ADD week 5
This commit is contained in:
		| @@ -0,0 +1,626 @@ | ||||
| package androidx.appcompat.widget; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.content.res.Resources; | ||||
| import android.graphics.PorterDuff; | ||||
| import android.graphics.Typeface; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Build; | ||||
| import android.os.LocaleList; | ||||
| import android.text.method.PasswordTransformationMethod; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.inputmethod.EditorInfo; | ||||
| import android.view.inputmethod.InputConnection; | ||||
| import android.widget.TextView; | ||||
| import androidx.appcompat.R; | ||||
| import androidx.core.content.res.ResourcesCompat; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import androidx.core.view.inputmethod.EditorInfoCompat; | ||||
| import androidx.core.widget.TextViewCompat; | ||||
| import java.lang.ref.WeakReference; | ||||
| import java.util.Locale; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class AppCompatTextHelper { | ||||
|     private static final int MONOSPACE = 3; | ||||
|     private static final int SANS = 1; | ||||
|     private static final int SERIF = 2; | ||||
|     private static final int TEXT_FONT_WEIGHT_UNSPECIFIED = -1; | ||||
|     private boolean mAsyncFontPending; | ||||
|     private final AppCompatTextViewAutoSizeHelper mAutoSizeTextHelper; | ||||
|     private TintInfo mDrawableBottomTint; | ||||
|     private TintInfo mDrawableEndTint; | ||||
|     private TintInfo mDrawableLeftTint; | ||||
|     private TintInfo mDrawableRightTint; | ||||
|     private TintInfo mDrawableStartTint; | ||||
|     private TintInfo mDrawableTint; | ||||
|     private TintInfo mDrawableTopTint; | ||||
|     private Typeface mFontTypeface; | ||||
|     private final TextView mView; | ||||
|     private int mStyle = 0; | ||||
|     private int mFontWeight = -1; | ||||
|  | ||||
|     private void setCompoundTints() { | ||||
|         TintInfo tintInfo = this.mDrawableTint; | ||||
|         this.mDrawableLeftTint = tintInfo; | ||||
|         this.mDrawableTopTint = tintInfo; | ||||
|         this.mDrawableRightTint = tintInfo; | ||||
|         this.mDrawableBottomTint = tintInfo; | ||||
|         this.mDrawableStartTint = tintInfo; | ||||
|         this.mDrawableEndTint = tintInfo; | ||||
|     } | ||||
|  | ||||
|     AppCompatTextHelper(TextView textView) { | ||||
|         this.mView = textView; | ||||
|         this.mAutoSizeTextHelper = new AppCompatTextViewAutoSizeHelper(textView); | ||||
|     } | ||||
|  | ||||
|     void loadFromAttributes(AttributeSet attributeSet, int i) { | ||||
|         ColorStateList colorStateList; | ||||
|         String str; | ||||
|         boolean z; | ||||
|         boolean z2; | ||||
|         ColorStateList colorStateList2; | ||||
|         String str2; | ||||
|         ColorStateList colorStateList3; | ||||
|         boolean z3; | ||||
|         int i2; | ||||
|         Context context = this.mView.getContext(); | ||||
|         AppCompatDrawableManager appCompatDrawableManager = AppCompatDrawableManager.get(); | ||||
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, R.styleable.AppCompatTextHelper, i, 0); | ||||
|         TextView textView = this.mView; | ||||
|         ViewCompat.saveAttributeDataForStyleable(textView, textView.getContext(), R.styleable.AppCompatTextHelper, attributeSet, obtainStyledAttributes.getWrappedTypeArray(), i, 0); | ||||
|         int resourceId = obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_textAppearance, -1); | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.AppCompatTextHelper_android_drawableLeft)) { | ||||
|             this.mDrawableLeftTint = createTintInfo(context, appCompatDrawableManager, obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_drawableLeft, 0)); | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.AppCompatTextHelper_android_drawableTop)) { | ||||
|             this.mDrawableTopTint = createTintInfo(context, appCompatDrawableManager, obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_drawableTop, 0)); | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.AppCompatTextHelper_android_drawableRight)) { | ||||
|             this.mDrawableRightTint = createTintInfo(context, appCompatDrawableManager, obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_drawableRight, 0)); | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.AppCompatTextHelper_android_drawableBottom)) { | ||||
|             this.mDrawableBottomTint = createTintInfo(context, appCompatDrawableManager, obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_drawableBottom, 0)); | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.AppCompatTextHelper_android_drawableStart)) { | ||||
|             this.mDrawableStartTint = createTintInfo(context, appCompatDrawableManager, obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_drawableStart, 0)); | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.AppCompatTextHelper_android_drawableEnd)) { | ||||
|             this.mDrawableEndTint = createTintInfo(context, appCompatDrawableManager, obtainStyledAttributes.getResourceId(R.styleable.AppCompatTextHelper_android_drawableEnd, 0)); | ||||
|         } | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         boolean z4 = this.mView.getTransformationMethod() instanceof PasswordTransformationMethod; | ||||
|         if (resourceId != -1) { | ||||
|             TintTypedArray obtainStyledAttributes2 = TintTypedArray.obtainStyledAttributes(context, resourceId, R.styleable.TextAppearance); | ||||
|             if (z4 || !obtainStyledAttributes2.hasValue(R.styleable.TextAppearance_textAllCaps)) { | ||||
|                 z = false; | ||||
|                 z2 = false; | ||||
|             } else { | ||||
|                 z = obtainStyledAttributes2.getBoolean(R.styleable.TextAppearance_textAllCaps, false); | ||||
|                 z2 = true; | ||||
|             } | ||||
|             updateTypefaceAndStyle(context, obtainStyledAttributes2); | ||||
|             if (Build.VERSION.SDK_INT < 23) { | ||||
|                 colorStateList3 = obtainStyledAttributes2.hasValue(R.styleable.TextAppearance_android_textColor) ? obtainStyledAttributes2.getColorStateList(R.styleable.TextAppearance_android_textColor) : null; | ||||
|                 colorStateList = obtainStyledAttributes2.hasValue(R.styleable.TextAppearance_android_textColorHint) ? obtainStyledAttributes2.getColorStateList(R.styleable.TextAppearance_android_textColorHint) : null; | ||||
|                 colorStateList2 = obtainStyledAttributes2.hasValue(R.styleable.TextAppearance_android_textColorLink) ? obtainStyledAttributes2.getColorStateList(R.styleable.TextAppearance_android_textColorLink) : null; | ||||
|             } else { | ||||
|                 colorStateList = null; | ||||
|                 colorStateList2 = null; | ||||
|                 colorStateList3 = null; | ||||
|             } | ||||
|             str2 = obtainStyledAttributes2.hasValue(R.styleable.TextAppearance_textLocale) ? obtainStyledAttributes2.getString(R.styleable.TextAppearance_textLocale) : null; | ||||
|             str = (Build.VERSION.SDK_INT < 26 || !obtainStyledAttributes2.hasValue(R.styleable.TextAppearance_fontVariationSettings)) ? null : obtainStyledAttributes2.getString(R.styleable.TextAppearance_fontVariationSettings); | ||||
|             obtainStyledAttributes2.recycle(); | ||||
|         } else { | ||||
|             colorStateList = null; | ||||
|             str = null; | ||||
|             z = false; | ||||
|             z2 = false; | ||||
|             colorStateList2 = null; | ||||
|             str2 = null; | ||||
|             colorStateList3 = null; | ||||
|         } | ||||
|         TintTypedArray obtainStyledAttributes3 = TintTypedArray.obtainStyledAttributes(context, attributeSet, R.styleable.TextAppearance, i, 0); | ||||
|         if (z4 || !obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_textAllCaps)) { | ||||
|             z3 = z2; | ||||
|         } else { | ||||
|             z = obtainStyledAttributes3.getBoolean(R.styleable.TextAppearance_textAllCaps, false); | ||||
|             z3 = true; | ||||
|         } | ||||
|         if (Build.VERSION.SDK_INT < 23) { | ||||
|             if (obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_android_textColor)) { | ||||
|                 colorStateList3 = obtainStyledAttributes3.getColorStateList(R.styleable.TextAppearance_android_textColor); | ||||
|             } | ||||
|             if (obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_android_textColorHint)) { | ||||
|                 colorStateList = obtainStyledAttributes3.getColorStateList(R.styleable.TextAppearance_android_textColorHint); | ||||
|             } | ||||
|             if (obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_android_textColorLink)) { | ||||
|                 colorStateList2 = obtainStyledAttributes3.getColorStateList(R.styleable.TextAppearance_android_textColorLink); | ||||
|             } | ||||
|         } | ||||
|         if (obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_textLocale)) { | ||||
|             str2 = obtainStyledAttributes3.getString(R.styleable.TextAppearance_textLocale); | ||||
|         } | ||||
|         if (Build.VERSION.SDK_INT >= 26 && obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_fontVariationSettings)) { | ||||
|             str = obtainStyledAttributes3.getString(R.styleable.TextAppearance_fontVariationSettings); | ||||
|         } | ||||
|         if (Build.VERSION.SDK_INT >= 28 && obtainStyledAttributes3.hasValue(R.styleable.TextAppearance_android_textSize) && obtainStyledAttributes3.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, -1) == 0) { | ||||
|             this.mView.setTextSize(0, 0.0f); | ||||
|         } | ||||
|         updateTypefaceAndStyle(context, obtainStyledAttributes3); | ||||
|         obtainStyledAttributes3.recycle(); | ||||
|         if (colorStateList3 != null) { | ||||
|             this.mView.setTextColor(colorStateList3); | ||||
|         } | ||||
|         if (colorStateList != null) { | ||||
|             this.mView.setHintTextColor(colorStateList); | ||||
|         } | ||||
|         if (colorStateList2 != null) { | ||||
|             this.mView.setLinkTextColor(colorStateList2); | ||||
|         } | ||||
|         if (!z4 && z3) { | ||||
|             setAllCaps(z); | ||||
|         } | ||||
|         Typeface typeface = this.mFontTypeface; | ||||
|         if (typeface != null) { | ||||
|             if (this.mFontWeight == -1) { | ||||
|                 this.mView.setTypeface(typeface, this.mStyle); | ||||
|             } else { | ||||
|                 this.mView.setTypeface(typeface); | ||||
|             } | ||||
|         } | ||||
|         if (str != null) { | ||||
|             Api26Impl.setFontVariationSettings(this.mView, str); | ||||
|         } | ||||
|         if (str2 != null) { | ||||
|             if (Build.VERSION.SDK_INT >= 24) { | ||||
|                 Api24Impl.setTextLocales(this.mView, Api24Impl.forLanguageTags(str2)); | ||||
|             } else { | ||||
|                 Api17Impl.setTextLocale(this.mView, Api21Impl.forLanguageTag(str2.split(",")[0])); | ||||
|             } | ||||
|         } | ||||
|         this.mAutoSizeTextHelper.loadFromAttributes(attributeSet, i); | ||||
|         if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE && this.mAutoSizeTextHelper.getAutoSizeTextType() != 0) { | ||||
|             int[] autoSizeTextAvailableSizes = this.mAutoSizeTextHelper.getAutoSizeTextAvailableSizes(); | ||||
|             if (autoSizeTextAvailableSizes.length > 0) { | ||||
|                 if (Api26Impl.getAutoSizeStepGranularity(this.mView) != -1.0f) { | ||||
|                     Api26Impl.setAutoSizeTextTypeUniformWithConfiguration(this.mView, this.mAutoSizeTextHelper.getAutoSizeMinTextSize(), this.mAutoSizeTextHelper.getAutoSizeMaxTextSize(), this.mAutoSizeTextHelper.getAutoSizeStepGranularity(), 0); | ||||
|                 } else { | ||||
|                     Api26Impl.setAutoSizeTextTypeUniformWithPresetSizes(this.mView, autoSizeTextAvailableSizes, 0); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         TintTypedArray obtainStyledAttributes4 = TintTypedArray.obtainStyledAttributes(context, attributeSet, R.styleable.AppCompatTextView); | ||||
|         int resourceId2 = obtainStyledAttributes4.getResourceId(R.styleable.AppCompatTextView_drawableLeftCompat, -1); | ||||
|         Drawable drawable = resourceId2 != -1 ? appCompatDrawableManager.getDrawable(context, resourceId2) : null; | ||||
|         int resourceId3 = obtainStyledAttributes4.getResourceId(R.styleable.AppCompatTextView_drawableTopCompat, -1); | ||||
|         Drawable drawable2 = resourceId3 != -1 ? appCompatDrawableManager.getDrawable(context, resourceId3) : null; | ||||
|         int resourceId4 = obtainStyledAttributes4.getResourceId(R.styleable.AppCompatTextView_drawableRightCompat, -1); | ||||
|         Drawable drawable3 = resourceId4 != -1 ? appCompatDrawableManager.getDrawable(context, resourceId4) : null; | ||||
|         int resourceId5 = obtainStyledAttributes4.getResourceId(R.styleable.AppCompatTextView_drawableBottomCompat, -1); | ||||
|         Drawable drawable4 = resourceId5 != -1 ? appCompatDrawableManager.getDrawable(context, resourceId5) : null; | ||||
|         int resourceId6 = obtainStyledAttributes4.getResourceId(R.styleable.AppCompatTextView_drawableStartCompat, -1); | ||||
|         Drawable drawable5 = resourceId6 != -1 ? appCompatDrawableManager.getDrawable(context, resourceId6) : null; | ||||
|         int resourceId7 = obtainStyledAttributes4.getResourceId(R.styleable.AppCompatTextView_drawableEndCompat, -1); | ||||
|         setCompoundDrawables(drawable, drawable2, drawable3, drawable4, drawable5, resourceId7 != -1 ? appCompatDrawableManager.getDrawable(context, resourceId7) : null); | ||||
|         if (obtainStyledAttributes4.hasValue(R.styleable.AppCompatTextView_drawableTint)) { | ||||
|             TextViewCompat.setCompoundDrawableTintList(this.mView, obtainStyledAttributes4.getColorStateList(R.styleable.AppCompatTextView_drawableTint)); | ||||
|         } | ||||
|         if (obtainStyledAttributes4.hasValue(R.styleable.AppCompatTextView_drawableTintMode)) { | ||||
|             i2 = -1; | ||||
|             TextViewCompat.setCompoundDrawableTintMode(this.mView, DrawableUtils.parseTintMode(obtainStyledAttributes4.getInt(R.styleable.AppCompatTextView_drawableTintMode, -1), null)); | ||||
|         } else { | ||||
|             i2 = -1; | ||||
|         } | ||||
|         int dimensionPixelSize = obtainStyledAttributes4.getDimensionPixelSize(R.styleable.AppCompatTextView_firstBaselineToTopHeight, i2); | ||||
|         int dimensionPixelSize2 = obtainStyledAttributes4.getDimensionPixelSize(R.styleable.AppCompatTextView_lastBaselineToBottomHeight, i2); | ||||
|         int dimensionPixelSize3 = obtainStyledAttributes4.getDimensionPixelSize(R.styleable.AppCompatTextView_lineHeight, i2); | ||||
|         obtainStyledAttributes4.recycle(); | ||||
|         if (dimensionPixelSize != i2) { | ||||
|             TextViewCompat.setFirstBaselineToTopHeight(this.mView, dimensionPixelSize); | ||||
|         } | ||||
|         if (dimensionPixelSize2 != i2) { | ||||
|             TextViewCompat.setLastBaselineToBottomHeight(this.mView, dimensionPixelSize2); | ||||
|         } | ||||
|         if (dimensionPixelSize3 != i2) { | ||||
|             TextViewCompat.setLineHeight(this.mView, dimensionPixelSize3); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void updateTypefaceAndStyle(Context context, TintTypedArray tintTypedArray) { | ||||
|         int i; | ||||
|         String string; | ||||
|         this.mStyle = tintTypedArray.getInt(R.styleable.TextAppearance_android_textStyle, this.mStyle); | ||||
|         if (Build.VERSION.SDK_INT >= 28) { | ||||
|             int i2 = tintTypedArray.getInt(R.styleable.TextAppearance_android_textFontWeight, -1); | ||||
|             this.mFontWeight = i2; | ||||
|             if (i2 != -1) { | ||||
|                 this.mStyle &= 2; | ||||
|             } | ||||
|         } | ||||
|         if (tintTypedArray.hasValue(R.styleable.TextAppearance_android_fontFamily) || tintTypedArray.hasValue(R.styleable.TextAppearance_fontFamily)) { | ||||
|             this.mFontTypeface = null; | ||||
|             if (tintTypedArray.hasValue(R.styleable.TextAppearance_fontFamily)) { | ||||
|                 i = R.styleable.TextAppearance_fontFamily; | ||||
|             } else { | ||||
|                 i = R.styleable.TextAppearance_android_fontFamily; | ||||
|             } | ||||
|             final int i3 = this.mFontWeight; | ||||
|             final int i4 = this.mStyle; | ||||
|             if (!context.isRestricted()) { | ||||
|                 final WeakReference weakReference = new WeakReference(this.mView); | ||||
|                 try { | ||||
|                     Typeface font = tintTypedArray.getFont(i, this.mStyle, new ResourcesCompat.FontCallback() { // from class: androidx.appcompat.widget.AppCompatTextHelper.1 | ||||
|                         @Override // androidx.core.content.res.ResourcesCompat.FontCallback | ||||
|                         /* renamed from: onFontRetrievalFailed */ | ||||
|                         public void m80xb24343b7(int i5) { | ||||
|                         } | ||||
|  | ||||
|                         @Override // androidx.core.content.res.ResourcesCompat.FontCallback | ||||
|                         /* renamed from: onFontRetrieved */ | ||||
|                         public void m81x46c88379(Typeface typeface) { | ||||
|                             int i5; | ||||
|                             if (Build.VERSION.SDK_INT >= 28 && (i5 = i3) != -1) { | ||||
|                                 typeface = Api28Impl.create(typeface, i5, (i4 & 2) != 0); | ||||
|                             } | ||||
|                             AppCompatTextHelper.this.onAsyncTypefaceReceived(weakReference, typeface); | ||||
|                         } | ||||
|                     }); | ||||
|                     if (font != null) { | ||||
|                         if (Build.VERSION.SDK_INT < 28 || this.mFontWeight == -1) { | ||||
|                             this.mFontTypeface = font; | ||||
|                         } else { | ||||
|                             this.mFontTypeface = Api28Impl.create(Typeface.create(font, 0), this.mFontWeight, (this.mStyle & 2) != 0); | ||||
|                         } | ||||
|                     } | ||||
|                     this.mAsyncFontPending = this.mFontTypeface == null; | ||||
|                 } catch (Resources.NotFoundException | UnsupportedOperationException unused) { | ||||
|                 } | ||||
|             } | ||||
|             if (this.mFontTypeface != null || (string = tintTypedArray.getString(i)) == null) { | ||||
|                 return; | ||||
|             } | ||||
|             if (Build.VERSION.SDK_INT >= 28 && this.mFontWeight != -1) { | ||||
|                 this.mFontTypeface = Api28Impl.create(Typeface.create(string, 0), this.mFontWeight, (this.mStyle & 2) != 0); | ||||
|                 return; | ||||
|             } else { | ||||
|                 this.mFontTypeface = Typeface.create(string, this.mStyle); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         if (tintTypedArray.hasValue(R.styleable.TextAppearance_android_typeface)) { | ||||
|             this.mAsyncFontPending = false; | ||||
|             int i5 = tintTypedArray.getInt(R.styleable.TextAppearance_android_typeface, 1); | ||||
|             if (i5 == 1) { | ||||
|                 this.mFontTypeface = Typeface.SANS_SERIF; | ||||
|             } else if (i5 == 2) { | ||||
|                 this.mFontTypeface = Typeface.SERIF; | ||||
|             } else { | ||||
|                 if (i5 != 3) { | ||||
|                     return; | ||||
|                 } | ||||
|                 this.mFontTypeface = Typeface.MONOSPACE; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void onAsyncTypefaceReceived(WeakReference<TextView> weakReference, final Typeface typeface) { | ||||
|         if (this.mAsyncFontPending) { | ||||
|             this.mFontTypeface = typeface; | ||||
|             final TextView textView = weakReference.get(); | ||||
|             if (textView != null) { | ||||
|                 if (ViewCompat.isAttachedToWindow(textView)) { | ||||
|                     final int i = this.mStyle; | ||||
|                     textView.post(new Runnable() { // from class: androidx.appcompat.widget.AppCompatTextHelper.2 | ||||
|                         @Override // java.lang.Runnable | ||||
|                         public void run() { | ||||
|                             textView.setTypeface(typeface, i); | ||||
|                         } | ||||
|                     }); | ||||
|                 } else { | ||||
|                     textView.setTypeface(typeface, this.mStyle); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void onSetTextAppearance(Context context, int i) { | ||||
|         String string; | ||||
|         ColorStateList colorStateList; | ||||
|         ColorStateList colorStateList2; | ||||
|         ColorStateList colorStateList3; | ||||
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, i, R.styleable.TextAppearance); | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.TextAppearance_textAllCaps)) { | ||||
|             setAllCaps(obtainStyledAttributes.getBoolean(R.styleable.TextAppearance_textAllCaps, false)); | ||||
|         } | ||||
|         if (Build.VERSION.SDK_INT < 23) { | ||||
|             if (obtainStyledAttributes.hasValue(R.styleable.TextAppearance_android_textColor) && (colorStateList3 = obtainStyledAttributes.getColorStateList(R.styleable.TextAppearance_android_textColor)) != null) { | ||||
|                 this.mView.setTextColor(colorStateList3); | ||||
|             } | ||||
|             if (obtainStyledAttributes.hasValue(R.styleable.TextAppearance_android_textColorLink) && (colorStateList2 = obtainStyledAttributes.getColorStateList(R.styleable.TextAppearance_android_textColorLink)) != null) { | ||||
|                 this.mView.setLinkTextColor(colorStateList2); | ||||
|             } | ||||
|             if (obtainStyledAttributes.hasValue(R.styleable.TextAppearance_android_textColorHint) && (colorStateList = obtainStyledAttributes.getColorStateList(R.styleable.TextAppearance_android_textColorHint)) != null) { | ||||
|                 this.mView.setHintTextColor(colorStateList); | ||||
|             } | ||||
|         } | ||||
|         if (obtainStyledAttributes.hasValue(R.styleable.TextAppearance_android_textSize) && obtainStyledAttributes.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, -1) == 0) { | ||||
|             this.mView.setTextSize(0, 0.0f); | ||||
|         } | ||||
|         updateTypefaceAndStyle(context, obtainStyledAttributes); | ||||
|         if (Build.VERSION.SDK_INT >= 26 && obtainStyledAttributes.hasValue(R.styleable.TextAppearance_fontVariationSettings) && (string = obtainStyledAttributes.getString(R.styleable.TextAppearance_fontVariationSettings)) != null) { | ||||
|             Api26Impl.setFontVariationSettings(this.mView, string); | ||||
|         } | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         Typeface typeface = this.mFontTypeface; | ||||
|         if (typeface != null) { | ||||
|             this.mView.setTypeface(typeface, this.mStyle); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void setAllCaps(boolean z) { | ||||
|         this.mView.setAllCaps(z); | ||||
|     } | ||||
|  | ||||
|     void onSetCompoundDrawables() { | ||||
|         applyCompoundDrawablesTints(); | ||||
|     } | ||||
|  | ||||
|     void applyCompoundDrawablesTints() { | ||||
|         if (this.mDrawableLeftTint != null || this.mDrawableTopTint != null || this.mDrawableRightTint != null || this.mDrawableBottomTint != null) { | ||||
|             Drawable[] compoundDrawables = this.mView.getCompoundDrawables(); | ||||
|             applyCompoundDrawableTint(compoundDrawables[0], this.mDrawableLeftTint); | ||||
|             applyCompoundDrawableTint(compoundDrawables[1], this.mDrawableTopTint); | ||||
|             applyCompoundDrawableTint(compoundDrawables[2], this.mDrawableRightTint); | ||||
|             applyCompoundDrawableTint(compoundDrawables[3], this.mDrawableBottomTint); | ||||
|         } | ||||
|         if (this.mDrawableStartTint == null && this.mDrawableEndTint == null) { | ||||
|             return; | ||||
|         } | ||||
|         Drawable[] compoundDrawablesRelative = Api17Impl.getCompoundDrawablesRelative(this.mView); | ||||
|         applyCompoundDrawableTint(compoundDrawablesRelative[0], this.mDrawableStartTint); | ||||
|         applyCompoundDrawableTint(compoundDrawablesRelative[2], this.mDrawableEndTint); | ||||
|     } | ||||
|  | ||||
|     private void applyCompoundDrawableTint(Drawable drawable, TintInfo tintInfo) { | ||||
|         if (drawable == null || tintInfo == null) { | ||||
|             return; | ||||
|         } | ||||
|         AppCompatDrawableManager.tintDrawable(drawable, tintInfo, this.mView.getDrawableState()); | ||||
|     } | ||||
|  | ||||
|     private static TintInfo createTintInfo(Context context, AppCompatDrawableManager appCompatDrawableManager, int i) { | ||||
|         ColorStateList tintList = appCompatDrawableManager.getTintList(context, i); | ||||
|         if (tintList == null) { | ||||
|             return null; | ||||
|         } | ||||
|         TintInfo tintInfo = new TintInfo(); | ||||
|         tintInfo.mHasTintList = true; | ||||
|         tintInfo.mTintList = tintList; | ||||
|         return tintInfo; | ||||
|     } | ||||
|  | ||||
|     void onLayout(boolean z, int i, int i2, int i3, int i4) { | ||||
|         if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) { | ||||
|             return; | ||||
|         } | ||||
|         autoSizeText(); | ||||
|     } | ||||
|  | ||||
|     void setTextSize(int i, float f) { | ||||
|         if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE || isAutoSizeEnabled()) { | ||||
|             return; | ||||
|         } | ||||
|         setTextSizeInternal(i, f); | ||||
|     } | ||||
|  | ||||
|     void autoSizeText() { | ||||
|         this.mAutoSizeTextHelper.autoSizeText(); | ||||
|     } | ||||
|  | ||||
|     boolean isAutoSizeEnabled() { | ||||
|         return this.mAutoSizeTextHelper.isAutoSizeEnabled(); | ||||
|     } | ||||
|  | ||||
|     private void setTextSizeInternal(int i, float f) { | ||||
|         this.mAutoSizeTextHelper.setTextSizeInternal(i, f); | ||||
|     } | ||||
|  | ||||
|     void setAutoSizeTextTypeWithDefaults(int i) { | ||||
|         this.mAutoSizeTextHelper.setAutoSizeTextTypeWithDefaults(i); | ||||
|     } | ||||
|  | ||||
|     void setAutoSizeTextTypeUniformWithConfiguration(int i, int i2, int i3, int i4) throws IllegalArgumentException { | ||||
|         this.mAutoSizeTextHelper.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4); | ||||
|     } | ||||
|  | ||||
|     void setAutoSizeTextTypeUniformWithPresetSizes(int[] iArr, int i) throws IllegalArgumentException { | ||||
|         this.mAutoSizeTextHelper.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i); | ||||
|     } | ||||
|  | ||||
|     int getAutoSizeTextType() { | ||||
|         return this.mAutoSizeTextHelper.getAutoSizeTextType(); | ||||
|     } | ||||
|  | ||||
|     int getAutoSizeStepGranularity() { | ||||
|         return this.mAutoSizeTextHelper.getAutoSizeStepGranularity(); | ||||
|     } | ||||
|  | ||||
|     int getAutoSizeMinTextSize() { | ||||
|         return this.mAutoSizeTextHelper.getAutoSizeMinTextSize(); | ||||
|     } | ||||
|  | ||||
|     int getAutoSizeMaxTextSize() { | ||||
|         return this.mAutoSizeTextHelper.getAutoSizeMaxTextSize(); | ||||
|     } | ||||
|  | ||||
|     int[] getAutoSizeTextAvailableSizes() { | ||||
|         return this.mAutoSizeTextHelper.getAutoSizeTextAvailableSizes(); | ||||
|     } | ||||
|  | ||||
|     ColorStateList getCompoundDrawableTintList() { | ||||
|         TintInfo tintInfo = this.mDrawableTint; | ||||
|         if (tintInfo != null) { | ||||
|             return tintInfo.mTintList; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     void setCompoundDrawableTintList(ColorStateList colorStateList) { | ||||
|         if (this.mDrawableTint == null) { | ||||
|             this.mDrawableTint = new TintInfo(); | ||||
|         } | ||||
|         this.mDrawableTint.mTintList = colorStateList; | ||||
|         this.mDrawableTint.mHasTintList = colorStateList != null; | ||||
|         setCompoundTints(); | ||||
|     } | ||||
|  | ||||
|     PorterDuff.Mode getCompoundDrawableTintMode() { | ||||
|         TintInfo tintInfo = this.mDrawableTint; | ||||
|         if (tintInfo != null) { | ||||
|             return tintInfo.mTintMode; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     void setCompoundDrawableTintMode(PorterDuff.Mode mode) { | ||||
|         if (this.mDrawableTint == null) { | ||||
|             this.mDrawableTint = new TintInfo(); | ||||
|         } | ||||
|         this.mDrawableTint.mTintMode = mode; | ||||
|         this.mDrawableTint.mHasTintMode = mode != null; | ||||
|         setCompoundTints(); | ||||
|     } | ||||
|  | ||||
|     private void setCompoundDrawables(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4, Drawable drawable5, Drawable drawable6) { | ||||
|         if (drawable5 != null || drawable6 != null) { | ||||
|             Drawable[] compoundDrawablesRelative = Api17Impl.getCompoundDrawablesRelative(this.mView); | ||||
|             TextView textView = this.mView; | ||||
|             if (drawable5 == null) { | ||||
|                 drawable5 = compoundDrawablesRelative[0]; | ||||
|             } | ||||
|             if (drawable2 == null) { | ||||
|                 drawable2 = compoundDrawablesRelative[1]; | ||||
|             } | ||||
|             if (drawable6 == null) { | ||||
|                 drawable6 = compoundDrawablesRelative[2]; | ||||
|             } | ||||
|             if (drawable4 == null) { | ||||
|                 drawable4 = compoundDrawablesRelative[3]; | ||||
|             } | ||||
|             Api17Impl.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, drawable5, drawable2, drawable6, drawable4); | ||||
|             return; | ||||
|         } | ||||
|         if (drawable == null && drawable2 == null && drawable3 == null && drawable4 == null) { | ||||
|             return; | ||||
|         } | ||||
|         Drawable[] compoundDrawablesRelative2 = Api17Impl.getCompoundDrawablesRelative(this.mView); | ||||
|         Drawable drawable7 = compoundDrawablesRelative2[0]; | ||||
|         if (drawable7 != null || compoundDrawablesRelative2[2] != null) { | ||||
|             TextView textView2 = this.mView; | ||||
|             if (drawable2 == null) { | ||||
|                 drawable2 = compoundDrawablesRelative2[1]; | ||||
|             } | ||||
|             Drawable drawable8 = compoundDrawablesRelative2[2]; | ||||
|             if (drawable4 == null) { | ||||
|                 drawable4 = compoundDrawablesRelative2[3]; | ||||
|             } | ||||
|             Api17Impl.setCompoundDrawablesRelativeWithIntrinsicBounds(textView2, drawable7, drawable2, drawable8, drawable4); | ||||
|             return; | ||||
|         } | ||||
|         Drawable[] compoundDrawables = this.mView.getCompoundDrawables(); | ||||
|         TextView textView3 = this.mView; | ||||
|         if (drawable == null) { | ||||
|             drawable = compoundDrawables[0]; | ||||
|         } | ||||
|         if (drawable2 == null) { | ||||
|             drawable2 = compoundDrawables[1]; | ||||
|         } | ||||
|         if (drawable3 == null) { | ||||
|             drawable3 = compoundDrawables[2]; | ||||
|         } | ||||
|         if (drawable4 == null) { | ||||
|             drawable4 = compoundDrawables[3]; | ||||
|         } | ||||
|         textView3.setCompoundDrawablesWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4); | ||||
|     } | ||||
|  | ||||
|     void populateSurroundingTextIfNeeded(TextView textView, InputConnection inputConnection, EditorInfo editorInfo) { | ||||
|         if (Build.VERSION.SDK_INT >= 30 || inputConnection == null) { | ||||
|             return; | ||||
|         } | ||||
|         EditorInfoCompat.setInitialSurroundingText(editorInfo, textView.getText()); | ||||
|     } | ||||
|  | ||||
|     static class Api26Impl { | ||||
|         private Api26Impl() { | ||||
|         } | ||||
|  | ||||
|         static boolean setFontVariationSettings(TextView textView, String str) { | ||||
|             return textView.setFontVariationSettings(str); | ||||
|         } | ||||
|  | ||||
|         static int getAutoSizeStepGranularity(TextView textView) { | ||||
|             return textView.getAutoSizeStepGranularity(); | ||||
|         } | ||||
|  | ||||
|         static void setAutoSizeTextTypeUniformWithConfiguration(TextView textView, int i, int i2, int i3, int i4) { | ||||
|             textView.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4); | ||||
|         } | ||||
|  | ||||
|         static void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, int[] iArr, int i) { | ||||
|             textView.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static class Api24Impl { | ||||
|         private Api24Impl() { | ||||
|         } | ||||
|  | ||||
|         static void setTextLocales(TextView textView, LocaleList localeList) { | ||||
|             textView.setTextLocales(localeList); | ||||
|         } | ||||
|  | ||||
|         static LocaleList forLanguageTags(String str) { | ||||
|             return LocaleList.forLanguageTags(str); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static class Api17Impl { | ||||
|         private Api17Impl() { | ||||
|         } | ||||
|  | ||||
|         static void setTextLocale(TextView textView, Locale locale) { | ||||
|             textView.setTextLocale(locale); | ||||
|         } | ||||
|  | ||||
|         static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView, Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { | ||||
|             textView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4); | ||||
|         } | ||||
|  | ||||
|         static Drawable[] getCompoundDrawablesRelative(TextView textView) { | ||||
|             return textView.getCompoundDrawablesRelative(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static class Api21Impl { | ||||
|         private Api21Impl() { | ||||
|         } | ||||
|  | ||||
|         static Locale forLanguageTag(String str) { | ||||
|             return Locale.forLanguageTag(str); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static class Api28Impl { | ||||
|         private Api28Impl() { | ||||
|         } | ||||
|  | ||||
|         static Typeface create(Typeface typeface, int i, boolean z) { | ||||
|             return Typeface.create(typeface, i, z); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user