package androidx.appcompat.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.method.PasswordTransformationMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import g.e.d.c.f;
import java.lang.ref.WeakReference;

/* JADX INFO: compiled from: AppCompatTextHelper.java */
/* JADX INFO: loaded from: classes.dex */
class x {
    private final TextView a;
    private r0 b;
    private r0 c;
    private r0 d;
    private r0 e;
    private r0 f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private r0 f219g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private final z f220h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private int f221i = 0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private Typeface f222j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private boolean f223k;

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    class a extends f.a {
        final /* synthetic */ WeakReference a;

        a(WeakReference weakReference) {
            this.a = weakReference;
        }

        @Override // g.e.d.c.f.a
        public void c(int i2) {
        }

        @Override // g.e.d.c.f.a
        public void d(Typeface typeface) {
            x.this.l(this.a, typeface);
        }
    }

    x(TextView textView) {
        this.a = textView;
        this.f220h = new z(this.a);
    }

    private void a(Drawable drawable, r0 r0Var) {
        if (drawable == null || r0Var == null) {
            return;
        }
        j.C(drawable, r0Var, this.a.getDrawableState());
    }

    private static r0 d(Context context, j jVar, int i2) {
        ColorStateList colorStateListS = jVar.s(context, i2);
        if (colorStateListS == null) {
            return null;
        }
        r0 r0Var = new r0();
        r0Var.d = true;
        r0Var.a = colorStateListS;
        return r0Var;
    }

    private void t(int i2, float f) {
        this.f220h.t(i2, f);
    }

    private void u(Context context, t0 t0Var) {
        String strN;
        this.f221i = t0Var.j(g.a.j.TextAppearance_android_textStyle, this.f221i);
        if (t0Var.q(g.a.j.TextAppearance_android_fontFamily) || t0Var.q(g.a.j.TextAppearance_fontFamily)) {
            this.f222j = null;
            int i2 = t0Var.q(g.a.j.TextAppearance_fontFamily) ? g.a.j.TextAppearance_fontFamily : g.a.j.TextAppearance_android_fontFamily;
            if (!context.isRestricted()) {
                try {
                    Typeface typefaceI = t0Var.i(i2, this.f221i, new a(new WeakReference(this.a)));
                    this.f222j = typefaceI;
                    this.f223k = typefaceI == null;
                } catch (Resources.NotFoundException | UnsupportedOperationException unused) {
                }
            }
            if (this.f222j != null || (strN = t0Var.n(i2)) == null) {
                return;
            }
            this.f222j = Typeface.create(strN, this.f221i);
            return;
        }
        if (t0Var.q(g.a.j.TextAppearance_android_typeface)) {
            this.f223k = false;
            int iJ = t0Var.j(g.a.j.TextAppearance_android_typeface, 1);
            if (iJ == 1) {
                this.f222j = Typeface.SANS_SERIF;
            } else if (iJ == 2) {
                this.f222j = Typeface.SERIF;
            } else {
                if (iJ != 3) {
                    return;
                }
                this.f222j = Typeface.MONOSPACE;
            }
        }
    }

    void b() {
        if (this.b != null || this.c != null || this.d != null || this.e != null) {
            Drawable[] compoundDrawables = this.a.getCompoundDrawables();
            a(compoundDrawables[0], this.b);
            a(compoundDrawables[1], this.c);
            a(compoundDrawables[2], this.d);
            a(compoundDrawables[3], this.e);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (this.f == null && this.f219g == null) {
                return;
            }
            Drawable[] compoundDrawablesRelative = this.a.getCompoundDrawablesRelative();
            a(compoundDrawablesRelative[0], this.f);
            a(compoundDrawablesRelative[2], this.f219g);
        }
    }

    void c() {
        this.f220h.a();
    }

    int e() {
        return this.f220h.g();
    }

    int f() {
        return this.f220h.h();
    }

    int g() {
        return this.f220h.i();
    }

    int[] h() {
        return this.f220h.j();
    }

    int i() {
        return this.f220h.k();
    }

    boolean j() {
        return this.f220h.n();
    }

