Fix various mention issues.

Fixes #9960
This commit is contained in:
Cody Henthorne
2020-09-25 12:13:18 -04:00
committed by Alan Evans
parent 93d6ce40c3
commit 6448b84430
5 changed files with 34 additions and 17 deletions

View File

@@ -1991,7 +1991,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
});
composeText.setMentionQueryChangedListener(query -> {
if (getRecipient().isPushV2Group()) {
if (getRecipient().isPushV2Group() && getRecipient().isActiveGroup()) {
if (!mentionsSuggestions.resolved()) {
mentionsSuggestions.get();
}
@@ -2000,7 +2000,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
});
composeText.setMentionValidator(annotations -> {
if (!getRecipient().isPushV2Group()) {
if (!getRecipient().isPushV2Group() || !getRecipient().isActiveGroup()) {
return annotations;
}

View File

@@ -1521,7 +1521,7 @@ public class ConversationItem extends LinearLayout implements BindableConversati
@Override
public void onClick(@NonNull View widget) {
if (eventListener != null && !Recipient.resolved(mentionedRecipientId).isLocalNumber()) {
if (eventListener != null) {
VibrateUtil.vibrateTick(context);
eventListener.onGroupMemberClicked(mentionedRecipientId, conversationRecipient.get().requireGroupId());
}

View File

@@ -30,6 +30,7 @@ public class MentionsPickerFragment extends LoggingFragment {
private View bottomDivider;
private BottomSheetBehavior<View> behavior;
private MentionsPickerViewModel viewModel;
private Runnable lockSheetAfterListUpdate = () -> behavior.setHideable(false);
@Override
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -62,6 +63,7 @@ public class MentionsPickerFragment extends LoggingFragment {
}
private void initializeBehavior() {
behavior.setHideable(true);
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
behavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@@ -69,6 +71,7 @@ public class MentionsPickerFragment extends LoggingFragment {
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
adapter.submitList(Collections.emptyList());
showDividers(false);
} else {
showDividers(true);
}
@@ -109,9 +112,10 @@ public class MentionsPickerFragment extends LoggingFragment {
if (isShowing) {
list.scrollToPosition(0);
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
list.post(() -> behavior.setHideable(false));
list.post(lockSheetAfterListUpdate);
showDividers(true);
} else {
list.getHandler().removeCallbacks(lockSheetAfterListUpdate);
behavior.setHideable(true);
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
}

View File

@@ -38,8 +38,8 @@ public class MentionsPickerViewModel extends ViewModel {
LiveData<Recipient> recipient = Transformations.switchMap(liveRecipient, LiveRecipient::getLiveData);
LiveData<List<RecipientId>> fullMembers = Transformations.distinctUntilChanged(LiveDataUtil.mapAsync(recipient, mentionsPickerRepository::getMembers));
LiveData<Query> query = Transformations.distinctUntilChanged(liveQuery);
LiveData<MentionQuery> mentionQuery = LiveDataUtil.combineLatest(query, fullMembers, (q, m) -> new MentionQuery(q.query, m));
LiveData<MentionQuery> mentionQuery = LiveDataUtil.combineLatest(liveQuery, fullMembers, (q, m) -> new MentionQuery(q.query, m));
this.mentionList = LiveDataUtil.mapAsync(mentionQuery, q -> Stream.of(mentionsPickerRepository.search(q)).<MappingModel<?>>map(MentionViewState::new).toList());
}