package androidx.appcompat.widget;

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.InputFilter;
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 androidx.core.text.c;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/* JADX INFO: compiled from: AppCompatTextView.java */
/* JADX INFO: loaded from: classes.dex */
public class d0 extends TextView implements androidx.core.view.w, androidx.core.widget.n, androidx.core.widget.b {

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final c0 f874f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final b0 f875g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private n f876h;

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private Future<androidx.core.text.c> f878j;

    public d0(Context context) {
        this(context, null);
    }

    private void c() {
        Future<androidx.core.text.c> future = this.f878j;
        if (future != null) {
            try {
                this.f878j = null;
                androidx.core.widget.j.m(this, future.get());
            } catch (InterruptedException | ExecutionException unused) {
            }
        }
    }

    private n getEmojiTextViewHelper() {
        if (this.f876h == null) {
            this.f876h = new n(this);
        }
        return this.f876h;
    }

    @Override // android.widget.TextView, android.view.View
    protected void drawableStateChanged() {
        super.drawableStateChanged();
        e eVar = this.f873e;
        if (eVar != null) {
            eVar.b();
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.b();
        }
    }

    @Override // android.widget.TextView
    public int getAutoSizeMaxTextSize() {
        if (androidx.core.widget.b.f2028a) {
            return super.getAutoSizeMaxTextSize();
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            return c0Var.e();
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int getAutoSizeMinTextSize() {
        if (androidx.core.widget.b.f2028a) {
            return super.getAutoSizeMinTextSize();
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            return c0Var.f();
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int getAutoSizeStepGranularity() {
        if (androidx.core.widget.b.f2028a) {
            return super.getAutoSizeStepGranularity();
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            return c0Var.g();
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int[] getAutoSizeTextAvailableSizes() {
        if (androidx.core.widget.b.f2028a) {
            return super.getAutoSizeTextAvailableSizes();
        }
        c0 c0Var = this.f874f;
        return c0Var != null ? c0Var.h() : new int[0];
    }

    @Override // android.widget.TextView
    @SuppressLint({"WrongConstant"})
    public int getAutoSizeTextType() {
        if (androidx.core.widget.b.f2028a) {
            return super.getAutoSizeTextType() == 1 ? 1 : 0;
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            return c0Var.i();
        }
        return 0;
    }

    @Override // android.widget.TextView
    public ActionMode.Callback getCustomSelectionActionModeCallback() {
        return androidx.core.widget.j.p(super.getCustomSelectionActionModeCallback());
    }

    @Override // android.widget.TextView
    public int getFirstBaselineToTopHeight() {
        return androidx.core.widget.j.b(this);
    }

    @Override // android.widget.TextView
    public int getLastBaselineToBottomHeight() {
        return androidx.core.widget.j.c(this);
    }

    @Override // androidx.core.view.w
    public ColorStateList getSupportBackgroundTintList() {
        e eVar = this.f873e;
        if (eVar != null) {
            return eVar.c();
        }
        return null;
    }

    @Override // androidx.core.view.w
    public PorterDuff.Mode getSupportBackgroundTintMode() {
        e eVar = this.f873e;
        if (eVar != null) {
            return eVar.d();
        }
        return null;
    }

    public ColorStateList getSupportCompoundDrawablesTintList() {
        return this.f874f.j();
    }

    public PorterDuff.Mode getSupportCompoundDrawablesTintMode() {
        return this.f874f.k();
    }

    @Override // android.widget.TextView
    public CharSequence getText() {
        c();
        return super.getText();
    }

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

    public c.a getTextMetricsParamsCompat() {
        return androidx.core.widget.j.f(this);
    }

    @Override // android.widget.TextView, android.view.View
    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        InputConnection inputConnectionOnCreateInputConnection = super.onCreateInputConnection(editorInfo);
        this.f874f.r(this, inputConnectionOnCreateInputConnection, editorInfo);
        return o.a(inputConnectionOnCreateInputConnection, editorInfo, this);
    }

    @Override // android.widget.TextView, android.view.View
    protected void onLayout(boolean z2, int i3, int i4, int i5, int i6) {
        super.onLayout(z2, i3, i4, i5, i6);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.o(z2, i3, i4, i5, i6);
        }
    }

    @Override // android.widget.TextView, android.view.View
    protected void onMeasure(int i3, int i4) {
        c();
        super.onMeasure(i3, i4);
    }

    @Override // android.widget.TextView
    protected void onTextChanged(CharSequence charSequence, int i3, int i4, int i5) {
        super.onTextChanged(charSequence, i3, i4, i5);
        c0 c0Var = this.f874f;
        if (c0Var == null || androidx.core.widget.b.f2028a || !c0Var.l()) {
            return;
        }
        this.f874f.c();
    }

    @Override // android.widget.TextView
    public void setAllCaps(boolean z2) {
        super.setAllCaps(z2);
        getEmojiTextViewHelper().c(z2);
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeUniformWithConfiguration(int i3, int i4, int i5, int i6) throws IllegalArgumentException {
        if (androidx.core.widget.b.f2028a) {
            super.setAutoSizeTextTypeUniformWithConfiguration(i3, i4, i5, i6);
            return;
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.t(i3, i4, i5, i6);
        }
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeUniformWithPresetSizes(int[] iArr, int i3) throws IllegalArgumentException {
        if (androidx.core.widget.b.f2028a) {
            super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i3);
            return;
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.u(iArr, i3);
        }
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeWithDefaults(int i3) {
        if (androidx.core.widget.b.f2028a) {
            super.setAutoSizeTextTypeWithDefaults(i3);
            return;
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.v(i3);
        }
    }

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

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

    @Override // android.widget.TextView
    public void setCompoundDrawables(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawables(drawable, drawable2, drawable3, drawable4);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.p();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelative(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawablesRelative(drawable, drawable2, drawable3, drawable4);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.p();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.p();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesWithIntrinsicBounds(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
        super.setCompoundDrawablesWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.p();
        }
    }

    @Override // android.widget.TextView
    public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(androidx.core.widget.j.q(this, callback));
    }

    public void setEmojiCompatEnabled(boolean z2) {
        getEmojiTextViewHelper().d(z2);
    }

    @Override // android.widget.TextView
    public void setFilters(InputFilter[] inputFilterArr) {
        super.setFilters(getEmojiTextViewHelper().a(inputFilterArr));
    }

    @Override // android.widget.TextView
    public void setFirstBaselineToTopHeight(int i3) {
        if (Build.VERSION.SDK_INT >= 28) {
            super.setFirstBaselineToTopHeight(i3);
        } else {
            androidx.core.widget.j.j(this, i3);
        }
    }

    @Override // android.widget.TextView
    public void setLastBaselineToBottomHeight(int i3) {
        if (Build.VERSION.SDK_INT >= 28) {
            super.setLastBaselineToBottomHeight(i3);
        } else {
            androidx.core.widget.j.k(this, i3);
        }
    }

    @Override // android.widget.TextView
    public void setLineHeight(int i3) {
        androidx.core.widget.j.l(this, i3);
    }

    public void setPrecomputedText(androidx.core.text.c cVar) {
        androidx.core.widget.j.m(this, cVar);
    }

    @Override // androidx.core.view.w
    public void setSupportBackgroundTintList(ColorStateList colorStateList) {
        e eVar = this.f873e;
        if (eVar != null) {
            eVar.i(colorStateList);
        }
    }

    @Override // androidx.core.view.w
    public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
        e eVar = this.f873e;
        if (eVar != null) {
            eVar.j(mode);
        }
    }

    @Override // androidx.core.widget.n
    public void setSupportCompoundDrawablesTintList(ColorStateList colorStateList) {
        this.f874f.w(colorStateList);
        this.f874f.b();
    }

    @Override // androidx.core.widget.n
    public void setSupportCompoundDrawablesTintMode(PorterDuff.Mode mode) {
        this.f874f.x(mode);
        this.f874f.b();
    }

    @Override // android.widget.TextView
    public void setTextAppearance(Context context, int i3) {
        super.setTextAppearance(context, i3);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.q(context, i3);
        }
    }

    @Override // android.widget.TextView
    public void setTextClassifier(TextClassifier textClassifier) {
        b0 b0Var;
        if (Build.VERSION.SDK_INT >= 28 || (b0Var = this.f875g) == null) {
            super.setTextClassifier(textClassifier);
        } else {
            b0Var.b(textClassifier);
        }
    }

    public void setTextFuture(Future<androidx.core.text.c> future) {
        this.f878j = future;
        if (future != null) {
            requestLayout();
        }
    }

    public void setTextMetricsParamsCompat(c.a aVar) {
        androidx.core.widget.j.o(this, aVar);
    }

    @Override // android.widget.TextView
    public void setTextSize(int i3, float f3) {
        if (androidx.core.widget.b.f2028a) {
            super.setTextSize(i3, f3);
            return;
        }
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.A(i3, f3);
        }
    }

    @Override // android.widget.TextView
    public void setTypeface(Typeface typeface, int i3) {
        if (this.f877i) {
            return;
        }
        Typeface typefaceA = null;
        if (typeface != null && i3 > 0) {
            typefaceA = androidx.core.graphics.e.a(getContext(), typeface, i3);
        }
        this.f877i = true;
        if (typefaceA != null) {
            typeface = typefaceA;
        }
        try {
            super.setTypeface(typeface, i3);
        } finally {
            this.f877i = false;
        }
    }

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

    public d0(Context context, AttributeSet attributeSet, int i3) {
        super(x0.b(context), attributeSet, i3);
        this.f877i = false;
        v0.a(this, getContext());
        e eVar = new e(this);
        this.f873e = eVar;
        eVar.e(attributeSet, i3);
        c0 c0Var = new c0(this);
        this.f874f = c0Var;
        c0Var.m(attributeSet, i3);
        c0Var.b();
        this.f875g = new b0(this);
        getEmojiTextViewHelper().b(attributeSet, i3);
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelativeWithIntrinsicBounds(int i3, int i4, int i5, int i6) {
        Context context = getContext();
        setCompoundDrawablesRelativeWithIntrinsicBounds(i3 != 0 ? d.a.b(context, i3) : null, i4 != 0 ? d.a.b(context, i4) : null, i5 != 0 ? d.a.b(context, i5) : null, i6 != 0 ? d.a.b(context, i6) : null);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.p();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesWithIntrinsicBounds(int i3, int i4, int i5, int i6) {
        Context context = getContext();
        setCompoundDrawablesWithIntrinsicBounds(i3 != 0 ? d.a.b(context, i3) : null, i4 != 0 ? d.a.b(context, i4) : null, i5 != 0 ? d.a.b(context, i5) : null, i6 != 0 ? d.a.b(context, i6) : null);
        c0 c0Var = this.f874f;
        if (c0Var != null) {
            c0Var.p();
        }
    }
}
