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 c.f.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;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    x(TextView textView) {
        this.a = textView;
        this.f553h = 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.f497d = true;
        r0Var.a = colorStateListS;
        return r0Var;
    }

    private void t(int i2, float f2) {
        this.f553h.t(i2, f2);
    }

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

    void b() {
        if (this.f547b != null || this.f548c != null || this.f549d != null || this.f550e != null) {
            Drawable[] compoundDrawables = this.a.getCompoundDrawables();
            a(compoundDrawables[0], this.f547b);
            a(compoundDrawables[1], this.f548c);
            a(compoundDrawables[2], this.f549d);
            a(compoundDrawables[3], this.f550e);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (this.f551f == null && this.f552g == null) {
                return;
            }
            Drawable[] compoundDrawablesRelative = this.a.getCompoundDrawablesRelative();
            a(compoundDrawablesRelative[0], this.f551f);
            a(compoundDrawablesRelative[2], this.f552g);
        }
    }

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

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

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

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

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

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

    boolean j() {
        return this.f553h.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, c.a.j.AppCompatTextHelper, i2, 0);
        int iM = t0VarT.m(c.a.j.AppCompatTextHelper_android_textAppearance, -1);
        if (t0VarT.q(c.a.j.AppCompatTextHelper_android_drawableLeft)) {
            this.f547b = d(context, jVarN, t0VarT.m(c.a.j.AppCompatTextHelper_android_drawableLeft, 0));
        }
        if (t0VarT.q(c.a.j.AppCompatTextHelper_android_drawableTop)) {
            this.f548c = d(context, jVarN, t0VarT.m(c.a.j.AppCompatTextHelper_android_drawableTop, 0));
        }
        if (t0VarT.q(c.a.j.AppCompatTextHelper_android_drawableRight)) {
            this.f549d = d(context, jVarN, t0VarT.m(c.a.j.AppCompatTextHelper_android_drawableRight, 0));
        }
        if (t0VarT.q(c.a.j.AppCompatTextHelper_android_drawableBottom)) {
            this.f550e = d(context, jVarN, t0VarT.m(c.a.j.AppCompatTextHelper_android_drawableBottom, 0));
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (t0VarT.q(c.a.j.AppCompatTextHelper_android_drawableStart)) {
                this.f551f = d(context, jVarN, t0VarT.m(c.a.j.AppCompatTextHelper_android_drawableStart, 0));
            }
            if (t0VarT.q(c.a.j.AppCompatTextHelper_android_drawableEnd)) {
                this.f552g = d(context, jVarN, t0VarT.m(c.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, c.a.j.TextAppearance);
            if (z2 || !t0VarR.q(c.a.j.TextAppearance_textAllCaps)) {
                zA = false;
                z = false;
            } else {
                zA = t0VarR.a(c.a.j.TextAppearance_textAllCaps, false);
                z = true;
            }
            u(context, t0VarR);
            if (Build.VERSION.SDK_INT < 23) {
                ColorStateList colorStateListC3 = t0VarR.q(c.a.j.TextAppearance_android_textColor) ? t0VarR.c(c.a.j.TextAppearance_android_textColor) : null;
                colorStateListC2 = t0VarR.q(c.a.j.TextAppearance_android_textColorHint) ? t0VarR.c(c.a.j.TextAppearance_android_textColorHint) : null;
                ColorStateList colorStateList = colorStateListC3;
                colorStateListC = t0VarR.q(c.a.j.TextAppearance_android_textColorLink) ? t0VarR.c(c.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, c.a.j.TextAppearance, i2, 0);
        if (z2 || !t0VarT2.q(c.a.j.TextAppearance_textAllCaps)) {
            z3 = z;
        } else {
            zA = t0VarT2.a(c.a.j.TextAppearance_textAllCaps, false);
        }
        if (Build.VERSION.SDK_INT < 23) {
            if (t0VarT2.q(c.a.j.TextAppearance_android_textColor)) {
                colorStateListC = t0VarT2.c(c.a.j.TextAppearance_android_textColor);
            }
            if (t0VarT2.q(c.a.j.TextAppearance_android_textColorHint)) {
                colorStateListC2 = t0VarT2.c(c.a.j.TextAppearance_android_textColorHint);
            }
            if (t0VarT2.q(c.a.j.TextAppearance_android_textColorLink)) {
                colorStateListC = t0VarT2.c(c.a.j.TextAppearance_android_textColorLink);
            }
        }
        if (Build.VERSION.SDK_INT >= 28 && t0VarT2.q(c.a.j.TextAppearance_android_textSize) && t0VarT2.e(c.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.f555j;
        if (typeface != null) {
            this.a.setTypeface(typeface, this.f554i);
        }
        this.f553h.o(attributeSet, i2);
        if (androidx.core.widget.b.a && this.f553h.k() != 0) {
            int[] iArrJ = this.f553h.j();
            if (iArrJ.length > 0) {
                if (this.a.getAutoSizeStepGranularity() != -1.0f) {
                    this.a.setAutoSizeTextTypeUniformWithConfiguration(this.f553h.h(), this.f553h.g(), this.f553h.i(), 0);
                } else {
                    this.a.setAutoSizeTextTypeUniformWithPresetSizes(iArrJ, 0);
                }
            }
        }
        t0 t0VarS = t0.s(context, attributeSet, c.a.j.AppCompatTextView);
        int iE = t0VarS.e(c.a.j.AppCompatTextView_firstBaselineToTopHeight, -1);
        int iE2 = t0VarS.e(c.a.j.AppCompatTextView_lastBaselineToBottomHeight, -1);
        int iE3 = t0VarS.e(c.a.j.AppCompatTextView_lineHeight, -1);
        t0VarS.u();
        if (iE != -1) {
            androidx.core.widget.i.g(this.a, iE);
        }
        if (iE2 != -1) {
            androidx.core.widget.i.h(this.a, iE2);
        }
        if (iE3 != -1) {
            androidx.core.widget.i.i(this.a, iE3);
        }
    }

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

    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, c.a.j.TextAppearance);
        if (t0VarR.q(c.a.j.TextAppearance_textAllCaps)) {
            o(t0VarR.a(c.a.j.TextAppearance_textAllCaps, false));
        }
        if (Build.VERSION.SDK_INT < 23 && t0VarR.q(c.a.j.TextAppearance_android_textColor) && (colorStateListC = t0VarR.c(c.a.j.TextAppearance_android_textColor)) != null) {
            this.a.setTextColor(colorStateListC);
        }
        if (t0VarR.q(c.a.j.TextAppearance_android_textSize) && t0VarR.e(c.a.j.TextAppearance_android_textSize, -1) == 0) {
            this.a.setTextSize(0, 0.0f);
        }
        u(context, t0VarR);
        t0VarR.u();
        Typeface typeface = this.f555j;
        if (typeface != null) {
            this.a.setTypeface(typeface, this.f554i);
        }
    }

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

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

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

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

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