package c.b.f;

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.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.b.f.c0;
import c.f.h.b;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/* JADX INFO: compiled from: AppCompatTextView.java */
/* JADX INFO: loaded from: classes.dex */
public class f0 extends TextView {

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public p f820g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public a f822i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public Future<c.f.h.b> f823j;

    /* JADX INFO: compiled from: AppCompatTextView.java */
    public interface a {
        void a(int i2);

        void b(int i2);
    }

    /* JADX INFO: compiled from: AppCompatTextView.java */
    public class b implements a {
        public b() {
        }

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

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

    /* JADX INFO: compiled from: AppCompatTextView.java */
    public class c extends b {
        public c() {
            super();
        }

        @Override // c.b.f.f0.b, c.b.f.f0.a
        public void a(int i2) {
            f0.super.setLastBaselineToBottomHeight(i2);
        }

        @Override // c.b.f.f0.b, c.b.f.f0.a
        public void b(int i2) {
            f0.super.setFirstBaselineToTopHeight(i2);
        }
    }

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

    private p getEmojiTextViewHelper() {
        if (this.f820g == null) {
            this.f820g = new p(this);
        }
        return this.f820g;
    }

    @Override // android.widget.TextView, android.view.View
    public void drawableStateChanged() {
        super.drawableStateChanged();
        g gVar = this.f817b;
        if (gVar != null) {
            gVar.a();
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            d0Var.b();
        }
    }

