parent
93d6ce40c3
commit
6448b84430
|
@ -46,7 +46,8 @@ import static org.thoughtcrime.securesms.database.MentionUtil.MENTION_STARTER;
|
||||||
|
|
||||||
public class ComposeText extends EmojiEditText {
|
public class ComposeText extends EmojiEditText {
|
||||||
|
|
||||||
private CharSequence combinedHint;
|
private CharSequence hint;
|
||||||
|
private SpannableString subHint;
|
||||||
private MentionRendererDelegate mentionRendererDelegate;
|
private MentionRendererDelegate mentionRendererDelegate;
|
||||||
private MentionValidatorWatcher mentionValidatorWatcher;
|
private MentionValidatorWatcher mentionValidatorWatcher;
|
||||||
|
|
||||||
|
@ -84,8 +85,14 @@ public class ComposeText extends EmojiEditText {
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(combinedHint)) {
|
if (!TextUtils.isEmpty(hint)) {
|
||||||
setHint(combinedHint);
|
if (!TextUtils.isEmpty(subHint)) {
|
||||||
|
setHint(new SpannableStringBuilder().append(ellipsizeToWidth(hint))
|
||||||
|
.append("\n")
|
||||||
|
.append(ellipsizeToWidth(subHint)));
|
||||||
|
} else {
|
||||||
|
setHint(ellipsizeToWidth(hint));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,18 +150,24 @@ public class ComposeText extends EmojiEditText {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHint(@NonNull String hint, @Nullable CharSequence subHint) {
|
public void setHint(@NonNull String hint, @Nullable CharSequence subHint) {
|
||||||
if (subHint != null) {
|
this.hint = hint;
|
||||||
Spannable subHintSpannable = new SpannableString(subHint);
|
|
||||||
subHintSpannable.setSpan(new RelativeSizeSpan(0.5f), 0, subHintSpannable.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
|
||||||
|
|
||||||
combinedHint = new SpannableStringBuilder().append(ellipsizeToWidth(hint))
|
if (subHint != null) {
|
||||||
.append("\n")
|
this.subHint = new SpannableString(subHint);
|
||||||
.append(ellipsizeToWidth(subHintSpannable));
|
this.subHint.setSpan(new RelativeSizeSpan(0.5f), 0, subHint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
} else {
|
} else {
|
||||||
combinedHint = ellipsizeToWidth(hint);
|
this.subHint = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setHint(combinedHint);
|
if (this.subHint != null) {
|
||||||
|
super.setHint(new SpannableStringBuilder().append(ellipsizeToWidth(this.hint))
|
||||||
|
.append("\n")
|
||||||
|
.append(ellipsizeToWidth(this.subHint)));
|
||||||
|
} else {
|
||||||
|
super.setHint(ellipsizeToWidth(this.hint));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.setHint(hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendInvite(String invite) {
|
public void appendInvite(String invite) {
|
||||||
|
|
|
@ -1991,7 +1991,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
||||||
});
|
});
|
||||||
|
|
||||||
composeText.setMentionQueryChangedListener(query -> {
|
composeText.setMentionQueryChangedListener(query -> {
|
||||||
if (getRecipient().isPushV2Group()) {
|
if (getRecipient().isPushV2Group() && getRecipient().isActiveGroup()) {
|
||||||
if (!mentionsSuggestions.resolved()) {
|
if (!mentionsSuggestions.resolved()) {
|
||||||
mentionsSuggestions.get();
|
mentionsSuggestions.get();
|
||||||
}
|
}
|
||||||
|
@ -2000,7 +2000,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
||||||
});
|
});
|
||||||
|
|
||||||
composeText.setMentionValidator(annotations -> {
|
composeText.setMentionValidator(annotations -> {
|
||||||
if (!getRecipient().isPushV2Group()) {
|
if (!getRecipient().isPushV2Group() || !getRecipient().isActiveGroup()) {
|
||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1521,7 +1521,7 @@ public class ConversationItem extends LinearLayout implements BindableConversati
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(@NonNull View widget) {
|
public void onClick(@NonNull View widget) {
|
||||||
if (eventListener != null && !Recipient.resolved(mentionedRecipientId).isLocalNumber()) {
|
if (eventListener != null) {
|
||||||
VibrateUtil.vibrateTick(context);
|
VibrateUtil.vibrateTick(context);
|
||||||
eventListener.onGroupMemberClicked(mentionedRecipientId, conversationRecipient.get().requireGroupId());
|
eventListener.onGroupMemberClicked(mentionedRecipientId, conversationRecipient.get().requireGroupId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class MentionsPickerFragment extends LoggingFragment {
|
||||||
private View bottomDivider;
|
private View bottomDivider;
|
||||||
private BottomSheetBehavior<View> behavior;
|
private BottomSheetBehavior<View> behavior;
|
||||||
private MentionsPickerViewModel viewModel;
|
private MentionsPickerViewModel viewModel;
|
||||||
|
private Runnable lockSheetAfterListUpdate = () -> behavior.setHideable(false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
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() {
|
private void initializeBehavior() {
|
||||||
|
behavior.setHideable(true);
|
||||||
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
|
|
||||||
behavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
behavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||||
|
@ -69,6 +71,7 @@ public class MentionsPickerFragment extends LoggingFragment {
|
||||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||||
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
|
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
|
||||||
adapter.submitList(Collections.emptyList());
|
adapter.submitList(Collections.emptyList());
|
||||||
|
showDividers(false);
|
||||||
} else {
|
} else {
|
||||||
showDividers(true);
|
showDividers(true);
|
||||||
}
|
}
|
||||||
|
@ -109,9 +112,10 @@ public class MentionsPickerFragment extends LoggingFragment {
|
||||||
if (isShowing) {
|
if (isShowing) {
|
||||||
list.scrollToPosition(0);
|
list.scrollToPosition(0);
|
||||||
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
list.post(() -> behavior.setHideable(false));
|
list.post(lockSheetAfterListUpdate);
|
||||||
showDividers(true);
|
showDividers(true);
|
||||||
} else {
|
} else {
|
||||||
|
list.getHandler().removeCallbacks(lockSheetAfterListUpdate);
|
||||||
behavior.setHideable(true);
|
behavior.setHideable(true);
|
||||||
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class MentionsPickerViewModel extends ViewModel {
|
||||||
|
|
||||||
LiveData<Recipient> recipient = Transformations.switchMap(liveRecipient, LiveRecipient::getLiveData);
|
LiveData<Recipient> recipient = Transformations.switchMap(liveRecipient, LiveRecipient::getLiveData);
|
||||||
LiveData<List<RecipientId>> fullMembers = Transformations.distinctUntilChanged(LiveDataUtil.mapAsync(recipient, mentionsPickerRepository::getMembers));
|
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());
|
this.mentionList = LiveDataUtil.mapAsync(mentionQuery, q -> Stream.of(mentionsPickerRepository.search(q)).<MappingModel<?>>map(MentionViewState::new).toList());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue