Improve various aspects of mentions.
parent
72b94127fb
commit
139317cf1b
|
@ -1902,7 +1902,12 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
||||||
private void initializeMentionsViewModel() {
|
private void initializeMentionsViewModel() {
|
||||||
MentionsPickerViewModel mentionsViewModel = ViewModelProviders.of(this, new MentionsPickerViewModel.Factory()).get(MentionsPickerViewModel.class);
|
MentionsPickerViewModel mentionsViewModel = ViewModelProviders.of(this, new MentionsPickerViewModel.Factory()).get(MentionsPickerViewModel.class);
|
||||||
|
|
||||||
recipient.observe(this, mentionsViewModel::onRecipientChange);
|
recipient.observe(this, r -> {
|
||||||
|
if (r.isPushV2Group() && !mentionsSuggestions.resolved()) {
|
||||||
|
mentionsSuggestions.get();
|
||||||
|
}
|
||||||
|
mentionsViewModel.onRecipientChange(r);
|
||||||
|
});
|
||||||
|
|
||||||
composeText.setMentionQueryChangedListener(query -> {
|
composeText.setMentionQueryChangedListener(query -> {
|
||||||
if (getRecipient().isPushV2Group()) {
|
if (getRecipient().isPushV2Group()) {
|
||||||
|
|
|
@ -15,6 +15,8 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.groups.GroupId;
|
import org.thoughtcrime.securesms.groups.GroupId;
|
||||||
import org.thoughtcrime.securesms.groups.LiveGroup;
|
import org.thoughtcrime.securesms.groups.LiveGroup;
|
||||||
import org.thoughtcrime.securesms.groups.ui.GroupMemberEntry.FullMember;
|
import org.thoughtcrime.securesms.groups.ui.GroupMemberEntry.FullMember;
|
||||||
|
import org.thoughtcrime.securesms.megaphone.MegaphoneRepository;
|
||||||
|
import org.thoughtcrime.securesms.megaphone.Megaphones;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.MappingModel;
|
import org.thoughtcrime.securesms.util.MappingModel;
|
||||||
import org.thoughtcrime.securesms.util.SingleLiveEvent;
|
import org.thoughtcrime.securesms.util.SingleLiveEvent;
|
||||||
|
@ -30,8 +32,11 @@ public class MentionsPickerViewModel extends ViewModel {
|
||||||
private final MutableLiveData<LiveGroup> group;
|
private final MutableLiveData<LiveGroup> group;
|
||||||
private final MutableLiveData<Query> liveQuery;
|
private final MutableLiveData<Query> liveQuery;
|
||||||
private final MutableLiveData<Boolean> isShowing;
|
private final MutableLiveData<Boolean> isShowing;
|
||||||
|
private final MegaphoneRepository megaphoneRepository;
|
||||||
|
|
||||||
|
MentionsPickerViewModel(@NonNull MentionsPickerRepository mentionsPickerRepository, @NonNull MegaphoneRepository megaphoneRepository) {
|
||||||
|
this.megaphoneRepository = megaphoneRepository;
|
||||||
|
|
||||||
MentionsPickerViewModel(@NonNull MentionsPickerRepository mentionsPickerRepository) {
|
|
||||||
group = new MutableLiveData<>();
|
group = new MutableLiveData<>();
|
||||||
liveQuery = new MutableLiveData<>(Query.NONE);
|
liveQuery = new MutableLiveData<>(Query.NONE);
|
||||||
selectedRecipient = new SingleLiveEvent<>();
|
selectedRecipient = new SingleLiveEvent<>();
|
||||||
|
@ -50,6 +55,7 @@ public class MentionsPickerViewModel extends ViewModel {
|
||||||
|
|
||||||
void onSelectionChange(@NonNull Recipient recipient) {
|
void onSelectionChange(@NonNull Recipient recipient) {
|
||||||
selectedRecipient.setValue(recipient);
|
selectedRecipient.setValue(recipient);
|
||||||
|
megaphoneRepository.markFinished(Megaphones.Event.MENTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIsShowing(boolean isShowing) {
|
void setIsShowing(boolean isShowing) {
|
||||||
|
@ -116,7 +122,8 @@ public class MentionsPickerViewModel extends ViewModel {
|
||||||
@Override
|
@Override
|
||||||
public @NonNull <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
public @NonNull <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return modelClass.cast(new MentionsPickerViewModel(new MentionsPickerRepository(ApplicationDependencies.getApplication())));
|
return modelClass.cast(new MentionsPickerViewModel(new MentionsPickerRepository(ApplicationDependencies.getApplication()),
|
||||||
|
ApplicationDependencies.getMegaphoneRepository()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,11 @@ public class MegaphoneRepository {
|
||||||
@AnyThread
|
@AnyThread
|
||||||
public void markFinished(@NonNull Event event) {
|
public void markFinished(@NonNull Event event) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
|
MegaphoneRecord record = databaseCache.get(event);
|
||||||
|
if (record != null && record.isFinished()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
database.markFinished(event);
|
database.markFinished(event);
|
||||||
resetDatabaseCache();
|
resetDatabaseCache();
|
||||||
});
|
});
|
||||||
|
|
|
@ -211,7 +211,7 @@ public final class Megaphones {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldShowMentionsMegaphone() {
|
private static boolean shouldShowMentionsMegaphone() {
|
||||||
return FeatureFlags.mentions() && FeatureFlags.groupsV2();
|
return FeatureFlags.mentions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldShowLinkPreviewsMegaphone(@NonNull Context context) {
|
private static boolean shouldShowLinkPreviewsMegaphone(@NonNull Context context) {
|
||||||
|
|
|
@ -233,7 +233,7 @@ public final class FeatureFlags {
|
||||||
|
|
||||||
/** Whether or not we allow mentions send support in groups. */
|
/** Whether or not we allow mentions send support in groups. */
|
||||||
public static boolean mentions() {
|
public static boolean mentions() {
|
||||||
return getBoolean(MENTIONS, false);
|
return groupsV2() && getBoolean(MENTIONS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether or not to use the UUID in verification codes. */
|
/** Whether or not to use the UUID in verification codes. */
|
||||||
|
|
Loading…
Reference in New Issue