    @SuppressLint({"NewApi"})
    void k(AttributeSet attributeSet, int i2) {
        boolean zA;
        boolean z;
        ColorStateList colorStateListC;
        ColorStateList colorStateListC2;
        Context context = this.a.getContext();
        j jVarN = j.n();
        t0 t0VarT = t0.t(context, attributeSet, g.a.j.AppCompatTextHelper, i2, 0);
        int iM = t0VarT.m(g.a.j.AppCompatTextHelper_android_textAppearance, -1);
        if (t0VarT.q(g.a.j.AppCompatTextHelper_android_drawableLeft)) {
            this.b = d(context, jVarN, t0VarT.m(g.a.j.AppCompatTextHelper_android_drawableLeft, 0));
        }
        if (t0VarT.q(g.a.j.AppCompatTextHelper_android_drawableTop)) {
            this.c = d(context, jVarN, t0VarT.m(g.a.j.AppCompatTextHelper_android_drawableTop, 0));
        }
        if (t0VarT.q(g.a.j.AppCompatTextHelper_android_drawableRight)) {
            this.d = d(context, jVarN, t0VarT.m(g.a.j.AppCompatTextHelper_android_drawableRight, 0));
        }
        if (t0VarT.q(g.a.j.AppCompatTextHelper_android_drawableBottom)) {
            this.e = d(context, jVarN, t0VarT.m(g.a.j.AppCompatTextHelper_android_drawableBottom, 0));
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (t0VarT.q(g.a.j.AppCompatTextHelper_android_drawableStart)) {
                this.f = d(context, jVarN, t0VarT.m(g.a.j.AppCompatTextHelper_android_drawableStart, 0));
            }
            if (t0VarT.q(g.a.j.AppCompatTextHelper_android_drawableEnd)) {
                this.f219g = d(context, jVarN, t0VarT.m(g.a.j.AppCompatTextHelper_android_drawableEnd, 0));
            }
        }
        t0VarT.u();
        boolean z2 = this.a.getTransformationMethod() instanceof PasswordTransformationMethod;
        boolean z3 = true;
        if (iM != -1) {
            t0 t0VarR = t0.r(context, iM, g.a.j.TextAppearance);
            if (z2 || !t0VarR.q(g.a.j.TextAppearance_textAllCaps)) {
                zA = false;
                z = false;
            } else {
                zA = t0VarR.a(g.a.j.TextAppearance_textAllCaps, false);
                z = true;
            }
            u(context, t0VarR);
            if (Build.VERSION.SDK_INT < 23) {
                ColorStateList colorStateListC3 = t0VarR.q(g.a.j.TextAppearance_android_textColor) ? t0VarR.c(g.a.j.TextAppearance_android_textColor) : null;
                colorStateListC2 = t0VarR.q(g.a.j.TextAppearance_android_textColorHint) ? t0VarR.c(g.a.j.TextAppearance_android_textColorHint) : null;
                ColorStateList colorStateList = colorStateListC3;
                colorStateListC = t0VarR.q(g.a.j.TextAppearance_android_textColorLink) ? t0VarR.c(g.a.j.TextAppearance_android_textColorLink) : null;
                colorStateListC = colorStateList;
            } else {
                colorStateListC = null;
                colorStateListC2 = null;
            }
            t0VarR.u();
        } else {
            zA = false;
            z = false;
            colorStateListC = null;
            colorStateListC2 = null;
        }
        t0 t0VarT2 = t0.t(context, attributeSet, g.a.j.TextAppearance, i2, 0);
        if (z2 || !t0VarT2.q(g.a.j.TextAppearance_textAllCaps)) {
            z3 = z;
        } else {
            zA = t0VarT2.a(g.a.j.TextAppearance_textAllCaps, false);
        }
        if (Build.VERSION.SDK_INT < 23) {
            if (t0VarT2.q(g.a.j.TextAppearance_android_textColor)) {
                colorStateListC = t0VarT2.c(g.a.j.TextAppearance_android_textColor);
            }
            if (t0VarT2.q(g.a.j.TextAppearance_android_textColorHint)) {
                colorStateListC2 = t0VarT2.c(g.a.j.TextAppearance_android_textColorHint);
            }
            if (t0VarT2.q(g.a.j.TextAppearance_android_textColorLink)) {
                colorStateListC = t0VarT2.c(g.a.j.TextAppearance_android_textColorLink);
            }
        }
        if (Build.VERSION.SDK_INT >= 28 && t0VarT2.q(g.a.j.TextAppearance_android_textSize) && t0VarT2.e(g.a.j.TextAppearance_android_textSize, -1) == 0) {
            this.a.setTextSize(0, 0.0f);
        }
        u(context, t0VarT2);
        t0VarT2.u();
        if (colorStateListC != null) {
            this.a.setTextColor(colorStateListC);
        }
        if (colorStateListC2 != null) {
            this.a.setHintTextColor(colorStateListC2);
        }
        if (colorStateListC != null) {
            this.a.setLinkTextColor(colorStateListC);
        }
        if (!z2 && z3) {
            o(zA);
        }
        Typeface typeface = this.f222j;
        if (typeface != null) {
            this.a.setTypeface(typeface, this.f221i);
        }
        this.f220h.o(attributeSet, i2);
        if (androidx.core.widget.b.a && this.f220h.k() != 0) {
            int[] iArrJ = this.f220h.j();
            if (iArrJ.length > 0) {
                if (this.a.getAutoSizeStepGranularity() != -1.0f) {
                    this.a.setAutoSizeTextTypeUniformWithConfiguration(this.f220h.h(), this.f220h.g(), this.f220h.i(), 0);
                } else {
                    this.a.setAutoSizeTextTypeUniformWithPresetSizes(iArrJ, 0);
                }
            }
        }
        t0 t0VarS = t0.s(context, attributeSet, g.a.j.AppCompatTextView);
        int iE = t0VarS.e(g.a.j.AppCompatTextView_firstBaselineToTopHeight, -1);
        int iE2 = t0VarS.e(g.a.j.AppCompatTextView_lastBaselineToBottomHeight, -1);
        int iE3 = t0VarS.e(g.a.j.AppCompatTextView_lineHeight, -1);
        t0VarS.u();
        if (iE != -1) {
            androidx.core.widget.i.f(this.a, iE);
        }
        if (iE2 != -1) {
            androidx.core.widget.i.g(this.a, iE2);
        }
        if (iE3 != -1) {
            androidx.core.widget.i.h(this.a, iE3);
        }
    }

