- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
645 lines
27 KiB
Java
645 lines
27 KiB
Java
package androidx.emoji2.text;
|
|
|
|
import android.text.Editable;
|
|
import android.text.Selection;
|
|
import android.text.Spannable;
|
|
import android.text.SpannableString;
|
|
import android.text.Spanned;
|
|
import android.text.TextUtils;
|
|
import android.text.method.MetaKeyKeyListener;
|
|
import android.view.KeyEvent;
|
|
import android.view.inputmethod.InputConnection;
|
|
import androidx.annotation.AnyThread;
|
|
import androidx.annotation.IntRange;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.emoji2.text.EmojiCompat;
|
|
import androidx.emoji2.text.MetadataRepo;
|
|
import java.util.Arrays;
|
|
import java.util.Set;
|
|
|
|
@AnyThread
|
|
@RequiresApi(19)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
/* loaded from: classes.dex */
|
|
final class EmojiProcessor {
|
|
private static final int ACTION_ADVANCE_BOTH = 1;
|
|
private static final int ACTION_ADVANCE_END = 2;
|
|
private static final int ACTION_FLUSH = 3;
|
|
private static final int MAX_LOOK_AROUND_CHARACTER = 16;
|
|
|
|
@Nullable
|
|
private final int[] mEmojiAsDefaultStyleExceptions;
|
|
|
|
@NonNull
|
|
private EmojiCompat.GlyphChecker mGlyphChecker;
|
|
|
|
@NonNull
|
|
private final MetadataRepo mMetadataRepo;
|
|
|
|
@NonNull
|
|
private final EmojiCompat.SpanFactory mSpanFactory;
|
|
private final boolean mUseEmojiAsDefaultStyle;
|
|
|
|
public interface EmojiProcessCallback<T> {
|
|
T getResult();
|
|
|
|
boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer);
|
|
}
|
|
|
|
private static boolean hasInvalidSelection(int i, int i2) {
|
|
return i == -1 || i2 == -1 || i != i2;
|
|
}
|
|
|
|
public EmojiProcessor(@NonNull MetadataRepo metadataRepo, @NonNull EmojiCompat.SpanFactory spanFactory, @NonNull EmojiCompat.GlyphChecker glyphChecker, boolean z, @Nullable int[] iArr, @NonNull Set<int[]> set) {
|
|
this.mSpanFactory = spanFactory;
|
|
this.mMetadataRepo = metadataRepo;
|
|
this.mGlyphChecker = glyphChecker;
|
|
this.mUseEmojiAsDefaultStyle = z;
|
|
this.mEmojiAsDefaultStyleExceptions = iArr;
|
|
initExclusions(set);
|
|
}
|
|
|
|
private void initExclusions(@NonNull Set<int[]> set) {
|
|
if (set.isEmpty()) {
|
|
return;
|
|
}
|
|
for (int[] iArr : set) {
|
|
String str = new String(iArr, 0, iArr.length);
|
|
process(str, 0, str.length(), 1, true, new MarkExclusionCallback(str));
|
|
}
|
|
}
|
|
|
|
public int getEmojiMatch(@NonNull CharSequence charSequence) {
|
|
return getEmojiMatch(charSequence, this.mMetadataRepo.getMetadataVersion());
|
|
}
|
|
|
|
public int getEmojiMatch(@NonNull CharSequence charSequence, int i) {
|
|
ProcessorSm processorSm = new ProcessorSm(this.mMetadataRepo.getRootNode(), this.mUseEmojiAsDefaultStyle, this.mEmojiAsDefaultStyleExceptions);
|
|
int length = charSequence.length();
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
int i4 = 0;
|
|
while (i2 < length) {
|
|
int codePointAt = Character.codePointAt(charSequence, i2);
|
|
int check = processorSm.check(codePointAt);
|
|
TypefaceEmojiRasterizer currentMetadata = processorSm.getCurrentMetadata();
|
|
if (check == 1) {
|
|
i2 += Character.charCount(codePointAt);
|
|
i4 = 0;
|
|
} else if (check == 2) {
|
|
i2 += Character.charCount(codePointAt);
|
|
} else if (check == 3) {
|
|
currentMetadata = processorSm.getFlushMetadata();
|
|
if (currentMetadata.getCompatAdded() <= i) {
|
|
i3++;
|
|
}
|
|
}
|
|
if (currentMetadata != null && currentMetadata.getCompatAdded() <= i) {
|
|
i4++;
|
|
}
|
|
}
|
|
if (i3 != 0) {
|
|
return 2;
|
|
}
|
|
if (!processorSm.isInFlushableState() || processorSm.getCurrentMetadata().getCompatAdded() > i) {
|
|
return i4 == 0 ? 0 : 2;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
public int getEmojiStart(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
|
|
if (i < 0 || i >= charSequence.length()) {
|
|
return -1;
|
|
}
|
|
if (charSequence instanceof Spanned) {
|
|
Spanned spanned = (Spanned) charSequence;
|
|
EmojiSpan[] emojiSpanArr = (EmojiSpan[]) spanned.getSpans(i, i + 1, EmojiSpan.class);
|
|
if (emojiSpanArr.length > 0) {
|
|
return spanned.getSpanStart(emojiSpanArr[0]);
|
|
}
|
|
}
|
|
return ((EmojiProcessLookupCallback) process(charSequence, Math.max(0, i - 16), Math.min(charSequence.length(), i + 16), Integer.MAX_VALUE, true, new EmojiProcessLookupCallback(i))).start;
|
|
}
|
|
|
|
public int getEmojiEnd(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
|
|
if (i < 0 || i >= charSequence.length()) {
|
|
return -1;
|
|
}
|
|
if (charSequence instanceof Spanned) {
|
|
Spanned spanned = (Spanned) charSequence;
|
|
EmojiSpan[] emojiSpanArr = (EmojiSpan[]) spanned.getSpans(i, i + 1, EmojiSpan.class);
|
|
if (emojiSpanArr.length > 0) {
|
|
return spanned.getSpanEnd(emojiSpanArr[0]);
|
|
}
|
|
}
|
|
return ((EmojiProcessLookupCallback) process(charSequence, Math.max(0, i - 16), Math.min(charSequence.length(), i + 16), Integer.MAX_VALUE, true, new EmojiProcessLookupCallback(i))).end;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:15:0x0049 A[Catch: all -> 0x002a, TryCatch #0 {all -> 0x002a, blocks: (B:51:0x000e, B:54:0x0013, B:56:0x0017, B:58:0x0024, B:9:0x003a, B:11:0x0042, B:13:0x0045, B:15:0x0049, B:17:0x0055, B:19:0x0058, B:24:0x0066, B:30:0x0074, B:31:0x0080, B:33:0x0094, B:6:0x002f), top: B:50:0x000e }] */
|
|
/* JADX WARN: Removed duplicated region for block: B:33:0x0094 A[Catch: all -> 0x002a, TRY_LEAVE, TryCatch #0 {all -> 0x002a, blocks: (B:51:0x000e, B:54:0x0013, B:56:0x0017, B:58:0x0024, B:9:0x003a, B:11:0x0042, B:13:0x0045, B:15:0x0049, B:17:0x0055, B:19:0x0058, B:24:0x0066, B:30:0x0074, B:31:0x0080, B:33:0x0094, B:6:0x002f), top: B:50:0x000e }] */
|
|
/* JADX WARN: Removed duplicated region for block: B:44:0x00a0 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public java.lang.CharSequence process(@androidx.annotation.NonNull java.lang.CharSequence r11, @androidx.annotation.IntRange(from = 0) int r12, @androidx.annotation.IntRange(from = 0) int r13, @androidx.annotation.IntRange(from = 0) int r14, boolean r15) {
|
|
/*
|
|
r10 = this;
|
|
boolean r0 = r11 instanceof androidx.emoji2.text.SpannableBuilder
|
|
if (r0 == 0) goto La
|
|
r1 = r11
|
|
androidx.emoji2.text.SpannableBuilder r1 = (androidx.emoji2.text.SpannableBuilder) r1
|
|
r1.beginBatchEdit()
|
|
La:
|
|
java.lang.Class<androidx.emoji2.text.EmojiSpan> r1 = androidx.emoji2.text.EmojiSpan.class
|
|
if (r0 != 0) goto L2f
|
|
boolean r2 = r11 instanceof android.text.Spannable // Catch: java.lang.Throwable -> L2a
|
|
if (r2 == 0) goto L13
|
|
goto L2f
|
|
L13:
|
|
boolean r2 = r11 instanceof android.text.Spanned // Catch: java.lang.Throwable -> L2a
|
|
if (r2 == 0) goto L2d
|
|
r2 = r11
|
|
android.text.Spanned r2 = (android.text.Spanned) r2 // Catch: java.lang.Throwable -> L2a
|
|
int r3 = r12 + (-1)
|
|
int r4 = r13 + 1
|
|
int r2 = r2.nextSpanTransition(r3, r4, r1) // Catch: java.lang.Throwable -> L2a
|
|
if (r2 > r13) goto L2d
|
|
androidx.emoji2.text.UnprecomputeTextOnModificationSpannable r2 = new androidx.emoji2.text.UnprecomputeTextOnModificationSpannable // Catch: java.lang.Throwable -> L2a
|
|
r2.<init>(r11) // Catch: java.lang.Throwable -> L2a
|
|
goto L37
|
|
L2a:
|
|
r12 = move-exception
|
|
goto Lb2
|
|
L2d:
|
|
r2 = 0
|
|
goto L37
|
|
L2f:
|
|
androidx.emoji2.text.UnprecomputeTextOnModificationSpannable r2 = new androidx.emoji2.text.UnprecomputeTextOnModificationSpannable // Catch: java.lang.Throwable -> L2a
|
|
r3 = r11
|
|
android.text.Spannable r3 = (android.text.Spannable) r3 // Catch: java.lang.Throwable -> L2a
|
|
r2.<init>(r3) // Catch: java.lang.Throwable -> L2a
|
|
L37:
|
|
r3 = 0
|
|
if (r2 == 0) goto L63
|
|
java.lang.Object[] r4 = r2.getSpans(r12, r13, r1) // Catch: java.lang.Throwable -> L2a
|
|
androidx.emoji2.text.EmojiSpan[] r4 = (androidx.emoji2.text.EmojiSpan[]) r4 // Catch: java.lang.Throwable -> L2a
|
|
if (r4 == 0) goto L63
|
|
int r5 = r4.length // Catch: java.lang.Throwable -> L2a
|
|
if (r5 <= 0) goto L63
|
|
int r5 = r4.length // Catch: java.lang.Throwable -> L2a
|
|
r6 = r3
|
|
L47:
|
|
if (r6 >= r5) goto L63
|
|
r7 = r4[r6] // Catch: java.lang.Throwable -> L2a
|
|
int r8 = r2.getSpanStart(r7) // Catch: java.lang.Throwable -> L2a
|
|
int r9 = r2.getSpanEnd(r7) // Catch: java.lang.Throwable -> L2a
|
|
if (r8 == r13) goto L58
|
|
r2.removeSpan(r7) // Catch: java.lang.Throwable -> L2a
|
|
L58:
|
|
int r12 = java.lang.Math.min(r8, r12) // Catch: java.lang.Throwable -> L2a
|
|
int r13 = java.lang.Math.max(r9, r13) // Catch: java.lang.Throwable -> L2a
|
|
int r6 = r6 + 1
|
|
goto L47
|
|
L63:
|
|
r4 = r13
|
|
if (r12 == r4) goto La9
|
|
int r13 = r11.length() // Catch: java.lang.Throwable -> L2a
|
|
if (r12 < r13) goto L6d
|
|
goto La9
|
|
L6d:
|
|
r13 = 2147483647(0x7fffffff, float:NaN)
|
|
if (r14 == r13) goto L80
|
|
if (r2 == 0) goto L80
|
|
int r13 = r2.length() // Catch: java.lang.Throwable -> L2a
|
|
java.lang.Object[] r13 = r2.getSpans(r3, r13, r1) // Catch: java.lang.Throwable -> L2a
|
|
androidx.emoji2.text.EmojiSpan[] r13 = (androidx.emoji2.text.EmojiSpan[]) r13 // Catch: java.lang.Throwable -> L2a
|
|
int r13 = r13.length // Catch: java.lang.Throwable -> L2a
|
|
int r14 = r14 - r13
|
|
L80:
|
|
r5 = r14
|
|
androidx.emoji2.text.EmojiProcessor$EmojiProcessAddSpanCallback r7 = new androidx.emoji2.text.EmojiProcessor$EmojiProcessAddSpanCallback // Catch: java.lang.Throwable -> L2a
|
|
androidx.emoji2.text.EmojiCompat$SpanFactory r13 = r10.mSpanFactory // Catch: java.lang.Throwable -> L2a
|
|
r7.<init>(r2, r13) // Catch: java.lang.Throwable -> L2a
|
|
r1 = r10
|
|
r2 = r11
|
|
r3 = r12
|
|
r6 = r15
|
|
java.lang.Object r12 = r1.process(r2, r3, r4, r5, r6, r7) // Catch: java.lang.Throwable -> L2a
|
|
androidx.emoji2.text.UnprecomputeTextOnModificationSpannable r12 = (androidx.emoji2.text.UnprecomputeTextOnModificationSpannable) r12 // Catch: java.lang.Throwable -> L2a
|
|
if (r12 == 0) goto La0
|
|
android.text.Spannable r12 = r12.getUnwrappedSpannable() // Catch: java.lang.Throwable -> L2a
|
|
if (r0 == 0) goto L9f
|
|
androidx.emoji2.text.SpannableBuilder r11 = (androidx.emoji2.text.SpannableBuilder) r11
|
|
r11.endBatchEdit()
|
|
L9f:
|
|
return r12
|
|
La0:
|
|
if (r0 == 0) goto La8
|
|
r12 = r11
|
|
androidx.emoji2.text.SpannableBuilder r12 = (androidx.emoji2.text.SpannableBuilder) r12
|
|
r12.endBatchEdit()
|
|
La8:
|
|
return r11
|
|
La9:
|
|
if (r0 == 0) goto Lb1
|
|
r12 = r11
|
|
androidx.emoji2.text.SpannableBuilder r12 = (androidx.emoji2.text.SpannableBuilder) r12
|
|
r12.endBatchEdit()
|
|
Lb1:
|
|
return r11
|
|
Lb2:
|
|
if (r0 == 0) goto Lb9
|
|
androidx.emoji2.text.SpannableBuilder r11 = (androidx.emoji2.text.SpannableBuilder) r11
|
|
r11.endBatchEdit()
|
|
Lb9:
|
|
throw r12
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.emoji2.text.EmojiProcessor.process(java.lang.CharSequence, int, int, int, boolean):java.lang.CharSequence");
|
|
}
|
|
|
|
private <T> T process(@NonNull CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, @IntRange(from = 0) int i3, boolean z, EmojiProcessCallback<T> emojiProcessCallback) {
|
|
int i4;
|
|
ProcessorSm processorSm = new ProcessorSm(this.mMetadataRepo.getRootNode(), this.mUseEmojiAsDefaultStyle, this.mEmojiAsDefaultStyleExceptions);
|
|
int i5 = 0;
|
|
boolean z2 = true;
|
|
int codePointAt = Character.codePointAt(charSequence, i);
|
|
loop0: while (true) {
|
|
i4 = i;
|
|
while (i < i2 && i5 < i3 && z2) {
|
|
int check = processorSm.check(codePointAt);
|
|
if (check == 1) {
|
|
i4 += Character.charCount(Character.codePointAt(charSequence, i4));
|
|
if (i4 < i2) {
|
|
codePointAt = Character.codePointAt(charSequence, i4);
|
|
}
|
|
i = i4;
|
|
} else if (check == 2) {
|
|
i += Character.charCount(codePointAt);
|
|
if (i < i2) {
|
|
codePointAt = Character.codePointAt(charSequence, i);
|
|
}
|
|
} else if (check == 3) {
|
|
if (z || !hasGlyph(charSequence, i4, i, processorSm.getFlushMetadata())) {
|
|
z2 = emojiProcessCallback.handleEmoji(charSequence, i4, i, processorSm.getFlushMetadata());
|
|
i5++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (processorSm.isInFlushableState() && i5 < i3 && z2 && (z || !hasGlyph(charSequence, i4, i, processorSm.getCurrentMetadata()))) {
|
|
emojiProcessCallback.handleEmoji(charSequence, i4, i, processorSm.getCurrentMetadata());
|
|
}
|
|
return emojiProcessCallback.getResult();
|
|
}
|
|
|
|
public static boolean handleOnKeyDown(@NonNull Editable editable, int i, @NonNull KeyEvent keyEvent) {
|
|
boolean delete;
|
|
if (i != 67) {
|
|
if (i == 112) {
|
|
delete = delete(editable, keyEvent, true);
|
|
}
|
|
return false;
|
|
}
|
|
delete = delete(editable, keyEvent, false);
|
|
if (delete) {
|
|
MetaKeyKeyListener.adjustMetaAfterKeypress(editable);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static boolean delete(@NonNull Editable editable, @NonNull KeyEvent keyEvent, boolean z) {
|
|
EmojiSpan[] emojiSpanArr;
|
|
if (hasModifiers(keyEvent)) {
|
|
return false;
|
|
}
|
|
int selectionStart = Selection.getSelectionStart(editable);
|
|
int selectionEnd = Selection.getSelectionEnd(editable);
|
|
if (!hasInvalidSelection(selectionStart, selectionEnd) && (emojiSpanArr = (EmojiSpan[]) editable.getSpans(selectionStart, selectionEnd, EmojiSpan.class)) != null && emojiSpanArr.length > 0) {
|
|
for (EmojiSpan emojiSpan : emojiSpanArr) {
|
|
int spanStart = editable.getSpanStart(emojiSpan);
|
|
int spanEnd = editable.getSpanEnd(emojiSpan);
|
|
if ((z && spanStart == selectionStart) || ((!z && spanEnd == selectionStart) || (selectionStart > spanStart && selectionStart < spanEnd))) {
|
|
editable.delete(spanStart, spanEnd);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static boolean handleDeleteSurroundingText(@NonNull InputConnection inputConnection, @NonNull Editable editable, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, boolean z) {
|
|
int max;
|
|
int min;
|
|
if (editable != null && inputConnection != null && i >= 0 && i2 >= 0) {
|
|
int selectionStart = Selection.getSelectionStart(editable);
|
|
int selectionEnd = Selection.getSelectionEnd(editable);
|
|
if (hasInvalidSelection(selectionStart, selectionEnd)) {
|
|
return false;
|
|
}
|
|
if (z) {
|
|
max = CodepointIndexFinder.findIndexBackward(editable, selectionStart, Math.max(i, 0));
|
|
min = CodepointIndexFinder.findIndexForward(editable, selectionEnd, Math.max(i2, 0));
|
|
if (max == -1 || min == -1) {
|
|
return false;
|
|
}
|
|
} else {
|
|
max = Math.max(selectionStart - i, 0);
|
|
min = Math.min(selectionEnd + i2, editable.length());
|
|
}
|
|
EmojiSpan[] emojiSpanArr = (EmojiSpan[]) editable.getSpans(max, min, EmojiSpan.class);
|
|
if (emojiSpanArr != null && emojiSpanArr.length > 0) {
|
|
for (EmojiSpan emojiSpan : emojiSpanArr) {
|
|
int spanStart = editable.getSpanStart(emojiSpan);
|
|
int spanEnd = editable.getSpanEnd(emojiSpan);
|
|
max = Math.min(spanStart, max);
|
|
min = Math.max(spanEnd, min);
|
|
}
|
|
int max2 = Math.max(max, 0);
|
|
int min2 = Math.min(min, editable.length());
|
|
inputConnection.beginBatchEdit();
|
|
editable.delete(max2, min2);
|
|
inputConnection.endBatchEdit();
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static boolean hasModifiers(@NonNull KeyEvent keyEvent) {
|
|
return !KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState());
|
|
}
|
|
|
|
private boolean hasGlyph(CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
|
|
if (typefaceEmojiRasterizer.getHasGlyph() == 0) {
|
|
typefaceEmojiRasterizer.setHasGlyph(this.mGlyphChecker.hasGlyph(charSequence, i, i2, typefaceEmojiRasterizer.getSdkAdded()));
|
|
}
|
|
return typefaceEmojiRasterizer.getHasGlyph() == 2;
|
|
}
|
|
|
|
public static final class ProcessorSm {
|
|
private static final int STATE_DEFAULT = 1;
|
|
private static final int STATE_WALKING = 2;
|
|
private int mCurrentDepth;
|
|
private MetadataRepo.Node mCurrentNode;
|
|
private final int[] mEmojiAsDefaultStyleExceptions;
|
|
private MetadataRepo.Node mFlushNode;
|
|
private int mLastCodepoint;
|
|
private final MetadataRepo.Node mRootNode;
|
|
private int mState = 1;
|
|
private final boolean mUseEmojiAsDefaultStyle;
|
|
|
|
private static boolean isEmojiStyle(int i) {
|
|
return i == 65039;
|
|
}
|
|
|
|
private static boolean isTextStyle(int i) {
|
|
return i == 65038;
|
|
}
|
|
|
|
private int reset() {
|
|
this.mState = 1;
|
|
this.mCurrentNode = this.mRootNode;
|
|
this.mCurrentDepth = 0;
|
|
return 1;
|
|
}
|
|
|
|
public ProcessorSm(MetadataRepo.Node node, boolean z, int[] iArr) {
|
|
this.mRootNode = node;
|
|
this.mCurrentNode = node;
|
|
this.mUseEmojiAsDefaultStyle = z;
|
|
this.mEmojiAsDefaultStyleExceptions = iArr;
|
|
}
|
|
|
|
public int check(int i) {
|
|
MetadataRepo.Node node = this.mCurrentNode.get(i);
|
|
int i2 = 2;
|
|
if (this.mState != 2) {
|
|
if (node == null) {
|
|
i2 = reset();
|
|
} else {
|
|
this.mState = 2;
|
|
this.mCurrentNode = node;
|
|
this.mCurrentDepth = 1;
|
|
}
|
|
} else if (node != null) {
|
|
this.mCurrentNode = node;
|
|
this.mCurrentDepth++;
|
|
} else if (isTextStyle(i)) {
|
|
i2 = reset();
|
|
} else if (!isEmojiStyle(i)) {
|
|
if (this.mCurrentNode.getData() != null) {
|
|
i2 = 3;
|
|
if (this.mCurrentDepth == 1) {
|
|
if (shouldUseEmojiPresentationStyleForSingleCodepoint()) {
|
|
this.mFlushNode = this.mCurrentNode;
|
|
reset();
|
|
} else {
|
|
i2 = reset();
|
|
}
|
|
} else {
|
|
this.mFlushNode = this.mCurrentNode;
|
|
reset();
|
|
}
|
|
} else {
|
|
i2 = reset();
|
|
}
|
|
}
|
|
this.mLastCodepoint = i;
|
|
return i2;
|
|
}
|
|
|
|
public TypefaceEmojiRasterizer getFlushMetadata() {
|
|
return this.mFlushNode.getData();
|
|
}
|
|
|
|
public TypefaceEmojiRasterizer getCurrentMetadata() {
|
|
return this.mCurrentNode.getData();
|
|
}
|
|
|
|
public boolean isInFlushableState() {
|
|
return this.mState == 2 && this.mCurrentNode.getData() != null && (this.mCurrentDepth > 1 || shouldUseEmojiPresentationStyleForSingleCodepoint());
|
|
}
|
|
|
|
private boolean shouldUseEmojiPresentationStyleForSingleCodepoint() {
|
|
if (this.mCurrentNode.getData().isDefaultEmoji() || isEmojiStyle(this.mLastCodepoint)) {
|
|
return true;
|
|
}
|
|
if (this.mUseEmojiAsDefaultStyle) {
|
|
if (this.mEmojiAsDefaultStyleExceptions == null) {
|
|
return true;
|
|
}
|
|
if (Arrays.binarySearch(this.mEmojiAsDefaultStyleExceptions, this.mCurrentNode.getData().getCodepointAt(0)) < 0) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@RequiresApi(19)
|
|
public static final class CodepointIndexFinder {
|
|
private static final int INVALID_INDEX = -1;
|
|
|
|
private CodepointIndexFinder() {
|
|
}
|
|
|
|
public static int findIndexBackward(CharSequence charSequence, int i, int i2) {
|
|
int length = charSequence.length();
|
|
if (i < 0 || length < i || i2 < 0) {
|
|
return -1;
|
|
}
|
|
while (true) {
|
|
boolean z = false;
|
|
while (i2 != 0) {
|
|
i--;
|
|
if (i < 0) {
|
|
return z ? -1 : 0;
|
|
}
|
|
char charAt = charSequence.charAt(i);
|
|
if (z) {
|
|
if (!Character.isHighSurrogate(charAt)) {
|
|
return -1;
|
|
}
|
|
i2--;
|
|
} else if (!Character.isSurrogate(charAt)) {
|
|
i2--;
|
|
} else {
|
|
if (Character.isHighSurrogate(charAt)) {
|
|
return -1;
|
|
}
|
|
z = true;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
}
|
|
|
|
public static int findIndexForward(CharSequence charSequence, int i, int i2) {
|
|
int length = charSequence.length();
|
|
if (i < 0 || length < i || i2 < 0) {
|
|
return -1;
|
|
}
|
|
while (true) {
|
|
boolean z = false;
|
|
while (i2 != 0) {
|
|
if (i >= length) {
|
|
if (z) {
|
|
return -1;
|
|
}
|
|
return length;
|
|
}
|
|
char charAt = charSequence.charAt(i);
|
|
if (z) {
|
|
if (!Character.isLowSurrogate(charAt)) {
|
|
return -1;
|
|
}
|
|
i2--;
|
|
i++;
|
|
} else if (!Character.isSurrogate(charAt)) {
|
|
i2--;
|
|
i++;
|
|
} else {
|
|
if (Character.isLowSurrogate(charAt)) {
|
|
return -1;
|
|
}
|
|
i++;
|
|
z = true;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static class EmojiProcessAddSpanCallback implements EmojiProcessCallback<UnprecomputeTextOnModificationSpannable> {
|
|
private final EmojiCompat.SpanFactory mSpanFactory;
|
|
|
|
@Nullable
|
|
public UnprecomputeTextOnModificationSpannable spannable;
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
|
|
public UnprecomputeTextOnModificationSpannable getResult() {
|
|
return this.spannable;
|
|
}
|
|
|
|
public EmojiProcessAddSpanCallback(@Nullable UnprecomputeTextOnModificationSpannable unprecomputeTextOnModificationSpannable, EmojiCompat.SpanFactory spanFactory) {
|
|
this.spannable = unprecomputeTextOnModificationSpannable;
|
|
this.mSpanFactory = spanFactory;
|
|
}
|
|
|
|
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
|
|
public boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
|
|
Spannable spannableString;
|
|
if (typefaceEmojiRasterizer.isPreferredSystemRender()) {
|
|
return true;
|
|
}
|
|
if (this.spannable == null) {
|
|
if (charSequence instanceof Spannable) {
|
|
spannableString = (Spannable) charSequence;
|
|
} else {
|
|
spannableString = new SpannableString(charSequence);
|
|
}
|
|
this.spannable = new UnprecomputeTextOnModificationSpannable(spannableString);
|
|
}
|
|
this.spannable.setSpan(this.mSpanFactory.createSpan(typefaceEmojiRasterizer), i, i2, 33);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public static class EmojiProcessLookupCallback implements EmojiProcessCallback<EmojiProcessLookupCallback> {
|
|
private final int mOffset;
|
|
public int start = -1;
|
|
public int end = -1;
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
|
|
public EmojiProcessLookupCallback getResult() {
|
|
return this;
|
|
}
|
|
|
|
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
|
|
public boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
|
|
int i3 = this.mOffset;
|
|
if (i > i3 || i3 >= i2) {
|
|
return i2 <= i3;
|
|
}
|
|
this.start = i;
|
|
this.end = i2;
|
|
return false;
|
|
}
|
|
|
|
public EmojiProcessLookupCallback(int i) {
|
|
this.mOffset = i;
|
|
}
|
|
}
|
|
|
|
public static class MarkExclusionCallback implements EmojiProcessCallback<MarkExclusionCallback> {
|
|
private final String mExclusion;
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
|
|
public MarkExclusionCallback getResult() {
|
|
return this;
|
|
}
|
|
|
|
public MarkExclusionCallback(String str) {
|
|
this.mExclusion = str;
|
|
}
|
|
|
|
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
|
|
public boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
|
|
if (!TextUtils.equals(charSequence.subSequence(i, i2), this.mExclusion)) {
|
|
return true;
|
|
}
|
|
typefaceEmojiRasterizer.setExclusion(true);
|
|
return false;
|
|
}
|
|
}
|
|
}
|