119 lines
4.0 KiB
Java
119 lines
4.0 KiB
Java
package o;
|
|
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.text.SpannableStringBuilder;
|
|
import android.text.TextUtils;
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
|
/* renamed from: o.BiK, reason: case insensitive filesystem */
|
|
/* loaded from: classes.dex */
|
|
public final class C0208BiK {
|
|
private static final String[] d = new String[0];
|
|
|
|
private static boolean d(int i) {
|
|
int i2 = i & 4095;
|
|
return i2 == 129 || i2 == 225 || i2 == 18;
|
|
}
|
|
|
|
public static void uy_(EditorInfo editorInfo, String[] strArr) {
|
|
editorInfo.contentMimeTypes = strArr;
|
|
}
|
|
|
|
public static void uA_(EditorInfo editorInfo, CharSequence charSequence) {
|
|
if (Build.VERSION.SDK_INT >= 30) {
|
|
Sts.uD_(editorInfo, charSequence, 0);
|
|
} else {
|
|
uz_(editorInfo, charSequence, 0);
|
|
}
|
|
}
|
|
|
|
public static void uz_(EditorInfo editorInfo, CharSequence charSequence, int i) {
|
|
int i2;
|
|
int i3;
|
|
if (Build.VERSION.SDK_INT >= 30) {
|
|
Sts.uD_(editorInfo, charSequence, i);
|
|
return;
|
|
}
|
|
if (editorInfo.initialSelStart > editorInfo.initialSelEnd) {
|
|
i2 = editorInfo.initialSelEnd;
|
|
} else {
|
|
i2 = editorInfo.initialSelStart;
|
|
}
|
|
int i4 = i2 - i;
|
|
if (editorInfo.initialSelStart > editorInfo.initialSelEnd) {
|
|
i3 = editorInfo.initialSelStart;
|
|
} else {
|
|
i3 = editorInfo.initialSelEnd;
|
|
}
|
|
int i5 = i3 - i;
|
|
int length = charSequence.length();
|
|
if (i < 0 || i4 < 0 || i5 > length) {
|
|
uB_(editorInfo, null, 0, 0);
|
|
return;
|
|
}
|
|
if (d(editorInfo.inputType)) {
|
|
uB_(editorInfo, null, 0, 0);
|
|
} else if (length <= 2048) {
|
|
uB_(editorInfo, charSequence, i4, i5);
|
|
} else {
|
|
uC_(editorInfo, charSequence, i4, i5);
|
|
}
|
|
}
|
|
|
|
private static void uC_(EditorInfo editorInfo, CharSequence charSequence, int i, int i2) {
|
|
CharSequence subSequence;
|
|
int i3 = i2 - i;
|
|
int i4 = i3 > 1024 ? 0 : i3;
|
|
int i5 = 2048 - i4;
|
|
int min = Math.min(charSequence.length() - i2, i5 - Math.min(i, (int) (i5 * 0.8d)));
|
|
int min2 = Math.min(i, i5 - min);
|
|
int i6 = i - min2;
|
|
if (d(charSequence, i6, 0)) {
|
|
i6++;
|
|
min2--;
|
|
}
|
|
if (d(charSequence, (i2 + min) - 1, 1)) {
|
|
min--;
|
|
}
|
|
if (i4 != i3) {
|
|
subSequence = TextUtils.concat(charSequence.subSequence(i6, i6 + min2), charSequence.subSequence(i2, min + i2));
|
|
} else {
|
|
subSequence = charSequence.subSequence(i6, min2 + i4 + min + i6);
|
|
}
|
|
uB_(editorInfo, subSequence, min2, i4 + min2);
|
|
}
|
|
|
|
private static boolean d(CharSequence charSequence, int i, int i2) {
|
|
if (i2 == 0) {
|
|
return Character.isLowSurrogate(charSequence.charAt(i));
|
|
}
|
|
if (i2 != 1) {
|
|
return false;
|
|
}
|
|
return Character.isHighSurrogate(charSequence.charAt(i));
|
|
}
|
|
|
|
private static void uB_(EditorInfo editorInfo, CharSequence charSequence, int i, int i2) {
|
|
if (editorInfo.extras == null) {
|
|
editorInfo.extras = new Bundle();
|
|
}
|
|
editorInfo.extras.putCharSequence("androidx.core.view.inputmethod.EditorInfoCompat.CONTENT_SURROUNDING_TEXT", charSequence != null ? new SpannableStringBuilder(charSequence) : null);
|
|
editorInfo.extras.putInt("androidx.core.view.inputmethod.EditorInfoCompat.CONTENT_SELECTION_HEAD", i);
|
|
editorInfo.extras.putInt("androidx.core.view.inputmethod.EditorInfoCompat.CONTENT_SELECTION_END", i2);
|
|
}
|
|
|
|
@Deprecated
|
|
public C0208BiK() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: o.BiK$Sts */
|
|
/* loaded from: classes.dex */
|
|
public static class Sts {
|
|
static void uD_(EditorInfo editorInfo, CharSequence charSequence, int i) {
|
|
editorInfo.setInitialSurroundingSubText(charSequence, i);
|
|
}
|
|
}
|
|
}
|