package defpackage;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.TextView;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/* renamed from: ᵞˏٴˈ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2956 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public C1894 f11442;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public Typeface f11443;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public C1894 f11444;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public C1894 f11445;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public C1894 f11446;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final C1719 f11447;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final TextView f11448;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public boolean f11449;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public C1894 f11451;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public C1894 f11454;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public C1894 f11455;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public int f11452 = 0;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public int f11453 = -1;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public String f11450 = null;

    public C2956(TextView textView) {
        this.f11448 = textView;
        this.f11447 = new C1719(textView);
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static C1894 m7231(Context context, C3159 c3159, int i) {
        ColorStateList colorStateListM5501;
        synchronized (c3159) {
            colorStateListM5501 = c3159.f11991.m5501(context, i);
        }
        if (colorStateListM5501 == null) {
            return null;
        }
        C1894 c1894 = new C1894();
        c1894.f7630 = true;
        c1894.f7628 = colorStateListM5501;
        return c1894;
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public static void m7232(EditorInfo editorInfo, InputConnection inputConnection, TextView textView) {
        int i = Build.VERSION.SDK_INT;
        if (i >= 30 || inputConnection == null) {
            return;
        }
        CharSequence text = textView.getText();
        if (i >= 30) {
            AbstractC1674.m4805(editorInfo, text);
            return;
        }
        text.getClass();
        if (i >= 30) {
            AbstractC1674.m4805(editorInfo, text);
            return;
        }
        int i2 = editorInfo.initialSelStart;
        int i3 = editorInfo.initialSelEnd;
        int i4 = i2 > i3 ? i3 : i2;
        if (i2 <= i3) {
            i2 = i3;
        }
        int length = text.length();
        if (i4 < 0 || i2 > length) {
            AbstractC3213.m7567(editorInfo, null, 0, 0);
            return;
        }
        int i5 = editorInfo.inputType & 4095;
        if (i5 == 129 || i5 == 225 || i5 == 18) {
            AbstractC3213.m7567(editorInfo, null, 0, 0);
            return;
        }
        if (length <= 2048) {
            AbstractC3213.m7567(editorInfo, text, i4, i2);
            return;
        }
        int i6 = i2 - i4;
        int i7 = i6 > 1024 ? 0 : i6;
        int i8 = 2048 - i7;
        int iMin = Math.min(text.length() - i2, i8 - Math.min(i4, (int) (i8 * 0.8d)));
        int iMin2 = Math.min(i4, i8 - iMin);
        int i9 = i4 - iMin2;
        if (Character.isLowSurrogate(text.charAt(i9))) {
            i9++;
            iMin2--;
        }
        if (Character.isHighSurrogate(text.charAt((i2 + iMin) - 1))) {
            iMin--;
        }
        int i10 = iMin2 + i7;
        AbstractC3213.m7567(editorInfo, i7 != i6 ? TextUtils.concat(text.subSequence(i9, i9 + iMin2), text.subSequence(i2, iMin + i2)) : text.subSequence(i9, i10 + iMin + i9), iMin2, i10);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static void m7233(TextView textView, Typeface typeface, int i) {
        int i2 = Build.VERSION.SDK_INT;
        String str = null;
        if (i2 >= 26) {
            String strM5777 = AbstractC2151.m5777(textView);
            if (!TextUtils.isEmpty(strM5777)) {
                AbstractC2151.m5774(textView, null);
            }
            str = strM5777;
        }
        textView.setTypeface(typeface, i);
        if (i2 < 26 || TextUtils.isEmpty(str)) {
            return;
        }
        AbstractC2151.m5774(textView, str);
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final boolean m7234(Context context, C1570 c1570) {
        String string;
        int i;
        Typeface typeface;
        int i2 = this.f11452;
        TypedArray typedArray = (TypedArray) c1570.f6230;
        this.f11452 = typedArray.getInt(2, i2);
        int i3 = Build.VERSION.SDK_INT;
        if (i3 >= 28) {
            int i4 = typedArray.getInt(11, -1);
            this.f11453 = i4;
            if (i4 != -1) {
                this.f11452 &= 2;
            }
        }
        if (i3 >= 26 && typedArray.hasValue(13)) {
            this.f11450 = typedArray.getString(13);
        }
        if (typedArray.hasValue(10) || typedArray.hasValue(12)) {
            this.f11443 = null;
            int i5 = typedArray.hasValue(12) ? 12 : 10;
            int i6 = this.f11453;
            int i7 = this.f11452;
            if (!context.isRestricted()) {
                WeakReference weakReference = new WeakReference(this.f11448);
                C3959 c3959 = new C3959();
                c3959.f14937 = this;
                c3959.f14936 = i6;
                c3959.f14935 = i7;
                c3959.f14938 = weakReference;
                try {
                    Typeface typefaceM4547 = c1570.m4547(i5, this.f11452, c3959);
                    if (typefaceM4547 != null) {
                        if (i3 < 28 || this.f11453 == -1) {
                            this.f11443 = typefaceM4547;
                        } else {
                            this.f11443 = AbstractC3502.m7998(Typeface.create(typefaceM4547, 0), this.f11453, (this.f11452 & 2) != 0);
                        }
                    }
                    this.f11449 = this.f11443 == null;
                } catch (Resources.NotFoundException | UnsupportedOperationException unused) {
                }
            }
            if (this.f11443 == null && (string = typedArray.getString(i5)) != null) {
                if (Build.VERSION.SDK_INT < 28 || this.f11453 == -1) {
                    this.f11443 = Typeface.create(string, this.f11452);
                } else {
                    this.f11443 = AbstractC3502.m7998(Typeface.create(string, 0), this.f11453, (this.f11452 & 2) != 0);
                }
            }
        } else {
            if (!typedArray.hasValue(1)) {
                if (i3 < 28 || (i = this.f11453) == -1 || (typeface = this.f11443) == null) {
                    return false;
                }
                this.f11443 = AbstractC3502.m7998(typeface, i, (this.f11452 & 2) != 0);
                return true;
            }
            this.f11449 = false;
            int i8 = typedArray.getInt(1, 1);
            if (i8 == 1) {
                this.f11443 = Typeface.SANS_SERIF;
                return true;
            }
            if (i8 == 2) {
                this.f11443 = Typeface.SERIF;
                return true;
            }
            if (i8 == 3) {
                this.f11443 = Typeface.MONOSPACE;
                return true;
            }
        }
        return true;
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m7235(int[] iArr, int i) {
        C1719 c1719 = this.f11447;
        if (c1719.m4913()) {
            int length = iArr.length;
            if (length > 0) {
                int[] iArrCopyOf = new int[length];
                if (i == 0) {
                    iArrCopyOf = Arrays.copyOf(iArr, length);
                } else {
                    DisplayMetrics displayMetrics = c1719.f6852.getResources().getDisplayMetrics();
                    for (int i2 = 0; i2 < length; i2++) {
                        iArrCopyOf[i2] = Math.round(TypedValue.applyDimension(i, iArr[i2], displayMetrics));
                    }
                }
                c1719.f6847 = C1719.m4907(iArrCopyOf);
                if (!c1719.m4916()) {
                    C5562.m11196(Arrays.toString(iArr), "None of the preset sizes is valid: ");
                    return;
                }
            } else {
                c1719.f6846 = false;
            }
            if (c1719.m4910()) {
                c1719.m4914();
            }
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final PorterDuff.Mode m7236() {
        C1894 c1894 = this.f11454;
        if (c1894 != null) {
            return (PorterDuff.Mode) c1894.f7631;
        }
        return null;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final ColorStateList m7237() {
        C1894 c1894 = this.f11454;
        if (c1894 != null) {
            return (ColorStateList) c1894.f7628;
        }
        return null;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m7238(boolean z) {
        Typeface typeface = this.f11443;
        TextView textView = this.f11448;
        if (typeface != null) {
            if (this.f11453 == -1) {
                textView.setTypeface(typeface, this.f11452);
            } else {
                textView.setTypeface(typeface);
            }
        } else if (z) {
            textView.setTypeface(null);
        }
        String str = this.f11450;
        if (str == null || Build.VERSION.SDK_INT < 26) {
            return;
        }
        AbstractC2151.m5774(textView, str);
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final void m7239(Context context, int i) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(i, AbstractC0542.f2814);
        C1570 c1570 = new C1570(context, typedArrayObtainStyledAttributes);
        boolean zHasValue = typedArrayObtainStyledAttributes.hasValue(14);
        TextView textView = this.f11448;
        if (zHasValue) {
            textView.setAllCaps(typedArrayObtainStyledAttributes.getBoolean(14, false));
        }
        if (typedArrayObtainStyledAttributes.hasValue(0) && typedArrayObtainStyledAttributes.getDimensionPixelSize(0, -1) == 0) {
            textView.setTextSize(0, 0.0f);
        }
        boolean zM7234 = m7234(context, c1570);
        c1570.m4542();
        m7238(zM7234);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m7240(Drawable drawable, C1894 c1894) {
        if (drawable == null || c1894 == null) {
            return;
        }
        C3159.m7513(drawable, c1894, this.f11448.getDrawableState());
    }

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public final void m7241(ColorStateList colorStateList) {
        if (this.f11454 == null) {
            this.f11454 = new C1894();
        }
        C1894 c1894 = this.f11454;
        c1894.f7628 = colorStateList;
        c1894.f7630 = colorStateList != null;
        this.f11451 = c1894;
        this.f11446 = c1894;
        this.f11455 = c1894;
        this.f11442 = c1894;
        this.f11445 = c1894;
        this.f11444 = c1894;
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void m7242(int i) {
        C1719 c1719 = this.f11447;
        if (c1719.m4913()) {
            if (i == 0) {
                c1719.f6850 = 0;
                c1719.f6855 = -1.0f;
                c1719.f6845 = -1.0f;
                c1719.f6848 = -1.0f;
                c1719.f6847 = new int[0];
                c1719.f6851 = false;
                return;
            }
            if (i != 1) {
                ᵹˉᵞ.ˌᵜᵹᵩ(AbstractC2990.m7313(i, "Unknown auto-size text type: "));
                return;
            }
            DisplayMetrics displayMetrics = c1719.f6852.getResources().getDisplayMetrics();
            c1719.m4915(TypedValue.applyDimension(2, 12.0f, displayMetrics), TypedValue.applyDimension(2, 112.0f, displayMetrics), 1.0f);
            if (c1719.m4910()) {
                c1719.m4914();
            }
        }
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public final void m7243(PorterDuff.Mode mode) {
        if (this.f11454 == null) {
            this.f11454 = new C1894();
        }
        C1894 c1894 = this.f11454;
        c1894.f7631 = mode;
        c1894.f7629 = mode != null;
        this.f11451 = c1894;
        this.f11446 = c1894;
        this.f11455 = c1894;
        this.f11442 = c1894;
        this.f11445 = c1894;
        this.f11444 = c1894;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m7244() {
        C1894 c1894 = this.f11451;
        TextView textView = this.f11448;
        if (c1894 != null || this.f11446 != null || this.f11455 != null || this.f11442 != null) {
            Drawable[] compoundDrawables = textView.getCompoundDrawables();
            m7240(compoundDrawables[0], this.f11451);
            m7240(compoundDrawables[1], this.f11446);
            m7240(compoundDrawables[2], this.f11455);
            m7240(compoundDrawables[3], this.f11442);
        }
        if (this.f11445 == null && this.f11444 == null) {
            return;
        }
        Drawable[] compoundDrawablesRelative = textView.getCompoundDrawablesRelative();
        m7240(compoundDrawablesRelative[0], this.f11445);
        m7240(compoundDrawablesRelative[2], this.f11444);
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m7245(int i, int i2, int i3, int i4) {
        C1719 c1719 = this.f11447;
        if (c1719.m4913()) {
            DisplayMetrics displayMetrics = c1719.f6852.getResources().getDisplayMetrics();
            c1719.m4915(TypedValue.applyDimension(i4, i, displayMetrics), TypedValue.applyDimension(i4, i2, displayMetrics), TypedValue.applyDimension(i4, i3, displayMetrics));
            if (c1719.m4910()) {
                c1719.m4914();
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:219:0x0385  */
    /* JADX WARN: Removed duplicated region for block: B:221:0x038a  */
    /* JADX WARN: Removed duplicated region for block: B:224:0x0391  */
    /* JADX WARN: Removed duplicated region for block: B:234:? A[RETURN, SYNTHETIC] */
    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m7246(android.util.AttributeSet r24, int r25) {
        /*
            Method dump skipped, instructions count: 950
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C2956.m7246(android.util.AttributeSet, int):void");
    }
}
