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