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.text.TextDirectionHeuristic;
import android.text.TextDirectionHeuristics;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.view.textclassifier.TextClassifier;
import android.widget.TextView;
import androidx.annotation.DrawableRes;
import androidx.annotation.FloatRange;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.core.view.x0;
import androidx.core.view.z0;
import j0.i;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import l.a1;
import l.b1;
import l.c1;
import l.d1;
import l.e1;
import l.f0;
import l.f4;
import l.j1;
import l.l3;
import l.m3;
import l.u0;
import l.y;
import o0.f;
import u0.p;
import u0.t;

/* JADX INFO: loaded from: classes.dex */
public class AppCompatTextView extends TextView implements x0, t {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final y f690a;

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public f0 f693d;

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

    @Nullable
    private Future<f> mPrecomputedTextFuture;

    @Nullable
    private b1 mSuperCaller;

    public AppCompatTextView(@NonNull Context context) {
        this(context, null);
    }

    @NonNull
    private f0 getEmojiTextViewHelper() {
        if (this.f693d == null) {
            this.f693d = new f0(this);
        }
        return this.f693d;
    }

    @Override // android.widget.TextView, android.view.View
    public final void drawableStateChanged() {
        super.drawableStateChanged();
        y yVar = this.f690a;
        if (yVar != null) {
            yVar.a();
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.b();
        }
    }

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public int getAutoSizeMaxTextSize() {
        if (f4.f29684c) {
            return super.getAutoSizeMaxTextSize();
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            return Math.round(a1Var.f29612i.f29739e);
        }
        return -1;
    }

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public int getAutoSizeMinTextSize() {
        if (f4.f29684c) {
            return super.getAutoSizeMinTextSize();
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            return Math.round(a1Var.f29612i.f29738d);
        }
        return -1;
    }

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public int getAutoSizeStepGranularity() {
        if (f4.f29684c) {
            return super.getAutoSizeStepGranularity();
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            return Math.round(a1Var.f29612i.f29737c);
        }
        return -1;
    }

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public int[] getAutoSizeTextAvailableSizes() {
        if (f4.f29684c) {
            return super.getAutoSizeTextAvailableSizes();
        }
        a1 a1Var = this.f691b;
        return a1Var != null ? a1Var.f29612i.f29740f : new int[0];
    }

    @Override // android.widget.TextView
    @SuppressLint({"WrongConstant"})
    @RestrictTo({RestrictTo.Scope.f557c})
    public int getAutoSizeTextType() {
        if (f4.f29684c) {
            return super.getAutoSizeTextType() == 1 ? 1 : 0;
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            return a1Var.f29612i.f29735a;
        }
        return 0;
    }

    @Override // android.widget.TextView
    @Nullable
    public ActionMode.Callback getCustomSelectionActionModeCallback() {
        return p.unwrapCustomSelectionActionModeCallback(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;
    }

    @RequiresApi(api = 26)
    @UiThread
    public b1 getSuperCaller() {
        if (this.mSuperCaller == null) {
            int i10 = Build.VERSION.SDK_INT;
            if (i10 >= 34) {
                this.mSuperCaller = new e1(this);
            } else if (i10 >= 28) {
                this.mSuperCaller = new d1(this);
            } else if (i10 >= 26) {
                this.mSuperCaller = new c1(this);
            }
        }
        return this.mSuperCaller;
    }

    @Override // androidx.core.view.x0
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public ColorStateList getSupportBackgroundTintList() {
        y yVar = this.f690a;
        if (yVar != null) {
            return yVar.b();
        }
        return null;
    }

    @Override // androidx.core.view.x0
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public PorterDuff.Mode getSupportBackgroundTintMode() {
        y yVar = this.f690a;
        if (yVar != null) {
            return yVar.c();
        }
        return null;
    }

    @Override // u0.t
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public ColorStateList getSupportCompoundDrawablesTintList() {
        return this.f691b.getCompoundDrawableTintList();
    }

    @Override // u0.t
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public PorterDuff.Mode getSupportCompoundDrawablesTintMode() {
        return this.f691b.getCompoundDrawableTintMode();
    }

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

    @Override // android.widget.TextView
    @NonNull
    @RequiresApi(api = 26)
    public TextClassifier getTextClassifier() {
        u0 u0Var;
        return (Build.VERSION.SDK_INT >= 28 || (u0Var = this.f692c) == null) ? super.getTextClassifier() : u0Var.a();
    }

    @NonNull
    public o0.c getTextMetricsParamsCompat() {
        return p.a(this);
    }

    public final void n() {
        Future<f> future = this.mPrecomputedTextFuture;
        if (future != null) {
            try {
                this.mPrecomputedTextFuture = null;
                p.e(this, future.get());
            } catch (InterruptedException | ExecutionException unused) {
            }
        }
    }

    @Override // android.widget.TextView, android.view.View
    public final InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        InputConnection inputConnectionOnCreateInputConnection = super.onCreateInputConnection(editorInfo);
        this.f691b.populateSurroundingTextIfNeeded(this, inputConnectionOnCreateInputConnection, editorInfo);
        kotlinx.coroutines.y.Q(this, editorInfo, inputConnectionOnCreateInputConnection);
        return inputConnectionOnCreateInputConnection;
    }

