package o; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.ComponentInfo; import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.ColorStateList; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.icu.text.DecimalFormatSymbols; import android.os.Build; import android.text.Editable; import android.text.PrecomputedText; import android.text.TextDirectionHeuristic; import android.text.TextDirectionHeuristics; import android.text.TextPaint; import android.text.method.PasswordTransformationMethod; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.TextView; import androidx.core.text.PrecomputedTextCompat; import com.huawei.hms.support.api.entity.common.CommonConstant; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Locale; /* loaded from: classes.dex */ public final class URz { public static void vZ_(TextView textView, Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { Sts.wm_(textView, drawable, drawable2, drawable3, drawable4); } public static int vR_(TextView textView) { return LWm.wj_(textView); } public static void we_(TextView textView, int i) { textView.setTextAppearance(i); } public static Drawable[] vO_(TextView textView) { return Sts.wk_(textView); } /* JADX WARN: Multi-variable type inference failed */ public static void vW_(TextView textView, int i) { if (Build.VERSION.SDK_INT >= 27) { HBt.wv_(textView, i); } else if (textView instanceof KBh) { ((KBh) textView).setAutoSizeTextTypeWithDefaults(i); } } /* JADX WARN: Multi-variable type inference failed */ public static void vV_(TextView textView, int i, int i2, int i3, int i4) throws IllegalArgumentException { if (Build.VERSION.SDK_INT >= 27) { HBt.wu_(textView, i, i2, i3, i4); } else if (textView instanceof KBh) { ((KBh) textView).setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4); } } public static ActionMode.Callback wh_(TextView textView, ActionMode.Callback callback) { return (Build.VERSION.SDK_INT > 27 || (callback instanceof ojQ) || callback == null) ? callback : new ojQ(callback, textView); } public static ActionMode.Callback wg_(ActionMode.Callback callback) { return callback instanceof ojQ ? ((ojQ) callback).wF_() : callback; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class ojQ implements ActionMode.Callback { private boolean a = false; private boolean b; private Method c; private Class d; private final ActionMode.Callback e; private final TextView i; ojQ(ActionMode.Callback callback, TextView textView) { this.e = callback; this.i = textView; } @Override // android.view.ActionMode.Callback public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { return this.e.onCreateActionMode(actionMode, menu); } @Override // android.view.ActionMode.Callback public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { wE_(menu); return this.e.onPrepareActionMode(actionMode, menu); } @Override // android.view.ActionMode.Callback public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { return this.e.onActionItemClicked(actionMode, menuItem); } @Override // android.view.ActionMode.Callback public void onDestroyActionMode(ActionMode actionMode) { this.e.onDestroyActionMode(actionMode); } private void wE_(Menu menu) { Context context = this.i.getContext(); PackageManager packageManager = context.getPackageManager(); if (!this.a) { this.a = true; try { Class cls = Class.forName("com.android.internal.view.menu.MenuBuilder"); this.d = cls; this.c = cls.getDeclaredMethod("removeItemAt", Integer.TYPE); this.b = true; } catch (ClassNotFoundException | NoSuchMethodException unused) { this.d = null; this.c = null; this.b = false; } } try { Method declaredMethod = (this.b && this.d.isInstance(menu)) ? this.c : menu.getClass().getDeclaredMethod("removeItemAt", Integer.TYPE); for (int size = menu.size() - 1; size >= 0; size--) { MenuItem item = menu.getItem(size); if (item.getIntent() != null && "android.intent.action.PROCESS_TEXT".equals(item.getIntent().getAction())) { declaredMethod.invoke(menu, Integer.valueOf(size)); } } List wB_ = wB_(context, packageManager); for (int i = 0; i < wB_.size(); i++) { ResolveInfo resolveInfo = wB_.get(i); menu.add(0, 0, i + 100, resolveInfo.loadLabel(packageManager)).setIntent(wA_(resolveInfo, this.i)).setShowAsAction(1); } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused2) { } } private List wB_(Context context, PackageManager packageManager) { ArrayList arrayList = new ArrayList(); if (!(context instanceof Activity)) { return arrayList; } for (ResolveInfo resolveInfo : packageManager.queryIntentActivities(wz_(), 0)) { if (wD_(resolveInfo, context)) { arrayList.add(resolveInfo); } } return arrayList; } private boolean wD_(ResolveInfo resolveInfo, Context context) { if (context.getPackageName().equals(PackageItemInfo.class.getField(CommonConstant.ReqAccessTokenParam.PACKAGE_NAME).get(resolveInfo.activityInfo))) { return true; } if (ComponentInfo.class.getField("exported").getBoolean(resolveInfo.activityInfo)) { return resolveInfo.activityInfo.permission == null || context.checkSelfPermission(resolveInfo.activityInfo.permission) == 0; } return false; } private Intent wA_(ResolveInfo resolveInfo, TextView textView) { return wz_().putExtra("android.intent.extra.PROCESS_TEXT_READONLY", !wC_(textView)).setClassName((String) PackageItemInfo.class.getField(CommonConstant.ReqAccessTokenParam.PACKAGE_NAME).get(resolveInfo.activityInfo), (String) PackageItemInfo.class.getField("name").get(resolveInfo.activityInfo)); } private boolean wC_(TextView textView) { return (textView instanceof Editable) && textView.onCheckIsTextEditor() && textView.isEnabled(); } private Intent wz_() { return new Intent().setAction("android.intent.action.PROCESS_TEXT").setType("text/plain"); } ActionMode.Callback wF_() { return this.e; } } public static void wa_(TextView textView, int i) { int i2; if (i >= 0) { if (Build.VERSION.SDK_INT >= 28) { ZqN.wy_(textView, i); return; } Paint.FontMetricsInt fontMetricsInt = textView.getPaint().getFontMetricsInt(); if (LWm.wi_(textView)) { i2 = fontMetricsInt.top; } else { i2 = fontMetricsInt.ascent; } if (i > Math.abs(i2)) { textView.setPadding(textView.getPaddingLeft(), i + i2, textView.getPaddingRight(), textView.getPaddingBottom()); return; } return; } throw new IllegalArgumentException(); } public static void wb_(TextView textView, int i) { int i2; if (i >= 0) { Paint.FontMetricsInt fontMetricsInt = textView.getPaint().getFontMetricsInt(); if (LWm.wi_(textView)) { i2 = fontMetricsInt.bottom; } else { i2 = fontMetricsInt.descent; } if (i > Math.abs(i2)) { textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), i - i2); return; } return; } throw new IllegalArgumentException(); } public static int vP_(TextView textView) { return textView.getPaddingTop() - textView.getPaint().getFontMetricsInt().top; } public static int vQ_(TextView textView) { return textView.getPaddingBottom() + textView.getPaint().getFontMetricsInt().bottom; } public static void wc_(TextView textView, int i) { if (i >= 0) { if (i != textView.getPaint().getFontMetricsInt(null)) { textView.setLineSpacing(i - r0, 1.0f); return; } return; } throw new IllegalArgumentException(); } public static PrecomputedTextCompat.Params vU_(TextView textView) { if (Build.VERSION.SDK_INT >= 28) { return new PrecomputedTextCompat.Params(ZqN.wx_(textView)); } PrecomputedTextCompat.Params.IeS ieS = new PrecomputedTextCompat.Params.IeS(new TextPaint(textView.getPaint())); ieS.c(IeS.wn_(textView)); ieS.b(IeS.wo_(textView)); ieS.qN_(vT_(textView)); return ieS.a(); } public static void wf_(TextView textView, PrecomputedTextCompat.Params params) { Sts.b(textView, vS_(params.qL_())); textView.getPaint().set(params.qM_()); IeS.wp_(textView, params.c()); IeS.ws_(textView, params.e()); } public static void wd_(TextView textView, PrecomputedTextCompat precomputedTextCompat) { if (Build.VERSION.SDK_INT >= 29) { textView.setText(precomputedTextCompat.qK_()); } else { if (!vU_(textView).d(precomputedTextCompat.e())) { throw new IllegalArgumentException("Given text can not be applied to TextView."); } textView.setText(precomputedTextCompat); } } private static TextDirectionHeuristic vT_(TextView textView) { if (textView.getTransformationMethod() instanceof PasswordTransformationMethod) { return TextDirectionHeuristics.LTR; } if (Build.VERSION.SDK_INT >= 28 && (textView.getInputType() & 15) == 3) { byte directionality = Character.getDirectionality(ZqN.ww_(RVV.wt_(Sts.wl_(textView)))[0].codePointAt(0)); if (directionality == 1 || directionality == 2) { return TextDirectionHeuristics.RTL; } return TextDirectionHeuristics.LTR; } boolean z = Sts.a(textView) == 1; switch (Sts.b(textView)) { case 2: return TextDirectionHeuristics.ANYRTL_LTR; case 3: return TextDirectionHeuristics.LTR; case 4: return TextDirectionHeuristics.RTL; case 5: return TextDirectionHeuristics.LOCALE; case 6: return TextDirectionHeuristics.FIRSTSTRONG_LTR; case 7: return TextDirectionHeuristics.FIRSTSTRONG_RTL; default: if (z) { return TextDirectionHeuristics.FIRSTSTRONG_RTL; } return TextDirectionHeuristics.FIRSTSTRONG_LTR; } } private static int vS_(TextDirectionHeuristic textDirectionHeuristic) { if (textDirectionHeuristic == TextDirectionHeuristics.FIRSTSTRONG_RTL || textDirectionHeuristic == TextDirectionHeuristics.FIRSTSTRONG_LTR) { return 1; } if (textDirectionHeuristic == TextDirectionHeuristics.ANYRTL_LTR) { return 2; } if (textDirectionHeuristic == TextDirectionHeuristics.LTR) { return 3; } if (textDirectionHeuristic == TextDirectionHeuristics.RTL) { return 4; } if (textDirectionHeuristic == TextDirectionHeuristics.LOCALE) { return 5; } if (textDirectionHeuristic == TextDirectionHeuristics.FIRSTSTRONG_LTR) { return 6; } return textDirectionHeuristic == TextDirectionHeuristics.FIRSTSTRONG_RTL ? 7 : 1; } public static void vX_(TextView textView, ColorStateList colorStateList) { IeS.wq_(textView, colorStateList); } public static void vY_(TextView textView, PorterDuff.Mode mode) { IeS.wr_(textView, mode); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class Sts { static void wm_(TextView textView, Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { textView.setCompoundDrawablesRelative(drawable, drawable2, drawable3, drawable4); } static int a(View view) { return view.getLayoutDirection(); } static Drawable[] wk_(TextView textView) { return textView.getCompoundDrawablesRelative(); } static void b(View view, int i) { view.setTextDirection(i); } static Locale wl_(TextView textView) { return textView.getTextLocale(); } static int b(View view) { return view.getTextDirection(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class LWm { static int wj_(TextView textView) { return textView.getMaxLines(); } static boolean wi_(TextView textView) { return textView.getIncludeFontPadding(); } } /* loaded from: classes.dex */ static class HBt { static void wv_(TextView textView, int i) { textView.setAutoSizeTextTypeWithDefaults(i); } static void wu_(TextView textView, int i, int i2, int i3, int i4) { textView.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class ZqN { static void wy_(TextView textView, int i) { textView.setFirstBaselineToTopHeight(i); } static PrecomputedText.Params wx_(TextView textView) { return textView.getTextMetricsParams(); } static String[] ww_(DecimalFormatSymbols decimalFormatSymbols) { return decimalFormatSymbols.getDigitStrings(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class IeS { static int wn_(TextView textView) { return textView.getBreakStrategy(); } static void wp_(TextView textView, int i) { textView.setBreakStrategy(i); } static int wo_(TextView textView) { return textView.getHyphenationFrequency(); } static void ws_(TextView textView, int i) { textView.setHyphenationFrequency(i); } static void wq_(TextView textView, ColorStateList colorStateList) { textView.setCompoundDrawableTintList(colorStateList); } static void wr_(TextView textView, PorterDuff.Mode mode) { textView.setCompoundDrawableTintMode(mode); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class RVV { static DecimalFormatSymbols wt_(Locale locale) { return DecimalFormatSymbols.getInstance(locale); } } }