package c.b.g;

import android.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextDirectionHeuristic;
import android.text.TextDirectionHeuristics;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.textclassifier.TextClassifier;
import android.widget.TextView;
import c.e.g.a;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/* JADX INFO: loaded from: classes.dex */
public class p extends TextView implements c.e.j.b {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final e f5020b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final n f5021c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final m f5022d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f5023e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Future<c.e.g.a> f5024f;

    public p(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, R.attr.textViewStyle);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public p(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        i0.a(context);
        this.f5023e = false;
        h0.a(this, getContext());
        e eVar = new e(this);
        this.f5020b = eVar;
        eVar.d(attributeSet, i2);
        n nVar = new n(this);
        this.f5021c = nVar;
        nVar.e(attributeSet, i2);
        nVar.b();
        this.f5022d = new m(this);
    }

    @Override // android.widget.TextView, android.view.View
    public void drawableStateChanged() {
        super.drawableStateChanged();
        e eVar = this.f5020b;
        if (eVar != null) {
            eVar.a();
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }

    @Override // android.widget.TextView
    public int getAutoSizeMaxTextSize() {
        if (c.e.j.b.f5352a) {
            return super.getAutoSizeMaxTextSize();
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            return Math.round(nVar.f5000i.f5033h);
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int getAutoSizeMinTextSize() {
        if (c.e.j.b.f5352a) {
            return super.getAutoSizeMinTextSize();
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            return Math.round(nVar.f5000i.f5032g);
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int getAutoSizeStepGranularity() {
        if (c.e.j.b.f5352a) {
            return super.getAutoSizeStepGranularity();
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            return Math.round(nVar.f5000i.f5031f);
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int[] getAutoSizeTextAvailableSizes() {
        if (c.e.j.b.f5352a) {
            return super.getAutoSizeTextAvailableSizes();
        }
        n nVar = this.f5021c;
        return nVar != null ? nVar.f5000i.f5034i : new int[0];
    }

    @Override // android.widget.TextView
    @SuppressLint({"WrongConstant"})
    public int getAutoSizeTextType() {
        if (c.e.j.b.f5352a) {
            return super.getAutoSizeTextType() == 1 ? 1 : 0;
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            return nVar.f5000i.f5029d;
        }
        return 0;
    }

    @Override // android.widget.TextView
    public int getFirstBaselineToTopHeight() {
        return getPaddingTop() - getPaint().getFontMetricsInt().top;
    }

    @Override // android.widget.TextView
    public int getLastBaselineToBottomHeight() {
        return getPaddingBottom() + getPaint().getFontMetricsInt().bottom;
    }

    public ColorStateList getSupportBackgroundTintList() {
        e eVar = this.f5020b;
        if (eVar != null) {
            return eVar.b();
        }
        return null;
    }

    public PorterDuff.Mode getSupportBackgroundTintMode() {
        e eVar = this.f5020b;
        if (eVar != null) {
            return eVar.c();
        }
        return null;
    }

    public ColorStateList getSupportCompoundDrawablesTintList() {
        j0 j0Var = this.f5021c.f4999h;
        if (j0Var != null) {
            return j0Var.f4980a;
        }
        return null;
    }

    public PorterDuff.Mode getSupportCompoundDrawablesTintMode() {
        j0 j0Var = this.f5021c.f4999h;
        if (j0Var != null) {
            return j0Var.f4981b;
        }
        return null;
    }

    @Override // android.widget.TextView
    public CharSequence getText() {
        Future<c.e.g.a> future = this.f5024f;
        if (future != null) {
            try {
                this.f5024f = null;
                c.e.b.a.E(this, future.get());
            } catch (InterruptedException | ExecutionException unused) {
            }
        }
        return super.getText();
    }

    @Override // android.widget.TextView
    public TextClassifier getTextClassifier() {
        m mVar;
        return (Build.VERSION.SDK_INT >= 28 || (mVar = this.f5022d) == null) ? super.getTextClassifier() : mVar.a();
    }

    public a.C0067a getTextMetricsParamsCompat() {
        return c.e.b.a.k(this);
    }

    @Override // android.widget.TextView, android.view.View
    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        InputConnection inputConnectionOnCreateInputConnection = super.onCreateInputConnection(editorInfo);
        this.f5021c.g(this, inputConnectionOnCreateInputConnection, editorInfo);
        c.b.a.a(inputConnectionOnCreateInputConnection, editorInfo, this);
        return inputConnectionOnCreateInputConnection;
    }

    @Override // android.widget.TextView, android.view.View
    public void onLayout(boolean z, int i2, int i3, int i4, int i5) {
        super.onLayout(z, i2, i3, i4, i5);
        n nVar = this.f5021c;
        if (nVar == null || c.e.j.b.f5352a) {
            return;
        }
        nVar.f5000i.a();
    }

    @Override // android.widget.TextView, android.view.View
    public void onMeasure(int i2, int i3) {
        Future<c.e.g.a> future = this.f5024f;
        if (future != null) {
            try {
                this.f5024f = null;
                c.e.b.a.E(this, future.get());
            } catch (InterruptedException | ExecutionException unused) {
            }
        }
        super.onMeasure(i2, i3);
    }

    @Override // android.widget.TextView
    public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
        super.onTextChanged(charSequence, i2, i3, i4);
        n nVar = this.f5021c;
        if (nVar == null || c.e.j.b.f5352a || !nVar.d()) {
            return;
        }
        this.f5021c.f5000i.a();
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeUniformWithConfiguration(int i2, int i3, int i4, int i5) {
        if (c.e.j.b.f5352a) {
            super.setAutoSizeTextTypeUniformWithConfiguration(i2, i3, i4, i5);
            return;
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.h(i2, i3, i4, i5);
        }
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeUniformWithPresetSizes(int[] iArr, int i2) {
        if (c.e.j.b.f5352a) {
            super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i2);
            return;
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.i(iArr, i2);
        }
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeWithDefaults(int i2) {
        if (c.e.j.b.f5352a) {
            super.setAutoSizeTextTypeWithDefaults(i2);
            return;
        }
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.j(i2);
        }
    }

    @Override // android.view.View
    public void setBackgroundDrawable(Drawable drawable) {
        super.setBackgroundDrawable(drawable);
        e eVar = this.f5020b;
        if (eVar != null) {
            eVar.e();
        }
    }

    @Override // android.view.View
    public void setBackgroundResource(int i2) {
        super.setBackgroundResource(i2);
        e eVar = this.f5020b;
        if (eVar != null) {
            eVar.f(i2);
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawables(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawables(drawable, drawable2, drawable3, drawable4);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelative(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawablesRelative(drawable, drawable2, drawable3, drawable4);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelativeWithIntrinsicBounds(int i2, int i3, int i4, int i5) {
        Context context = getContext();
        setCompoundDrawablesRelativeWithIntrinsicBounds(i2 != 0 ? c.b.d.a.a.a(context, i2) : null, i3 != 0 ? c.b.d.a.a.a(context, i3) : null, i4 != 0 ? c.b.d.a.a.a(context, i4) : null, i5 != 0 ? c.b.d.a.a.a(context, i5) : null);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesWithIntrinsicBounds(int i2, int i3, int i4, int i5) {
        Context context = getContext();
        setCompoundDrawablesWithIntrinsicBounds(i2 != 0 ? c.b.d.a.a.a(context, i2) : null, i3 != 0 ? c.b.d.a.a.a(context, i3) : null, i4 != 0 ? c.b.d.a.a.a(context, i4) : null, i5 != 0 ? c.b.d.a.a.a(context, i5) : null);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }

    @Override // android.widget.TextView
    public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(c.e.b.a.O(this, callback));
    }

    @Override // android.widget.TextView
    public void setFirstBaselineToTopHeight(int i2) {
        if (Build.VERSION.SDK_INT >= 28) {
            super.setFirstBaselineToTopHeight(i2);
        } else {
            c.e.b.a.B(this, i2);
        }
    }

    @Override // android.widget.TextView
    public void setLastBaselineToBottomHeight(int i2) {
        if (Build.VERSION.SDK_INT >= 28) {
            super.setLastBaselineToBottomHeight(i2);
        } else {
            c.e.b.a.C(this, i2);
        }
    }

    @Override // android.widget.TextView
    public void setLineHeight(int i2) {
        c.e.b.a.D(this, i2);
    }

    public void setPrecomputedText(c.e.g.a aVar) {
        c.e.b.a.E(this, aVar);
    }

    public void setSupportBackgroundTintList(ColorStateList colorStateList) {
        e eVar = this.f5020b;
        if (eVar != null) {
            eVar.h(colorStateList);
        }
    }

    public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
        e eVar = this.f5020b;
        if (eVar != null) {
            eVar.i(mode);
        }
    }

    public void setSupportCompoundDrawablesTintList(ColorStateList colorStateList) {
        this.f5021c.k(colorStateList);
        this.f5021c.b();
    }

    public void setSupportCompoundDrawablesTintMode(PorterDuff.Mode mode) {
        this.f5021c.l(mode);
        this.f5021c.b();
    }

    @Override // android.widget.TextView
    public void setTextAppearance(Context context, int i2) {
        super.setTextAppearance(context, i2);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.f(context, i2);
        }
    }

    @Override // android.widget.TextView
    public void setTextClassifier(TextClassifier textClassifier) {
        m mVar;
        if (Build.VERSION.SDK_INT >= 28 || (mVar = this.f5022d) == null) {
            super.setTextClassifier(textClassifier);
        } else {
            mVar.f4989b = textClassifier;
        }
    }

    public void setTextFuture(Future<c.e.g.a> future) {
        this.f5024f = future;
        if (future != null) {
            requestLayout();
        }
    }

    public void setTextMetricsParamsCompat(a.C0067a c0067a) {
        TextDirectionHeuristic textDirectionHeuristic = c0067a.f5248b;
        int i2 = 1;
        if (textDirectionHeuristic != TextDirectionHeuristics.FIRSTSTRONG_RTL && textDirectionHeuristic != TextDirectionHeuristics.FIRSTSTRONG_LTR) {
            if (textDirectionHeuristic == TextDirectionHeuristics.ANYRTL_LTR) {
                i2 = 2;
            } else if (textDirectionHeuristic == TextDirectionHeuristics.LTR) {
                i2 = 3;
            } else if (textDirectionHeuristic == TextDirectionHeuristics.RTL) {
                i2 = 4;
            } else if (textDirectionHeuristic == TextDirectionHeuristics.LOCALE) {
                i2 = 5;
            } else if (textDirectionHeuristic == TextDirectionHeuristics.FIRSTSTRONG_LTR) {
                i2 = 6;
            } else if (textDirectionHeuristic == TextDirectionHeuristics.FIRSTSTRONG_RTL) {
                i2 = 7;
            }
        }
        setTextDirection(i2);
        getPaint().set(c0067a.f5247a);
        setBreakStrategy(c0067a.f5249c);
        setHyphenationFrequency(c0067a.f5250d);
    }

    @Override // android.widget.TextView
    public void setTextSize(int i2, float f2) {
        boolean z = c.e.j.b.f5352a;
        if (z) {
            super.setTextSize(i2, f2);
            return;
        }
        n nVar = this.f5021c;
        if (nVar == null || z || nVar.d()) {
            return;
        }
        nVar.f5000i.f(i2, f2);
    }

    @Override // android.widget.TextView
    public void setTypeface(Typeface typeface, int i2) {
        if (this.f5023e) {
            return;
        }
        Typeface typefaceCreate = null;
        if (typeface != null && i2 > 0) {
            Context context = getContext();
            c.e.d.i iVar = c.e.d.c.f5191a;
            if (context == null) {
                throw new IllegalArgumentException("Context cannot be null");
            }
            typefaceCreate = Typeface.create(typeface, i2);
        }
        this.f5023e = true;
        if (typefaceCreate != null) {
            typeface = typefaceCreate;
        }
        try {
            super.setTypeface(typeface, i2);
        } finally {
            this.f5023e = false;
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesWithIntrinsicBounds(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawablesWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4);
        n nVar = this.f5021c;
        if (nVar != null) {
            nVar.b();
        }
    }
}
