mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
parent
973ed7686b
commit
3c400f958e
@ -19,7 +19,7 @@ public class EmojiFilter implements InputFilter {
|
|||||||
char[] v = new char[end - start];
|
char[] v = new char[end - start];
|
||||||
TextUtils.getChars(source, start, end, v, 0);
|
TextUtils.getChars(source, start, end, v, 0);
|
||||||
Spannable emojified = EmojiProvider.getInstance(view.getContext()).emojify(new String(v), view);
|
Spannable emojified = EmojiProvider.getInstance(view.getContext()).emojify(new String(v), view);
|
||||||
if (source instanceof Spanned) {
|
if (source instanceof Spanned && emojified != null) {
|
||||||
TextUtils.copySpansFrom((Spanned) source, start, end, null, emojified, 0);
|
TextUtils.copySpansFrom((Spanned) source, start, end, null, emojified, 0);
|
||||||
}
|
}
|
||||||
return emojified;
|
return emojified;
|
||||||
|
@ -12,6 +12,8 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -78,7 +80,8 @@ public class EmojiProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Spannable emojify(CharSequence text, TextView tv) {
|
public @Nullable Spannable emojify(@Nullable CharSequence text, @NonNull TextView tv) {
|
||||||
|
if (text == null) return null;
|
||||||
Matcher matches = EMOJI_RANGE.matcher(text);
|
Matcher matches = EMOJI_RANGE.matcher(text);
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder(text);
|
SpannableStringBuilder builder = new SpannableStringBuilder(text);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.graphics.Paint.FontMetricsInt;
|
import android.graphics.Paint.FontMetricsInt;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.AppCompatTextView;
|
import android.support.v7.widget.AppCompatTextView;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextUtils.TruncateAt;
|
import android.text.TextUtils.TruncateAt;
|
||||||
@ -28,12 +29,12 @@ public class EmojiTextView extends AppCompatTextView {
|
|||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setText(CharSequence text, BufferType type) {
|
@Override public void setText(@Nullable CharSequence text, BufferType type) {
|
||||||
source = EmojiProvider.getInstance(getContext()).emojify(text, this);
|
source = EmojiProvider.getInstance(getContext()).emojify(text, this);
|
||||||
setTextEllipsized(source);
|
setTextEllipsized(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextEllipsized(final CharSequence source) {
|
public void setTextEllipsized(final @Nullable CharSequence source) {
|
||||||
super.setText(needsEllipsizing ? ViewUtil.ellipsize(source, this) : source, BufferType.SPANNABLE);
|
super.setText(needsEllipsizing ? ViewUtil.ellipsize(source, this) : source, BufferType.SPANNABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user