mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Allow EmojiTextView to redraw after changing emoji setting.
Also just fixed some minor formatting issues.
This commit is contained in:
parent
ceafb0d130
commit
f0e5aa312e
@ -25,6 +25,7 @@ public class EmojiTextView extends AppCompatTextView {
|
|||||||
|
|
||||||
private CharSequence originalText;
|
private CharSequence originalText;
|
||||||
private float originalFontSize;
|
private float originalFontSize;
|
||||||
|
private boolean useSystemEmoji;
|
||||||
|
|
||||||
public EmojiTextView(Context context) {
|
public EmojiTextView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@ -47,28 +48,31 @@ public class EmojiTextView extends AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setText(@Nullable CharSequence text, BufferType type) {
|
@Override public void setText(@Nullable CharSequence text, BufferType type) {
|
||||||
if (Util.equals(originalText, text)) {
|
if (Util.equals(originalText, text) && useSystemEmoji == useSystemEmoji()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
originalText = text;
|
originalText = text;
|
||||||
|
useSystemEmoji = useSystemEmoji();
|
||||||
|
|
||||||
EmojiProvider provider = EmojiProvider.getInstance(getContext());
|
EmojiProvider provider = EmojiProvider.getInstance(getContext());
|
||||||
EmojiParser.CandidateList candidates = provider.getCandidates(text);
|
EmojiParser.CandidateList candidates = provider.getCandidates(text);
|
||||||
|
|
||||||
if (scaleEmojis && candidates != null && candidates.allEmojis) {
|
if (scaleEmojis && candidates != null && candidates.allEmojis) {
|
||||||
int emojis = candidates.size();
|
int emojis = candidates.size();
|
||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
|
|
||||||
if (emojis <= 8) scale += 0.25f;
|
if (emojis <= 8) scale += 0.25f;
|
||||||
if (emojis <= 6) scale += 0.25f;
|
if (emojis <= 6) scale += 0.25f;
|
||||||
if (emojis <= 4) scale += 0.25f;
|
if (emojis <= 4) scale += 0.25f;
|
||||||
if (emojis <= 2) scale += 0.25f;
|
if (emojis <= 2) scale += 0.25f;
|
||||||
|
|
||||||
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize * scale);
|
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize * scale);
|
||||||
} else if (scaleEmojis) {
|
} else if (scaleEmojis) {
|
||||||
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize);
|
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useSystemEmoji() || candidates == null || candidates.size() == 0) {
|
if (useSystemEmoji || candidates == null || candidates.size() == 0) {
|
||||||
super.setText(text, BufferType.NORMAL);
|
super.setText(text, BufferType.NORMAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -85,7 +89,7 @@ public class EmojiTextView extends AppCompatTextView {
|
|||||||
|
|
||||||
private void ellipsize() {
|
private void ellipsize() {
|
||||||
post(() -> {
|
post(() -> {
|
||||||
if (getLayout() == null || getLineCount() == 0) {
|
if (getLayout() == null) {
|
||||||
ellipsize();
|
ellipsize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user