package android.support.v7.widget;

import a.b.c.a.e.f;
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 java.lang.ref.WeakReference;

/* JADX INFO: compiled from: AppCompatTextHelper.java */
/* JADX INFO: loaded from: classes.dex */
class x {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final TextView f1163a;

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private r0 f1168f;
    private r0 g;
    private final z h;
    private int i = 0;
    private Typeface j;
    private boolean k;

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    class a extends f.a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ WeakReference f1169a;

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

        @Override // a.b.c.a.e.f.a
        public void c(int i) {
        }

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

    x(TextView textView) {
        this.f1163a = textView;
        this.h = new z(this.f1163a);
    }

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

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

    private void t(int i, float f2) {
        this.h.t(i, f2);
    }

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

    void b() {
        if (this.f1164b != null || this.f1165c != null || this.f1166d != null || this.f1167e != null) {
            Drawable[] compoundDrawables = this.f1163a.getCompoundDrawables();
            a(compoundDrawables[0], this.f1164b);
            a(compoundDrawables[1], this.f1165c);
            a(compoundDrawables[2], this.f1166d);
            a(compoundDrawables[3], this.f1167e);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (this.f1168f == null && this.g == null) {
                return;
            }
            Drawable[] compoundDrawablesRelative = this.f1163a.getCompoundDrawablesRelative();
            a(compoundDrawablesRelative[0], this.f1168f);
            a(compoundDrawablesRelative[2], this.g);
        }
    }

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

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

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

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

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

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

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

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

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

    void m(boolean z, int i, int i2, int i3, int i4) {
        if (android.support.v4.widget.b.f694a) {
            return;
        }
        c();
    }

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

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

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

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

    void r(int i) {
        this.h.r(i);
    }

    void s(int i, float f2) {
        if (android.support.v4.widget.b.f694a || j()) {
            return;
        }
        t(i, f2);
    }
}