    void l(WeakReference<TextView> weakReference, Typeface typeface) {
        if (this.f223k) {
            this.f222j = typeface;
            TextView textView = weakReference.get();
            if (textView != null) {
                textView.setTypeface(typeface, this.f221i);
            }
        }
    }

    void m(boolean z, int i2, int i3, int i4, int i5) {
        if (androidx.core.widget.b.a) {
            return;
        }
        c();
    }

    void n(Context context, int i2) {
        ColorStateList colorStateListC;
        t0 t0VarR = t0.r(context, i2, g.a.j.TextAppearance);
        if (t0VarR.q(g.a.j.TextAppearance_textAllCaps)) {
            o(t0VarR.a(g.a.j.TextAppearance_textAllCaps, false));
        }
        if (Build.VERSION.SDK_INT < 23 && t0VarR.q(g.a.j.TextAppearance_android_textColor) && (colorStateListC = t0VarR.c(g.a.j.TextAppearance_android_textColor)) != null) {
            this.a.setTextColor(colorStateListC);
        }
        if (t0VarR.q(g.a.j.TextAppearance_android_textSize) && t0VarR.e(g.a.j.TextAppearance_android_textSize, -1) == 0) {
            this.a.setTextSize(0, 0.0f);
        }
        u(context, t0VarR);
        t0VarR.u();
        Typeface typeface = this.f222j;
        if (typeface != null) {
            this.a.setTypeface(typeface, this.f221i);
        }
    }

    void o(boolean z) {
        this.a.setAllCaps(z);
    }

    void p(int i2, int i3, int i4, int i5) throws IllegalArgumentException {
        this.f220h.p(i2, i3, i4, i5);
    }

    void q(int[] iArr, int i2) throws IllegalArgumentException {
        this.f220h.q(iArr, i2);
    }

    void r(int i2) {
        this.f220h.r(i2);
    }

    void s(int i2, float f) {
        if (androidx.core.widget.b.a || j()) {
            return;
        }
        t(i2, f);
    }
}