    @Override // android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        int i10 = Build.VERSION.SDK_INT;
        if (i10 < 30 || i10 >= 33 || !onCheckIsTextEditor()) {
            return;
        }
        ((InputMethodManager) getContext().getSystemService("input_method")).isActive(this);
    }

    @Override // android.widget.TextView, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        super.onLayout(z10, i10, i11, i12, i13);
        a1 a1Var = this.f691b;
        if (a1Var == null || f4.f29684c) {
            return;
        }
        a1Var.f29612i.a();
    }

    @Override // android.widget.TextView, android.view.View
    public void onMeasure(int i10, int i11) {
        n();
        super.onMeasure(i10, i11);
    }

    @Override // android.widget.TextView
    public final void onTextChanged(CharSequence charSequence, int i10, int i11, int i12) {
        super.onTextChanged(charSequence, i10, i11, i12);
        a1 a1Var = this.f691b;
        if (a1Var == null || f4.f29684c) {
            return;
        }
        j1 j1Var = a1Var.f29612i;
        if (j1Var.e()) {
            j1Var.a();
        }
    }

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

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setAutoSizeTextTypeUniformWithConfiguration(int i10, int i11, int i12, int i13) throws IllegalArgumentException {
        if (f4.f29684c) {
            super.setAutoSizeTextTypeUniformWithConfiguration(i10, i11, i12, i13);
            return;
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.e(i10, i11, i12, i13);
        }
    }

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setAutoSizeTextTypeUniformWithPresetSizes(@NonNull int[] iArr, int i10) throws IllegalArgumentException {
        if (f4.f29684c) {
            super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i10);
            return;
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.f(iArr, i10);
        }
    }

    @Override // android.widget.TextView
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setAutoSizeTextTypeWithDefaults(int i10) {
        if (f4.f29684c) {
            super.setAutoSizeTextTypeWithDefaults(i10);
            return;
        }
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.g(i10);
        }
    }

    @Override // android.view.View
    public void setBackgroundDrawable(@Nullable Drawable drawable) {
        super.setBackgroundDrawable(drawable);
        y yVar = this.f690a;
        if (yVar != null) {
            yVar.d();
        }
    }

    @Override // android.view.View
    public void setBackgroundResource(@DrawableRes int i10) {
        super.setBackgroundResource(i10);
        y yVar = this.f690a;
        if (yVar != null) {
            yVar.e(i10);
        }
    }

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

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

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

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

    @Override // android.widget.TextView
    public void setCustomSelectionActionModeCallback(@Nullable ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(p.wrapCustomSelectionActionModeCallback(this, callback));
    }

    public void setEmojiCompatEnabled(boolean z10) {
        getEmojiTextViewHelper().c(z10);
    }

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

    @Override // android.widget.TextView
    public void setFirstBaselineToTopHeight(@IntRange(from = 0) @Px int i10) {
        if (Build.VERSION.SDK_INT >= 28) {
            getSuperCaller().b(i10);
        } else {
            p.b(this, i10);
        }
    }

    @Override // android.widget.TextView
    public void setLastBaselineToBottomHeight(@IntRange(from = 0) @Px int i10) {
        if (Build.VERSION.SDK_INT >= 28) {
            getSuperCaller().a(i10);
        } else {
            p.c(this, i10);
        }
    }

    @Override // android.widget.TextView
    public void setLineHeight(@IntRange(from = 0) @Px int i10) {
        p.d(this, i10);
    }

    public void setPrecomputedText(@NonNull f fVar) {
        p.e(this, fVar);
    }

    @Override // androidx.core.view.x0
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportBackgroundTintList(@Nullable ColorStateList colorStateList) {
        y yVar = this.f690a;
        if (yVar != null) {
            yVar.g(colorStateList);
        }
    }

    @Override // androidx.core.view.x0
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode mode) {
        y yVar = this.f690a;
        if (yVar != null) {
            yVar.h(mode);
        }
    }

    @Override // u0.t
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportCompoundDrawablesTintList(@Nullable ColorStateList colorStateList) {
        a1 a1Var = this.f691b;
        a1Var.setCompoundDrawableTintList(colorStateList);
        a1Var.b();
    }

    @Override // u0.t
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportCompoundDrawablesTintMode(@Nullable PorterDuff.Mode mode) {
        a1 a1Var = this.f691b;
        a1Var.setCompoundDrawableTintMode(mode);
        a1Var.b();
    }

    @Override // android.widget.TextView
    public void setTextAppearance(Context context, int i10) {
        super.setTextAppearance(context, i10);
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.d(context, i10);
        }
    }

    @Override // android.widget.TextView
    @RequiresApi(api = 26)
    public void setTextClassifier(@Nullable TextClassifier textClassifier) {
        u0 u0Var;
        if (Build.VERSION.SDK_INT >= 28 || (u0Var = this.f692c) == null) {
            ((c1) getSuperCaller()).setTextClassifier(textClassifier);
        } else {
            u0Var.setTextClassifier(textClassifier);
        }
    }

    public void setTextFuture(@Nullable Future<f> future) {
        this.mPrecomputedTextFuture = future;
        if (future != null) {
            requestLayout();
        }
    }

    public void setTextMetricsParamsCompat(@NonNull o0.c cVar) {
        TextDirectionHeuristic textDirectionHeuristic;
        TextDirectionHeuristic textDirection = cVar.getTextDirection();
        TextDirectionHeuristic textDirectionHeuristic2 = TextDirectionHeuristics.FIRSTSTRONG_RTL;
        int i10 = 1;
        if (textDirection != textDirectionHeuristic2 && textDirection != (textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_LTR)) {
            if (textDirection == TextDirectionHeuristics.ANYRTL_LTR) {
                i10 = 2;
            } else if (textDirection == TextDirectionHeuristics.LTR) {
                i10 = 3;
            } else if (textDirection == TextDirectionHeuristics.RTL) {
                i10 = 4;
            } else if (textDirection == TextDirectionHeuristics.LOCALE) {
                i10 = 5;
            } else if (textDirection == textDirectionHeuristic) {
                i10 = 6;
            } else if (textDirection == textDirectionHeuristic2) {
                i10 = 7;
            }
        }
        setTextDirection(i10);
        getPaint().set(cVar.f31265a);
        setBreakStrategy(cVar.f31266b);
        setHyphenationFrequency(cVar.f31267c);
    }

    @Override // android.widget.TextView
    public void setTextSize(int i10, float f10) {
        boolean z10 = f4.f29684c;
        if (z10) {
            super.setTextSize(i10, f10);
            return;
        }
        a1 a1Var = this.f691b;
        if (a1Var == null || z10) {
            return;
        }
        j1 j1Var = a1Var.f29612i;
        if (j1Var.e()) {
            return;
        }
        j1Var.f(f10, i10);
    }

    @Override // android.widget.TextView
    public void setTypeface(@Nullable Typeface typeface, int i10) {
        if (this.f694e) {
            return;
        }
        Typeface typefaceCreate = (typeface == null || i10 <= 0) ? null : i.create(getContext(), typeface, i10);
        this.f694e = true;
        if (typefaceCreate != null) {
            typeface = typefaceCreate;
        }
        try {
            super.setTypeface(typeface, i10);
        } finally {
            this.f694e = false;
        }
    }

    public AppCompatTextView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, R.attr.textViewStyle);
    }

    @Override // android.widget.TextView
    public void setLineHeight(int i10, @FloatRange(from = 0.0d) float f10) {
        int i11 = Build.VERSION.SDK_INT;
        if (i11 >= 34) {
            getSuperCaller().c(i10, f10);
        } else if (i11 >= 34) {
            z0.i(this, i10, f10);
        } else {
            p.d(this, Math.round(TypedValue.applyDimension(i10, f10, getResources().getDisplayMetrics())));
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public AppCompatTextView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        m3.a(context);
        this.f694e = false;
        this.mSuperCaller = null;
        l3.a(getContext(), this);
        y yVar = new y(this);
        this.f690a = yVar;
        yVar.loadFromAttributes(attributeSet, i10);
        a1 a1Var = new a1(this);
        this.f691b = a1Var;
        a1Var.loadFromAttributes(attributeSet, i10);
        a1Var.b();
        this.f692c = new u0(this);
        getEmojiTextViewHelper().loadFromAttributes(attributeSet, i10);
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesRelativeWithIntrinsicBounds(int i10, int i11, int i12, int i13) {
        Context context = getContext();
        setCompoundDrawablesRelativeWithIntrinsicBounds(i10 != 0 ? f.a.getDrawable(context, i10) : null, i11 != 0 ? f.a.getDrawable(context, i11) : null, i12 != 0 ? f.a.getDrawable(context, i12) : null, i13 != 0 ? f.a.getDrawable(context, i13) : null);
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.b();
        }
    }

    @Override // android.widget.TextView
    public void setCompoundDrawablesWithIntrinsicBounds(int i10, int i11, int i12, int i13) {
        Context context = getContext();
        setCompoundDrawablesWithIntrinsicBounds(i10 != 0 ? f.a.getDrawable(context, i10) : null, i11 != 0 ? f.a.getDrawable(context, i11) : null, i12 != 0 ? f.a.getDrawable(context, i12) : null, i13 != 0 ? f.a.getDrawable(context, i13) : null);
        a1 a1Var = this.f691b;
        if (a1Var != null) {
            a1Var.b();
        }
    }
}
