content: package androidx.core.widget;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  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.util.Log;
  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 androidx.core.util.Preconditions;
  import java.lang.annotation.Retention;
  import java.lang.annotation.RetentionPolicy;
  import java.lang.reflect.Field;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Locale;
  
  public final class TextViewCompat {
      public static final int AUTO_SIZE_TEXT_TYPE_NONE = 0;
      public static final int AUTO_SIZE_TEXT_TYPE_UNIFORM = 1;
      private static final int LINES = 1;
      private static final String LOG_TAG = "TextViewCompat";
      private static Field sMaxModeField;
      private static boolean sMaxModeFieldFetched;
      private static Field sMaximumField;
      private static boolean sMaximumFieldFetched;
      private static Field sMinModeField;
      private static boolean sMinModeFieldFetched;
      private static Field sMinimumField;
      private static boolean sMinimumFieldFetched;
  
      static class Api16Impl {
          private Api16Impl() {
          }
  
          static boolean getIncludeFontPadding(TextView textView) {
              return textView.getIncludeFontPadding();
          }
  
          static int getMaxLines(TextView textView) {
              return textView.getMaxLines();
          }
  
          static int getMinLines(TextView textView) {
              return textView.getMinLines();
          }
      }
  
      static class Api17Impl {
          private Api17Impl() {
          }
  
          static Drawable[] getCompoundDrawablesRelative(TextView textView) {
              return textView.getCompoundDrawablesRelative();
          }
  
          static int getLayoutDirection(View view) {
              return view.getLayoutDirection();
          }
  
          static int getTextDirection(View view) {
              return view.getTextDirection();
          }
  
          static Locale getTextLocale(TextView textView) {
              return textView.getTextLocale();
          }
  
          static void setCompoundDrawablesRelative(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom) {
              textView.setCompoundDrawablesRelative(start, top, end, bottom);
          }
  
          static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, int start, int top, int end, int bottom) {
              textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
          }
  
          static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom) {
              textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
          }
  
          static void setTextDirection(View view, int textDirection) {
              view.setTextDirection(textDirection);
          }
      }
  
      static class Api23Impl {
          private Api23Impl() {
          }
  
          static int getBreakStrategy(TextView textView) {
              return textView.getBreakStrategy();
          }
  
          static ColorStateList getCompoundDrawableTintList(TextView textView) {
              return textView.getCompoundDrawableTintList();
          }
  
          static PorterDuff.Mode getCompoundDrawableTintMode(TextView textView) {
              return textView.getCompoundDrawableTintMode();
          }
  
          static int getHyphenationFrequency(TextView textView) {
              return textView.getHyphenationFrequency();
          }
  
          static void setBreakStrategy(TextView textView, int breakStrategy) {
              textView.setBreakStrategy(breakStrategy);
          }
  
          static void setCompoundDrawableTintList(TextView textView, ColorStateList tint) {
              textView.setCompoundDrawableTintList(tint);
          }
  
          static void setCompoundDrawableTintMode(TextView textView, PorterDuff.Mode tintMode) {
              textView.setCompoundDrawableTintMode(tintMode);
          }
  
          static void setHyphenationFrequency(TextView textView, int hyphenationFrequency) {
              textView.setHyphenationFrequency(hyphenationFrequency);
          }
      }
  
      static class Api24Impl {
          private Api24Impl() {
          }
  
          static DecimalFormatSymbols getInstance(Locale locale) {
              return DecimalFormatSymbols.getInstance(locale);
          }
      }
  
      static class Api26Impl {
          private Api26Impl() {
          }
  
          static int getAutoSizeMaxTextSize(TextView textView) {
              return textView.getAutoSizeMaxTextSize();
          }
  
          static int getAutoSizeMinTextSize(TextView textView) {
              return textView.getAutoSizeMinTextSize();
          }
  
          static int getAutoSizeStepGranularity(TextView textView) {
              return textView.getAutoSizeStepGranularity();
          }
  
          static int[] getAutoSizeTextAvailableSizes(TextView textView) {
              return textView.getAutoSizeTextAvailableSizes();
          }
  
          static int getAutoSizeTextType(TextView textView) {
              return textView.getAutoSizeTextType();
          }
  
          static void setAutoSizeTextTypeUniformWithConfiguration(TextView textView, int autoSizeMinTextSize, int autoSizeMaxTextSize, int autoSizeStepGranularity, int unit) {
              textView.setAutoSizeTextTypeUniformWithConfiguration(autoSizeMinTextSize, autoSizeMaxTextSize, autoSizeStepGranularity, unit);
          }
  
          static void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, int[] presetSizes, int unit) {
              textView.setAutoSizeTextTypeUniformWithPresetSizes(presetSizes, unit);
          }
  
          static void setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType) {
              textView.setAutoSizeTextTypeWithDefaults(autoSizeTextType);
          }
      }
  
      static class Api28Impl {
          private Api28Impl() {
          }
  
          static String[] getDigitStrings(DecimalFormatSymbols decimalFormatSymbols) {
              return decimalFormatSymbols.getDigitStrings();
          }
  
          static PrecomputedText.Params getTextMetricsParams(TextView textView) {
              return textView.getTextMetricsParams();
          }
  
          static void setFirstBaselineToTopHeight(TextView textView, int firstBaselineToTopHeight) {
              textView.setFirstBaselineToTopHeight(firstBaselineToTopHeight);
          }
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface AutoSizeTextType {
      }
  
      private static class OreoCallback implements ActionMode.Callback {
          private static final int MENU_ITEM_ORDER_PROCESS_TEXT_INTENT_ACTIONS_START = 100;
          private final ActionMode.Callback mCallback;
          private boolean mCanUseMenuBuilderReferences;
          private boolean mInitializedMenuBuilderReferences = false;
          private Class<?> mMenuBuilderClass;
          private Method mMenuBuilderRemoveItemAtMethod;
          private final TextView mTextView;
  
          OreoCallback(ActionMode.Callback callback, TextView textView) {
              this.mCallback = callback;
              this.mTextView = textView;
          }
  
          private Intent createProcessTextIntent() {
              return new Intent().setAction("android.intent.action.PROCESS_TEXT").setType("text/plain");
          }
  
          private Intent createProcessTextIntentForResolveInfo(ResolveInfo info, TextView textView11) {
              return createProcessTextIntent().putExtra("android.intent.extra.PROCESS_TEXT_READONLY", !isEditable(textView11)).setClassName(info.activityInfo.packageName, info.activityInfo.name);
          }
  
          private List<ResolveInfo> getSupportedActivities(Context context, PackageManager packageManager) {
              ArrayList arrayList = new ArrayList();
              if (!(context instanceof Activity)) {
                  return arrayList;
              }
              for (ResolveInfo next : packageManager.queryIntentActivities(createProcessTextIntent(), 0)) {
                  if (isSupportedActivity(next, context)) {
                      arrayList.add(next);
                  }
              }
              return arrayList;
          }
  
          private boolean isEditable(TextView textView11) {
              return (textView11 instanceof Editable) && textView11.onCheckIsTextEditor() && textView11.isEnabled();
          }
  
          private boolean isSupportedActivity(ResolveInfo info, Context context) {
              if (context.getPackageName().equals(info.activityInfo.packageName)) {
                  return true;
              }
              if (!info.activityInfo.exported) {
                  return false;
              }
              return info.activityInfo.permission == null || context.checkSelfPermission(info.activityInfo.permission) == 0;
          }
  
          private void recomputeProcessTextMenuItems(Menu menu) {
              Method method;
              Context context = this.mTextView.getContext();
              PackageManager packageManager = context.getPackageManager();
              if (!this.mInitializedMenuBuilderReferences) {
                  this.mInitializedMenuBuilderReferences = true;
                  try {
                      Class<?> cls = Class.forName("com.android.internal.view.menu.MenuBuilder");
                      this.mMenuBuilderClass = cls;
                      this.mMenuBuilderRemoveItemAtMethod = cls.getDeclaredMethod("removeItemAt", new Class[]{Integer.TYPE});
                      this.mCanUseMenuBuilderReferences = true;
                  } catch (ClassNotFoundException | NoSuchMethodException e) {
                      this.mMenuBuilderClass = null;
                      this.mMenuBuilderRemoveItemAtMethod = null;
                      this.mCanUseMenuBuilderReferences = false;
                  }
              }
              try {
                  if (!this.mCanUseMenuBuilderReferences || !this.mMenuBuilderClass.isInstance(menu)) {
                      method = menu.getClass().getDeclaredMethod("removeItemAt", new Class[]{Integer.TYPE});
                  } else {
                      method = this.mMenuBuilderRemoveItemAtMethod;
                  }
                  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())) {
                          method.invoke(menu, new Object[]{Integer.valueOf(size)});
                      }
                  }
                  List<ResolveInfo> supportedActivities = getSupportedActivities(context, packageManager);
                  for (int i = 0; i < supportedActivities.size(); i++) {
                      ResolveInfo resolveInfo = supportedActivities.get(i);
                      menu.add(0, 0, i + 100, resolveInfo.loadLabel(packageManager)).setIntent(createProcessTextIntentForResolveInfo(resolveInfo, this.mTextView)).setShowAsAction(1);
                  }
              } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e2) {
              }
          }
  
          /* access modifiers changed from: package-private */
          public ActionMode.Callback getWrappedCallback() {
              return this.mCallback;
          }
  
          public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
              return this.mCallback.onActionItemClicked(mode, item);
          }
  
          public boolean onCreateActionMode(ActionMode mode, Menu menu) {
              return this.mCallback.onCreateActionMode(mode, menu);
          }
  
          public void onDestroyActionMode(ActionMode mode) {
              this.mCallback.onDestroyActionMode(mode);
          }
  
          public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
              recomputeProcessTextMenuItems(menu);
              return this.mCallback.onPrepareActionMode(mode, menu);
          }
      }
  
      private TextViewCompat() {
      }
  
      public static int getAutoSizeMaxTextSize(TextView textView) {
          if (Build.VERSION.SDK_INT >= 27) {
              return Api26Impl.getAutoSizeMaxTextSize(textView);
          }
          if (textView instanceof AutoSizeableTextView) {
              return ((AutoSizeableTextView) textView).getAutoSizeMaxTextSize();
          }
          return -1;
      }
  
      public static int getAutoSizeMinTextSize(TextView textView) {
          if (Build.VERSION.SDK_INT >= 27) {
              return Api26Impl.getAutoSizeMinTextSize(textView);
          }
          if (textView instanceof AutoSizeableTextView) {
              return ((AutoSizeableTextView) textView).getAutoSizeMinTextSize();
          }
          return -1;
      }
  
      public static int getAutoSizeStepGranularity(TextView textView) {
          if (Build.VERSION.SDK_INT >= 27) {
              return Api26Impl.getAutoSizeStepGranularity(textView);
          }
          if (textView instanceof AutoSizeableTextView) {
              return ((AutoSizeableTextView) textView).getAutoSizeStepGranularity();
          }
          return -1;
      }
  
      public static int[] getAutoSizeTextAvailableSizes(TextView textView) {
          return Build.VERSION.SDK_INT >= 27 ? Api26Impl.getAutoSizeTextAvailableSizes(textView) : textView instanceof AutoSizeableTextView ? ((AutoSizeableTextView) textView).getAutoSizeTextAvailableSizes() : new int[0];
      }
  
      public static int getAutoSizeTextType(TextView textView) {
          if (Build.VERSION.SDK_INT >= 27) {
              return Api26Impl.getAutoSizeTextType(textView);
          }
          if (textView instanceof AutoSizeableTextView) {
              return ((AutoSizeableTextView) textView).getAutoSizeTextType();
          }
          return 0;
      }
  
      public static ColorStateList getCompoundDrawableTintList(TextView textView) {
          Preconditions.checkNotNull(textView);
          if (Build.VERSION.SDK_INT >= 24) {
              return Api23Impl.getCompoundDrawableTintList(textView);
          }
          if (textView instanceof TintableCompoundDrawablesView) {
              return ((TintableCompoundDrawablesView) textView).getSupportCompoundDrawablesTintList();
          }
          return null;
      }
  
      public static PorterDuff.Mode getCompoundDrawableTintMode(TextView textView) {
          Preconditions.checkNotNull(textView);
          if (Build.VERSION.SDK_INT >= 24) {
              return Api23Impl.getCompoundDrawableTintMode(textView);
          }
          if (textView instanceof TintableCompoundDrawablesView) {
              return ((TintableCompoundDrawablesView) textView).getSupportCompoundDrawablesTintMode();
          }
          return null;
      }
  
      public static Drawable[] getCompoundDrawablesRelative(TextView textView) {
          if (Build.VERSION.SDK_INT >= 18) {
              return Api17Impl.getCompoundDrawablesRelative(textView);
          }
          if (Build.VERSION.SDK_INT < 17) {
              return textView.getCompoundDrawables();
          }
          boolean z = true;
          if (Api17Impl.getLayoutDirection(textView) != 1) {
              z = false;
          }
          boolean z2 = z;
          Drawable[] compoundDrawables = textView.getCompoundDrawables();
          if (z2) {
              Drawable drawable = compoundDrawables[2];
              Drawable drawable2 = compoundDrawables[0];
              compoundDrawables[0] = drawable;
              compoundDrawables[2] = drawable2;
          }
          return compoundDrawables;
      }
  
      public static int getFirstBaselineToTopHeight(TextView textView) {
          return textView.getPaddingTop() - textView.getPaint().getFontMetricsInt().top;
      }
  
      public static int getLastBaselineToBottomHeight(TextView textView) {
          return textView.getPaddingBottom() + textView.getPaint().getFontMetricsInt().bottom;
      }
  
      public static int getMaxLines(TextView textView) {
          if (Build.VERSION.SDK_INT >= 16) {
              return Api16Impl.getMaxLines(textView);
          }
          if (!sMaxModeFieldFetched) {
              sMaxModeField = retrieveField("mMaxMode");
              sMaxModeFieldFetched = true;
          }
          Field field = sMaxModeField;
          if (field == null || retrieveIntFromField(field, textView) != 1) {
              return -1;
          }
          if (!sMaximumFieldFetched) {
              sMaximumField = retrieveField("mMaximum");
              sMaximumFieldFetched = true;
          }
          Field field2 = sMaximumField;
          if (field2 != null) {
              return retrieveIntFromField(field2, textView);
          }
          return -1;
      }
  
      public static int getMinLines(TextView textView) {
          if (Build.VERSION.SDK_INT >= 16) {
              return Api16Impl.getMinLines(textView);
          }
          if (!sMinModeFieldFetched) {
              sMinModeField = retrieveField("mMinMode");
              sMinModeFieldFetched = true;
          }
          Field field = sMinModeField;
          if (field == null || retrieveIntFromField(field, textView) != 1) {
              return -1;
          }
          if (!sMinimumFieldFetched) {
              sMinimumField = retrieveField("mMinimum");
              sMinimumFieldFetched = true;
          }
          Field field2 = sMinimumField;
          if (field2 != null) {
              return retrieveIntFromField(field2, textView);
          }
          return -1;
      }
  
      private static int getTextDirection(TextDirectionHeuristic heuristic) {
          if (heuristic == TextDirectionHeuristics.FIRSTSTRONG_RTL || heuristic == TextDirectionHeuristics.FIRSTSTRONG_LTR) {
              return 1;
          }
          if (heuristic == TextDirectionHeuristics.ANYRTL_LTR) {
              return 2;
          }
          if (heuristic == TextDirectionHeuristics.LTR) {
              return 3;
          }
          if (heuristic == TextDirectionHeuristics.RTL) {
              return 4;
          }
          if (heuristic == TextDirectionHeuristics.LOCALE) {
              return 5;
          }
          if (heuristic == TextDirectionHeuristics.FIRSTSTRONG_LTR) {
              return 6;
          }
          return heuristic == TextDirectionHeuristics.FIRSTSTRONG_RTL ? 7 : 1;
      }
  
      private static TextDirectionHeuristic getTextDirectionHeuristic(TextView textView) {
          if (textView.getTransformationMethod() instanceof PasswordTransformationMethod) {
              return TextDirectionHeuristics.LTR;
          }
          boolean z = false;
          if (Build.VERSION.SDK_INT < 28 || (textView.getInputType() & 15) != 3) {
              if (Api17Impl.getLayoutDirection(textView) == 1) {
                  z = true;
              }
              boolean z2 = z;
              switch (Api17Impl.getTextDirection(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:
                      return z2 ? TextDirectionHeuristics.FIRSTSTRONG_RTL : TextDirectionHeuristics.FIRSTSTRONG_LTR;
              }
          } else {
              byte directionality = Character.getDirectionality(Api28Impl.getDigitStrings(Api24Impl.getInstance(Api17Impl.getTextLocale(textView)))[0].codePointAt(0));
              return (directionality == 1 || directionality == 2) ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR;
          }
      }
  
      public static PrecomputedTextCompat.Params getTextMetricsParams(TextView textView) {
          if (Build.VERSION.SDK_INT >= 28) {
              return new PrecomputedTextCompat.Params(Api28Impl.getTextMetricsParams(textView));
          }
          PrecomputedTextCompat.Params.Builder builder = new PrecomputedTextCompat.Params.Builder(new TextPaint(textView.getPaint()));
          if (Build.VERSION.SDK_INT >= 23) {
              builder.setBreakStrategy(Api23Impl.getBreakStrategy(textView));
              builder.setHyphenationFrequency(Api23Impl.getHyphenationFrequency(textView));
          }
          if (Build.VERSION.SDK_INT >= 18) {
              builder.setTextDirection(getTextDirectionHeuristic(textView));
          }
          return builder.build();
      }
  
      private static Field retrieveField(String fieldName) {
          Field field = null;
          try {
              field = TextView.class.getDeclaredField(fieldName);
              field.setAccessible(true);
              return field;
          } catch (NoSuchFieldException e) {
              Log.e(LOG_TAG, "Could not retrieve " + fieldName + " field.");
              return field;
          }
      }
  
      private static int retrieveIntFromField(Field field, TextView textView) {
          try {
              return field.getInt(textView);
          } catch (IllegalAccessException e) {
              Log.d(LOG_TAG, "Could not retrieve value of " + field.getName() + " field.");
              return -1;
          }
      }
  
      public static void setAutoSizeTextTypeUniformWithConfiguration(TextView textView, int autoSizeMinTextSize, int autoSizeMaxTextSize, int autoSizeStepGranularity, int unit) throws IllegalArgumentException {
          if (Build.VERSION.SDK_INT >= 27) {
              Api26Impl.setAutoSizeTextTypeUniformWithConfiguration(textView, autoSizeMinTextSize, autoSizeMaxTextSize, autoSizeStepGranularity, unit);
          } else if (textView instanceof AutoSizeableTextView) {
              ((AutoSizeableTextView) textView).setAutoSizeTextTypeUniformWithConfiguration(autoSizeMinTextSize, autoSizeMaxTextSize, autoSizeStepGranularity, unit);
          }
      }
  
      public static void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, int[] presetSizes, int unit) throws IllegalArgumentException {
          if (Build.VERSION.SDK_INT >= 27) {
              Api26Impl.setAutoSizeTextTypeUniformWithPresetSizes(textView, presetSizes, unit);
          } else if (textView instanceof AutoSizeableTextView) {
              ((AutoSizeableTextView) textView).setAutoSizeTextTypeUniformWithPresetSizes(presetSizes, unit);
          }
      }
  
      public static void setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType) {
          if (Build.VERSION.SDK_INT >= 27) {
              Api26Impl.setAutoSizeTextTypeWithDefaults(textView, autoSizeTextType);
          } else if (textView instanceof AutoSizeableTextView) {
              ((AutoSizeableTextView) textView).setAutoSizeTextTypeWithDefaults(autoSizeTextType);
          }
      }
  
      public static void setCompoundDrawableTintList(TextView textView, ColorStateList tint) {
          Preconditions.checkNotNull(textView);
          if (Build.VERSION.SDK_INT >= 24) {
              Api23Impl.setCompoundDrawableTintList(textView, tint);
          } else if (textView instanceof TintableCompoundDrawablesView) {
              ((TintableCompoundDrawablesView) textView).setSupportCompoundDrawablesTintList(tint);
          }
      }
  
      public static void setCompoundDrawableTintMode(TextView textView, PorterDuff.Mode tintMode) {
          Preconditions.checkNotNull(textView);
          if (Build.VERSION.SDK_INT >= 24) {
              Api23Impl.setCompoundDrawableTintMode(textView, tintMode);
          } else if (textView instanceof TintableCompoundDrawablesView) {
              ((TintableCompoundDrawablesView) textView).setSupportCompoundDrawablesTintMode(tintMode);
          }
      }
  
      public static void setCompoundDrawablesRelative(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom) {
          if (Build.VERSION.SDK_INT >= 18) {
              Api17Impl.setCompoundDrawablesRelative(textView, start, top, end, bottom);
          } else if (Build.VERSION.SDK_INT >= 17) {
              boolean z = true;
              if (Api17Impl.getLayoutDirection(textView) != 1) {
                  z = false;
              }
              boolean z2 = z;
              textView.setCompoundDrawables(z2 ? end : start, top, z2 ? start : end, bottom);
          } else {
              textView.setCompoundDrawables(start, top, end, bottom);
          }
      }
  
      public static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, int start, int top, int end, int bottom) {
          if (Build.VERSION.SDK_INT >= 18) {
              Api17Impl.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, start, top, end, bottom);
          } else if (Build.VERSION.SDK_INT >= 17) {
              boolean z = true;
              if (Api17Impl.getLayoutDirection(textView) != 1) {
                  z = false;
              }
              boolean z2 = z;
              textView.setCompoundDrawablesWithIntrinsicBounds(z2 ? end : start, top, z2 ? start : end, bottom);
          } else {
              textView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom);
          }
      }
  
      public static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, Drawable start, Drawable top, Drawable end, Drawable bottom) {
          if (Build.VERSION.SDK_INT >= 18) {
              Api17Impl.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, start, top, end, bottom);
          } else if (Build.VERSION.SDK_INT >= 17) {
              boolean z = true;
              if (Api17Impl.getLayoutDirection(textView) != 1) {
                  z = false;
              }
              boolean z2 = z;
              textView.setCompoundDrawablesWithIntrinsicBounds(z2 ? end : start, top, z2 ? start : end, bottom);
          } else {
              textView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom);
          }
      }
  
      public static void setCustomSelectionActionModeCallback(TextView textView, ActionMode.Callback callback) {
          textView.setCustomSelectionActionModeCallback(wrapCustomSelectionActionModeCallback(textView, callback));
      }
  
      public static void setFirstBaselineToTopHeight(TextView textView, int firstBaselineToTopHeight) {
          Preconditions.checkArgumentNonnegative(firstBaselineToTopHeight);
          if (Build.VERSION.SDK_INT >= 28) {
              Api28Impl.setFirstBaselineToTopHeight(textView, firstBaselineToTopHeight);
              return;
          }
          Paint.FontMetricsInt fontMetricsInt = textView.getPaint().getFontMetricsInt();
          int i = (Build.VERSION.SDK_INT < 16 || Api16Impl.getIncludeFontPadding(textView)) ? fontMetricsInt.top : fontMetricsInt.ascent;
          if (firstBaselineToTopHeight > Math.abs(i)) {
              textView.setPadding(textView.getPaddingLeft(), firstBaselineToTopHeight + i, textView.getPaddingRight(), textView.getPaddingBottom());
          }
      }
  
      public static void setLastBaselineToBottomHeight(TextView textView, int lastBaselineToBottomHeight) {
          Preconditions.checkArgumentNonnegative(lastBaselineToBottomHeight);
          Paint.FontMetricsInt fontMetricsInt = textView.getPaint().getFontMetricsInt();
          int i = (Build.VERSION.SDK_INT < 16 || Api16Impl.getIncludeFontPadding(textView)) ? fontMetricsInt.bottom : fontMetricsInt.descent;
          if (lastBaselineToBottomHeight > Math.abs(i)) {
              textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), lastBaselineToBottomHeight - i);
          }
      }
  
      public static void setLineHeight(TextView textView, int lineHeight) {
          Preconditions.checkArgumentNonnegative(lineHeight);
          int fontMetricsInt = textView.getPaint().getFontMetricsInt((Paint.FontMetricsInt) null);
          if (lineHeight != fontMetricsInt) {
              textView.setLineSpacing((float) (lineHeight - fontMetricsInt), 1.0f);
          }
      }
  
      public static void setPrecomputedText(TextView textView, PrecomputedTextCompat precomputed) {
          if (Build.VERSION.SDK_INT >= 29) {
              textView.setText(precomputed.getPrecomputedText());
          } else if (getTextMetricsParams(textView).equalsWithoutTextDirection(precomputed.getParams())) {
              textView.setText(precomputed);
          } else {
              throw new IllegalArgumentException("Given text can not be applied to TextView.");
          }
      }
  
      public static void setTextAppearance(TextView textView, int resId) {
          if (Build.VERSION.SDK_INT >= 23) {
              textView.setTextAppearance(resId);
          } else {
              textView.setTextAppearance(textView.getContext(), resId);
          }
      }
  
      public static void setTextMetricsParams(TextView textView, PrecomputedTextCompat.Params params) {
          if (Build.VERSION.SDK_INT >= 18) {
              Api17Impl.setTextDirection(textView, getTextDirection(params.getTextDirection()));
          }
          if (Build.VERSION.SDK_INT < 23) {
              float textScaleX = params.getTextPaint().getTextScaleX();
              textView.getPaint().set(params.getTextPaint());
              if (textScaleX == textView.getTextScaleX()) {
                  textView.setTextScaleX((textScaleX / 2.0f) + 1.0f);
              }
              textView.setTextScaleX(textScaleX);
              return;
          }
          textView.getPaint().set(params.getTextPaint());
          Api23Impl.setBreakStrategy(textView, params.getBreakStrategy());
          Api23Impl.setHyphenationFrequency(textView, params.getHyphenationFrequency());
      }
  
      public static ActionMode.Callback unwrapCustomSelectionActionModeCallback(ActionMode.Callback callback) {
          return (!(callback instanceof OreoCallback) || Build.VERSION.SDK_INT < 26) ? callback : ((OreoCallback) callback).getWrappedCallback();
      }
  
      public static ActionMode.Callback wrapCustomSelectionActionModeCallback(TextView textView, ActionMode.Callback callback) {
          return (Build.VERSION.SDK_INT < 26 || Build.VERSION.SDK_INT > 27 || (callback instanceof OreoCallback) || callback == null) ? callback : new OreoCallback(callback, textView);
      }
  }
  