mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
parent
f04281ac4a
commit
4840cdd293
@ -17,6 +17,8 @@ import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class ComposeText extends EmojiEditText {
|
||||
private SpannableString hint;
|
||||
|
||||
public ComposeText(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@ -31,18 +33,22 @@ public class ComposeText extends EmojiEditText {
|
||||
|
||||
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (!TextUtils.isEmpty(getHint())) {
|
||||
setHint(TextUtils.ellipsize(getHint(),
|
||||
getPaint(),
|
||||
getWidth() - getPaddingLeft() - getPaddingRight(),
|
||||
TruncateAt.END));
|
||||
if (!TextUtils.isEmpty(hint)) {
|
||||
setHint(ellipsizeToWidth(hint));
|
||||
}
|
||||
}
|
||||
|
||||
private CharSequence ellipsizeToWidth(CharSequence text) {
|
||||
return TextUtils.ellipsize(text,
|
||||
getPaint(),
|
||||
getWidth() - getPaddingLeft() - getPaddingRight(),
|
||||
TruncateAt.END);
|
||||
}
|
||||
|
||||
public void setHint(@NonNull String hint) {
|
||||
SpannableString span = new SpannableString(hint);
|
||||
span.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
super.setHint(span);
|
||||
this.hint = new SpannableString(hint);
|
||||
this.hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
super.setHint(ellipsizeToWidth(this.hint));
|
||||
}
|
||||
|
||||
public void appendInvite(String invite) {
|
||||
|
@ -14,6 +14,7 @@ public class EmojiFilter implements InputFilter, OnGlobalLayoutListener {
|
||||
|
||||
public EmojiFilter(TextView view) {
|
||||
this.view = view;
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(this);
|
||||
}
|
||||
|
||||
@Override public CharSequence filter(CharSequence source, int start, int end,
|
||||
@ -25,7 +26,6 @@ public class EmojiFilter implements InputFilter, OnGlobalLayoutListener {
|
||||
if (source instanceof Spanned) {
|
||||
TextUtils.copySpansFrom((Spanned) source, start, end, null, emojified, 0);
|
||||
}
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(this);
|
||||
if (view.getWidth() == 0 || view.getEllipsize() != TruncateAt.END) {
|
||||
return emojified;
|
||||
} else {
|
||||
@ -38,13 +38,6 @@ public class EmojiFilter implements InputFilter, OnGlobalLayoutListener {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public void onGlobalLayout() {
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
else {
|
||||
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
|
||||
view.invalidate();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user