Fix font size preference

Closes #6597
// FREEBIE
This commit is contained in:
Mateo Hernandez 2017-04-28 16:38:58 -05:00 committed by Moxie Marlinspike
parent 50cf9c448a
commit a93fb1a0e5

View File

@ -20,10 +20,10 @@ import org.thoughtcrime.securesms.util.ViewUtil;
public class EmojiTextView extends AppCompatTextView {
private final boolean scaleEmojis;
private final float originalFontSize;
private CharSequence source;
private boolean needsEllipsizing;
private float originalFontSize;
public EmojiTextView(Context context) {
this(context, null);
@ -56,9 +56,9 @@ public class EmojiTextView extends AppCompatTextView {
if (emojis <= 6) scale += 0.25f;
if (emojis <= 4) scale += 0.25f;
if (emojis <= 2) scale += 0.25f;
setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize() * scale);
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize * scale);
} else if (scaleEmojis) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize);
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize);
}
if (useSystemEmoji()) {
@ -106,4 +106,15 @@ public class EmojiTextView extends AppCompatTextView {
if (changed && !useSystemEmoji()) setTextEllipsized(source);
super.onLayout(changed, left, top, right, bottom);
}
@Override
public void setTextSize(float size) {
setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
}
@Override
public void setTextSize(int unit, float size) {
this.originalFontSize = TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics());
super.setTextSize(unit, size);
}
}