Fix transformation method issues.

This commit is contained in:
Lucio Maciel 2021-09-16 10:20:00 -03:00 committed by Alex Hart
parent 4ac1134a9b
commit c43fe44e3e

View file

@ -11,6 +11,7 @@ import android.text.Spanned;
import android.text.TextDirectionHeuristic; import android.text.TextDirectionHeuristic;
import android.text.TextDirectionHeuristics; import android.text.TextDirectionHeuristics;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.method.TransformationMethod;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -42,6 +43,7 @@ public class EmojiTextView extends AppCompatTextView {
private boolean forceCustom; private boolean forceCustom;
private CharSequence previousText; private CharSequence previousText;
private BufferType previousBufferType; private BufferType previousBufferType;
private TransformationMethod previousTransformationMethod;
private float originalFontSize; private float originalFontSize;
private boolean useSystemEmoji; private boolean useSystemEmoji;
private boolean sizeChangeInProgress; private boolean sizeChangeInProgress;
@ -124,10 +126,11 @@ public class EmojiTextView extends AppCompatTextView {
return; return;
} }
previousText = text; previousText = text;
previousOverflowText = overflowText; previousOverflowText = overflowText;
previousBufferType = type; previousBufferType = type;
useSystemEmoji = useSystemEmoji(); useSystemEmoji = useSystemEmoji();
previousTransformationMethod = getTransformationMethod();
if (useSystemEmoji || candidates == null || candidates.size() == 0) { if (useSystemEmoji || candidates == null || candidates.size() == 0) {
super.setText(new SpannableStringBuilder(Optional.fromNullable(text).or("")), BufferType.NORMAL); super.setText(new SpannableStringBuilder(Optional.fromNullable(text).or("")), BufferType.NORMAL);
@ -158,9 +161,11 @@ public class EmojiTextView extends AppCompatTextView {
lastLineWidth = -1; lastLineWidth = -1;
} else { } else {
Layout layout = getLayout(); Layout layout = getLayout();
int lines = layout.getLineCount(); text = layout.getText();
int start = layout.getLineStart(lines - 1);
int count = text.length() - start; int lines = layout.getLineCount();
int start = layout.getLineStart(lines - 1);
int count = text.length() - start;
if ((getLayoutDirection() == LAYOUT_DIRECTION_LTR && textDirection.isRtl(text, start, count)) || if ((getLayoutDirection() == LAYOUT_DIRECTION_LTR && textDirection.isRtl(text, start, count)) ||
(getLayoutDirection() == LAYOUT_DIRECTION_RTL && !textDirection.isRtl(text, start, count))) { (getLayoutDirection() == LAYOUT_DIRECTION_RTL && !textDirection.isRtl(text, start, count))) {
@ -260,7 +265,8 @@ public class EmojiTextView extends AppCompatTextView {
Util.equals(previousOverflowText, overflowText) && Util.equals(previousOverflowText, overflowText) &&
Util.equals(previousBufferType, bufferType) && Util.equals(previousBufferType, bufferType) &&
useSystemEmoji == useSystemEmoji() && useSystemEmoji == useSystemEmoji() &&
!sizeChangeInProgress; !sizeChangeInProgress &&
previousTransformationMethod != getTransformationMethod();
} }
private boolean useSystemEmoji() { private boolean useSystemEmoji() {