mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-18 23:48:26 +00:00
parent
3bac3c6263
commit
6c5daf5ed6
@ -9,17 +9,28 @@ import android.widget.TextView;
|
|||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
|
||||||
public class EmojiSpan extends AnimatingImageSpan {
|
public class EmojiSpan extends AnimatingImageSpan {
|
||||||
|
private final int size;
|
||||||
|
private final FontMetricsInt fm;
|
||||||
|
|
||||||
public EmojiSpan(@NonNull Drawable drawable, @NonNull TextView tv) {
|
public EmojiSpan(@NonNull Drawable drawable, @NonNull TextView tv) {
|
||||||
super(drawable, tv);
|
super(drawable, tv);
|
||||||
FontMetricsInt fm = tv.getPaint().getFontMetricsInt();
|
fm = tv.getPaint().getFontMetricsInt();
|
||||||
final int size = fm != null ? Math.abs(fm.descent) + Math.abs(fm.ascent)
|
size = fm != null ? Math.abs(fm.descent) + Math.abs(fm.ascent)
|
||||||
: tv.getResources().getDimensionPixelSize(R.dimen.conversation_item_body_text_size);
|
: tv.getResources().getDimensionPixelSize(R.dimen.conversation_item_body_text_size);
|
||||||
getDrawable().setBounds(0, 0, size, size);
|
getDrawable().setBounds(0, 0, size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getSize(Paint paint, CharSequence text, int start, int end,
|
@Override public int getSize(Paint paint, CharSequence text, int start, int end,
|
||||||
FontMetricsInt fm)
|
FontMetricsInt fm)
|
||||||
{
|
{
|
||||||
return getDrawable().getBounds().right;
|
if (fm != null && this.fm != null) {
|
||||||
|
fm.ascent = this.fm.ascent;
|
||||||
|
fm.descent = this.fm.descent;
|
||||||
|
fm.top = this.fm.top;
|
||||||
|
fm.bottom = this.fm.bottom;
|
||||||
|
return size;
|
||||||
|
} else {
|
||||||
|
return super.getSize(paint, text, start, end, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user