    @Override // android.widget.TextView
    public int getAutoSizeMaxTextSize() {
        if (i1.f864b) {
            return super.getAutoSizeMaxTextSize();
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            return Math.round(d0Var.f799i.f849h);
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int getAutoSizeMinTextSize() {
        if (i1.f864b) {
            return super.getAutoSizeMinTextSize();
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            return Math.round(d0Var.f799i.f848g);
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int getAutoSizeStepGranularity() {
        if (i1.f864b) {
            return super.getAutoSizeStepGranularity();
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            return Math.round(d0Var.f799i.f847f);
        }
        return -1;
    }

    @Override // android.widget.TextView
    public int[] getAutoSizeTextAvailableSizes() {
        if (i1.f864b) {
            return super.getAutoSizeTextAvailableSizes();
        }
        d0 d0Var = this.f818e;
        return d0Var != null ? d0Var.f799i.f850i : new int[0];
    }

    @Override // android.widget.TextView
    @SuppressLint({"WrongConstant"})
    public int getAutoSizeTextType() {
        if (i1.f864b) {
            return super.getAutoSizeTextType() == 1 ? 1 : 0;
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            return d0Var.f799i.f845d;
        }
        return 0;
    }

    @Override // android.widget.TextView
    public ActionMode.Callback getCustomSelectionActionModeCallback() {
        return c.f.b.h.K(super.getCustomSelectionActionModeCallback());
    }

    @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 a getSuperCaller() {
        if (this.f822i == null) {
            if (Build.VERSION.SDK_INT >= 28) {
                this.f822i = new c();
            } else {
                this.f822i = new b();
            }
        }
        return this.f822i;
    }

    public ColorStateList getSupportBackgroundTintList() {
        g gVar = this.f817b;
        if (gVar != null) {
            return gVar.b();
        }
        return null;
    }

    public PorterDuff.Mode getSupportBackgroundTintMode() {
        g gVar = this.f817b;
        if (gVar != null) {
            return gVar.c();
        }
        return null;
    }

    public ColorStateList getSupportCompoundDrawablesTintList() {
        return this.f818e.d();
    }

    public PorterDuff.Mode getSupportCompoundDrawablesTintMode() {
        return this.f818e.e();
    }

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

    @Override // android.widget.TextView
    public TextClassifier getTextClassifier() {
        c0 c0Var;
        if (Build.VERSION.SDK_INT >= 28 || (c0Var = this.f819f) == null) {
            return super.getTextClassifier();
        }
        TextClassifier textClassifier = c0Var.f781b;
        return textClassifier == null ? c0.a.a(c0Var.a) : textClassifier;
    }

    public b.a getTextMetricsParamsCompat() {
        return c.f.b.h.r(this);
    }

    @Override // android.widget.TextView, android.view.View
    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        InputConnection inputConnectionOnCreateInputConnection = super.onCreateInputConnection(editorInfo);
        this.f818e.i(this, inputConnectionOnCreateInputConnection, editorInfo);
        c.b.a.f(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);
        d0 d0Var = this.f818e;
        if (d0Var == null || i1.f864b) {
            return;
        }
        d0Var.f799i.a();
    }

    @Override // android.widget.TextView, android.view.View
    public void onMeasure(int i2, int i3) {
        Future<c.f.h.b> future = this.f823j;
        if (future != null) {
            try {
                this.f823j = null;
                c.f.b.h.F(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);
        d0 d0Var = this.f818e;
        if ((d0Var == null || i1.f864b || !d0Var.f()) ? false : true) {
            this.f818e.f799i.a();
        }
    }

    @Override // android.widget.TextView
    public void setAllCaps(boolean z) {
        super.setAllCaps(z);
        getEmojiTextViewHelper().f928b.a.b(z);
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeUniformWithConfiguration(int i2, int i3, int i4, int i5) throws IllegalArgumentException {
        if (i1.f864b) {
            super.setAutoSizeTextTypeUniformWithConfiguration(i2, i3, i4, i5);
            return;
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            d0Var.j(i2, i3, i4, i5);
        }
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeUniformWithPresetSizes(int[] iArr, int i2) throws IllegalArgumentException {
        if (i1.f864b) {
            super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i2);
            return;
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            d0Var.k(iArr, i2);
        }
    }

    @Override // android.widget.TextView
    public void setAutoSizeTextTypeWithDefaults(int i2) {
        if (i1.f864b) {
            super.setAutoSizeTextTypeWithDefaults(i2);
            return;
        }
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            d0Var.l(i2);
        }
    }

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

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

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

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

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

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

    @Override // android.widget.TextView
    public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(c.f.b.h.L(this, callback));
    }

    public void setEmojiCompatEnabled(boolean z) {
        getEmojiTextViewHelper().f928b.a.c(z);
    }

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

    @Override // android.widget.TextView
    public void setFirstBaselineToTopHeight(int i2) {
        if (Build.VERSION.SDK_INT >= 28) {
            getSuperCaller().b(i2);
        } else {
            c.f.b.h.C(this, i2);
        }
    }

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

    @Override // android.widget.TextView
    public void setLineHeight(int i2) {
        c.f.b.h.E(this, i2);
    }

    public void setPrecomputedText(c.f.h.b bVar) {
        c.f.b.h.F(this, bVar);
    }

    public void setSupportBackgroundTintList(ColorStateList colorStateList) {
        g gVar = this.f817b;
        if (gVar != null) {
            gVar.h(colorStateList);
        }
    }

    public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
        g gVar = this.f817b;
        if (gVar != null) {
            gVar.i(mode);
        }
    }

    public void setSupportCompoundDrawablesTintList(ColorStateList colorStateList) {
        this.f818e.m(colorStateList);
        this.f818e.b();
    }

    public void setSupportCompoundDrawablesTintMode(PorterDuff.Mode mode) {
        this.f818e.n(mode);
        this.f818e.b();
    }

    @Override // android.widget.TextView
    public void setTextAppearance(Context context, int i2) {
        super.setTextAppearance(context, i2);
        d0 d0Var = this.f818e;
        if (d0Var != null) {
            d0Var.h(context, i2);
        }
    }

    @Override // android.widget.TextView
    public void setTextClassifier(TextClassifier textClassifier) {
        c0 c0Var;
        if (Build.VERSION.SDK_INT >= 28 || (c0Var = this.f819f) == null) {
            super.setTextClassifier(textClassifier);
        } else {
            c0Var.f781b = textClassifier;
        }
    }

    public void setTextFuture(Future<c.f.h.b> future) {
        this.f823j = future;
        if (future != null) {
            requestLayout();
        }
    }

    public void setTextMetricsParamsCompat(b.a aVar) {
        TextDirectionHeuristic textDirectionHeuristic = aVar.f1386b;
        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;
            }
        }
        c.f.k.l.h(this, i2);
        getPaint().set(aVar.a);
        c.f.k.m.e(this, aVar.f1387c);
        c.f.k.m.h(this, aVar.f1388d);
    }

    @Override // android.widget.TextView
    public void setTextSize(int i2, float f2) {
        boolean z = i1.f864b;
        if (z) {
            super.setTextSize(i2, f2);
            return;
        }
        d0 d0Var = this.f818e;
        if (d0Var == null || z || d0Var.f()) {
            return;
        }
        d0Var.f799i.f(i2, f2);
    }

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public f0(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        a1.a(context);
        this.f821h = false;
        this.f822i = null;
        y0.a(this, getContext());
        g gVar = new g(this);
        this.f817b = gVar;
        gVar.d(attributeSet, i2);
        d0 d0Var = new d0(this);
        this.f818e = d0Var;
        d0Var.g(attributeSet, i2);
        d0Var.b();
        this.f819f = new c0(this);
        getEmojiTextViewHelper().a(attributeSet, i2);
    }

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

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