mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 14:38:26 +00:00
parent
1e895e960f
commit
79830049c4
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.components.emoji;
|
package org.thoughtcrime.securesms.components.emoji;
|
||||||
|
|
||||||
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.FontMetricsInt;
|
import android.graphics.Paint.FontMetricsInt;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@ -9,6 +10,9 @@ 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 float SHIFT_FACTOR = 1.5f;
|
||||||
|
|
||||||
private final int size;
|
private final int size;
|
||||||
private final FontMetricsInt fm;
|
private final FontMetricsInt fm;
|
||||||
|
|
||||||
@ -20,17 +24,25 @@ public class EmojiSpan extends AnimatingImageSpan {
|
|||||||
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
|
||||||
FontMetricsInt fm)
|
public int getSize(Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
|
||||||
{
|
|
||||||
if (fm != null && this.fm != null) {
|
if (fm != null && this.fm != null) {
|
||||||
fm.ascent = this.fm.ascent;
|
fm.ascent = this.fm.ascent;
|
||||||
fm.descent = this.fm.descent;
|
fm.descent = this.fm.descent;
|
||||||
fm.top = this.fm.top;
|
fm.top = this.fm.top;
|
||||||
fm.bottom = this.fm.bottom;
|
fm.bottom = this.fm.bottom;
|
||||||
|
fm.leading = this.fm.leading;
|
||||||
return size;
|
return size;
|
||||||
} else {
|
} else {
|
||||||
return super.getSize(paint, text, start, end, fm);
|
return super.getSize(paint, text, start, end, fm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
|
||||||
|
int height = bottom - top;
|
||||||
|
int centeringMargin = (height - size) / 2;
|
||||||
|
int adjustedMargin = (int) (centeringMargin * SHIFT_FACTOR);
|
||||||
|
super.draw(canvas, text, start, end, x, top, y, bottom - adjustedMargin, paint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user