package androidx.appcompat.widget;

import android.R;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.InputFilter;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.TransformationMethod;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.CompoundButton;
import defpackage.AbstractC0430;
import defpackage.AbstractC0912;
import defpackage.AbstractC1630;
import defpackage.AbstractC2340;
import defpackage.AbstractC2514;
import defpackage.AbstractC2746;
import defpackage.C0180;
import defpackage.C0645;
import defpackage.C0909;
import defpackage.C2176;
import defpackage.C2938;
import defpackage.C3880;
import defpackage.C4832;
import defpackage.C5398;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes3.dex */
public class SwitchCompat extends CompoundButton {

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public final int f170;

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public int f171;

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public int f172;

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public int f173;

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public CharSequence f174;

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public float f175;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public boolean f176;

    /* JADX INFO: renamed from: ˁᵺˈ, reason: contains not printable characters */
    public final TextPaint f177;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public ColorStateList f178;

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public float f179;

    /* JADX INFO: renamed from: ˉˆᵗ, reason: contains not printable characters */
    public boolean f180;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public int f181;

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public final int f182;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public CharSequence f183;

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public CharSequence f184;

    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    public int f185;

    /* JADX INFO: renamed from: ˋᵯᵩ, reason: contains not printable characters */
    public final ColorStateList f186;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public Drawable f187;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public PorterDuff.Mode f188;

    /* JADX INFO: renamed from: ˏʜᵪ, reason: contains not printable characters */
    public final Rect f189;

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public int f190;

    /* JADX INFO: renamed from: ːᵝٴᵶ, reason: contains not printable characters */
    public StaticLayout f191;

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public int f192;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public boolean f193;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public PorterDuff.Mode f194;

    /* JADX INFO: renamed from: ᵗᵭ, reason: contains not printable characters */
    public final C2176 f195;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public int f196;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public CharSequence f197;

    /* JADX INFO: renamed from: ᵜᵤ, reason: contains not printable characters */
    public StaticLayout f198;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public ColorStateList f199;

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public final VelocityTracker f200;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public int f201;

    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    public int f202;

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public int f203;

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public float f204;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public boolean f205;

    /* JADX INFO: renamed from: ᵫˈᵹ, reason: contains not printable characters */
    public ObjectAnimator f206;

    /* JADX INFO: renamed from: ᵬᵦˋ, reason: contains not printable characters */
    public C4832 f207;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public boolean f208;

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public boolean f209;

    /* JADX INFO: renamed from: ᵵᵸᵕᵸ, reason: contains not printable characters */
    public C0909 f210;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public Drawable f211;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public boolean f212;

    /* JADX INFO: renamed from: ᵘᵝ, reason: contains not printable characters */
    public static final C0645 f169 = new C0645(Float.class, "thumbPos", 11);

    /* JADX INFO: renamed from: ˆʤᵳ, reason: contains not printable characters */
    public static final int[] f168 = {R.attr.state_checked};

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

    public SwitchCompat(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, ar.tvplayer.tv.R.attr.h);
    }

    public SwitchCompat(Context context, AttributeSet attributeSet, int i) {
        int resourceId;
        super(context, attributeSet, i);
        this.f199 = null;
        this.f194 = null;
        this.f205 = false;
        this.f208 = false;
        this.f178 = null;
        this.f188 = null;
        this.f212 = false;
        this.f193 = false;
        this.f200 = VelocityTracker.obtain();
        this.f180 = true;
        this.f189 = new Rect();
        AbstractC2340.m6017(getContext(), this);
        TextPaint textPaint = new TextPaint(1);
        this.f177 = textPaint;
        textPaint.density = getResources().getDisplayMetrics().density;
        int[] iArr = AbstractC0430.f2383;
        C5398 c5398M11010 = C5398.m11010(context, attributeSet, iArr, i);
        TypedArray typedArray = (TypedArray) c5398M11010.f20483;
        AbstractC2746.m6646(this, context, iArr, attributeSet, typedArray, i);
        Drawable drawableM11017 = c5398M11010.m11017(2);
        this.f187 = drawableM11017;
        if (drawableM11017 != null) {
            drawableM11017.setCallback(this);
        }
        Drawable drawableM110172 = c5398M11010.m11017(11);
        this.f211 = drawableM110172;
        if (drawableM110172 != null) {
            drawableM110172.setCallback(this);
        }
        setTextOnInternal(typedArray.getText(0));
        setTextOffInternal(typedArray.getText(1));
        this.f209 = typedArray.getBoolean(3, true);
        this.f171 = typedArray.getDimensionPixelSize(8, 0);
        this.f201 = typedArray.getDimensionPixelSize(5, 0);
        this.f181 = typedArray.getDimensionPixelSize(6, 0);
        this.f176 = typedArray.getBoolean(4, false);
        ColorStateList colorStateListM11016 = c5398M11010.m11016(9);
        if (colorStateListM11016 != null) {
            this.f199 = colorStateListM11016;
            this.f205 = true;
        }
        PorterDuff.Mode modeM3159 = AbstractC0912.m3159(typedArray.getInt(10, -1), null);
        if (this.f194 != modeM3159) {
            this.f194 = modeM3159;
            this.f208 = true;
        }
        if (this.f205 || this.f208) {
            m40();
        }
        ColorStateList colorStateListM110162 = c5398M11010.m11016(12);
        if (colorStateListM110162 != null) {
            this.f178 = colorStateListM110162;
            this.f212 = true;
        }
        PorterDuff.Mode modeM31592 = AbstractC0912.m3159(typedArray.getInt(13, -1), null);
        if (this.f188 != modeM31592) {
            this.f188 = modeM31592;
            this.f193 = true;
        }
        if (this.f212 || this.f193) {
            m38();
        }
        int resourceId2 = typedArray.getResourceId(7, 0);
        if (resourceId2 != 0) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(resourceId2, AbstractC0430.f2387);
            ColorStateList colorStateList = (!typedArrayObtainStyledAttributes.hasValue(3) || (resourceId = typedArrayObtainStyledAttributes.getResourceId(3, 0)) == 0 || (colorStateList = AbstractC1630.m4515(context, resourceId)) == null) ? typedArrayObtainStyledAttributes.getColorStateList(3) : colorStateList;
            if (colorStateList != null) {
                this.f186 = colorStateList;
            } else {
                this.f186 = getTextColors();
            }
            int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, 0);
            if (dimensionPixelSize != 0) {
                float f = dimensionPixelSize;
                if (f != textPaint.getTextSize()) {
                    textPaint.setTextSize(f);
                    requestLayout();
                }
            }
            int i2 = typedArrayObtainStyledAttributes.getInt(1, -1);
            int i3 = typedArrayObtainStyledAttributes.getInt(2, -1);
            Typeface typeface = i2 != 1 ? i2 != 2 ? i2 != 3 ? null : Typeface.MONOSPACE : Typeface.SERIF : Typeface.SANS_SERIF;
            if (i3 > 0) {
                Typeface typefaceDefaultFromStyle = typeface == null ? Typeface.defaultFromStyle(i3) : Typeface.create(typeface, i3);
                setSwitchTypeface(typefaceDefaultFromStyle);
                int i4 = (~(typefaceDefaultFromStyle != null ? typefaceDefaultFromStyle.getStyle() : 0)) & i3;
                textPaint.setFakeBoldText((i4 & 1) != 0);
                textPaint.setTextSkewX((2 & i4) != 0 ? -0.25f : 0.0f);
            } else {
                textPaint.setFakeBoldText(false);
                textPaint.setTextSkewX(0.0f);
                setSwitchTypeface(typeface);
            }
            if (typedArrayObtainStyledAttributes.getBoolean(14, false)) {
                Context context2 = getContext();
                C2176 c2176 = new C2176();
                c2176.f8672 = context2.getResources().getConfiguration().locale;
                this.f195 = c2176;
            } else {
                this.f195 = null;
            }
            setTextOnInternal(this.f174);
            setTextOffInternal(this.f183);
            typedArrayObtainStyledAttributes.recycle();
        }
        new C2938(this).m7013(attributeSet, i);
        c5398M11010.m11012();
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        this.f170 = viewConfiguration.getScaledTouchSlop();
        this.f182 = viewConfiguration.getScaledMinimumFlingVelocity();
        getEmojiTextViewHelper().m3154(attributeSet, i);
        refreshDrawableState();
        setChecked(isChecked());
    }

    private C0909 getEmojiTextViewHelper() {
        if (this.f210 == null) {
            this.f210 = new C0909(this);
        }
        return this.f210;
    }

    private boolean getTargetCheckedState() {
        return this.f175 > 0.5f;
    }

    private int getThumbOffset() {
        boolean z = AbstractC2514.f9717;
        int layoutDirection = getLayoutDirection();
        float f = this.f175;
        if (layoutDirection == 1) {
            f = 1.0f - f;
        }
        return (int) ((f * getThumbScrollRange()) + 0.5f);
    }

    private int getThumbScrollRange() {
        Drawable drawable = this.f211;
        if (drawable == null) {
            return 0;
        }
        Rect rect = this.f189;
        drawable.getPadding(rect);
        Drawable drawable2 = this.f187;
        Rect rectM3158 = drawable2 != null ? AbstractC0912.m3158(drawable2) : AbstractC0912.f4003;
        return ((((this.f173 - this.f196) - rect.left) - rect.right) - rectM3158.left) - rectM3158.right;
    }

    private void setTextOffInternal(CharSequence charSequence) {
        this.f183 = charSequence;
        TransformationMethod transformationMethod = ((ᵶᵦ) getEmojiTextViewHelper().f3997.f4404).ˉᵵᵜ(this.f195);
        if (transformationMethod != null) {
            charSequence = transformationMethod.getTransformation(charSequence, this);
        }
        this.f197 = charSequence;
        this.f191 = null;
        if (this.f209) {
            m41();
        }
    }

    private void setTextOnInternal(CharSequence charSequence) {
        this.f174 = charSequence;
        TransformationMethod transformationMethod = ((ᵶᵦ) getEmojiTextViewHelper().f3997.f4404).ˉᵵᵜ(this.f195);
        if (transformationMethod != null) {
            charSequence = transformationMethod.getTransformation(charSequence, this);
        }
        this.f184 = charSequence;
        this.f198 = null;
        if (this.f209) {
            m41();
        }
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        int i;
        int i2;
        int i3 = this.f172;
        int i4 = this.f202;
        int i5 = this.f203;
        int i6 = this.f185;
        int thumbOffset = getThumbOffset() + i3;
        Drawable drawable = this.f187;
        Rect rectM3158 = drawable != null ? AbstractC0912.m3158(drawable) : AbstractC0912.f4003;
        Drawable drawable2 = this.f211;
        Rect rect = this.f189;
        if (drawable2 != null) {
            drawable2.getPadding(rect);
            int i7 = rect.left;
            thumbOffset += i7;
            if (rectM3158 != null) {
                int i8 = rectM3158.left;
                if (i8 > i7) {
                    i3 += i8 - i7;
                }
                int i9 = rectM3158.top;
                int i10 = rect.top;
                i = i9 > i10 ? (i9 - i10) + i4 : i4;
                int i11 = rectM3158.right;
                int i12 = rect.right;
                if (i11 > i12) {
                    i5 -= i11 - i12;
                }
                int i13 = rectM3158.bottom;
                int i14 = rect.bottom;
                if (i13 > i14) {
                    i2 = i6 - (i13 - i14);
                }
                this.f211.setBounds(i3, i, i5, i2);
            } else {
                i = i4;
            }
            i2 = i6;
            this.f211.setBounds(i3, i, i5, i2);
        }
        Drawable drawable3 = this.f187;
        if (drawable3 != null) {
            drawable3.getPadding(rect);
            int i15 = thumbOffset - rect.left;
            int i16 = thumbOffset + this.f196 + rect.right;
            this.f187.setBounds(i15, i4, i16, i6);
            Drawable background = getBackground();
            if (background != null) {
                background.setHotspotBounds(i15, i4, i16, i6);
            }
        }
        super.draw(canvas);
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public final void drawableHotspotChanged(float f, float f2) {
        super.drawableHotspotChanged(f, f2);
        Drawable drawable = this.f187;
        if (drawable != null) {
            drawable.setHotspot(f, f2);
        }
        Drawable drawable2 = this.f211;
        if (drawable2 != null) {
            drawable2.setHotspot(f, f2);
        }
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public final void drawableStateChanged() {
        super.drawableStateChanged();
        int[] drawableState = getDrawableState();
        Drawable drawable = this.f187;
        boolean state = (drawable == null || !drawable.isStateful()) ? false : drawable.setState(drawableState);
        Drawable drawable2 = this.f211;
        if (drawable2 != null && drawable2.isStateful()) {
            state |= drawable2.setState(drawableState);
        }
        if (state) {
            invalidate();
        }
    }

    @Override // android.widget.CompoundButton, android.widget.TextView
    public int getCompoundPaddingLeft() {
        boolean z = AbstractC2514.f9717;
        if (getLayoutDirection() != 1) {
            return super.getCompoundPaddingLeft();
        }
        int compoundPaddingLeft = super.getCompoundPaddingLeft() + this.f173;
        return !TextUtils.isEmpty(getText()) ? compoundPaddingLeft + this.f181 : compoundPaddingLeft;
    }

    @Override // android.widget.CompoundButton, android.widget.TextView
    public int getCompoundPaddingRight() {
        boolean z = AbstractC2514.f9717;
        if (getLayoutDirection() == 1) {
            return super.getCompoundPaddingRight();
        }
        int compoundPaddingRight = super.getCompoundPaddingRight() + this.f173;
        return !TextUtils.isEmpty(getText()) ? compoundPaddingRight + this.f181 : compoundPaddingRight;
    }

    @Override // android.widget.TextView
    public ActionMode.Callback getCustomSelectionActionModeCallback() {
        return ᵷᵸˁ.ʿٴˇ(super.getCustomSelectionActionModeCallback());
    }

    public boolean getShowText() {
        return this.f209;
    }

    public boolean getSplitTrack() {
        return this.f176;
    }

    public int getSwitchMinWidth() {
        return this.f201;
    }

    public int getSwitchPadding() {
        return this.f181;
    }

    public CharSequence getTextOff() {
        return this.f183;
    }

    public CharSequence getTextOn() {
        return this.f174;
    }

    public Drawable getThumbDrawable() {
        return this.f187;
    }

    public final float getThumbPosition() {
        return this.f175;
    }

    public int getThumbTextPadding() {
        return this.f171;
    }

    public ColorStateList getThumbTintList() {
        return this.f199;
    }

    public PorterDuff.Mode getThumbTintMode() {
        return this.f194;
    }

    public Drawable getTrackDrawable() {
        return this.f211;
    }

    public ColorStateList getTrackTintList() {
        return this.f178;
    }

    public PorterDuff.Mode getTrackTintMode() {
        return this.f188;
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public final void jumpDrawablesToCurrentState() {
        super.jumpDrawablesToCurrentState();
        Drawable drawable = this.f187;
        if (drawable != null) {
            drawable.jumpToCurrentState();
        }
        Drawable drawable2 = this.f211;
        if (drawable2 != null) {
            drawable2.jumpToCurrentState();
        }
        ObjectAnimator objectAnimator = this.f206;
        if (objectAnimator == null || !objectAnimator.isStarted()) {
            return;
        }
        this.f206.end();
        this.f206 = null;
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public final int[] onCreateDrawableState(int i) {
        int[] iArrOnCreateDrawableState = super.onCreateDrawableState(i + 1);
        if (isChecked()) {
            View.mergeDrawableStates(iArrOnCreateDrawableState, f168);
        }
        return iArrOnCreateDrawableState;
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public final void onDraw(Canvas canvas) {
        int width;
        super.onDraw(canvas);
        Drawable drawable = this.f211;
        Rect rect = this.f189;
        if (drawable != null) {
            drawable.getPadding(rect);
        } else {
            rect.setEmpty();
        }
        int i = this.f202;
        int i2 = this.f185;
        int i3 = i + rect.top;
        int i4 = i2 - rect.bottom;
        Drawable drawable2 = this.f187;
        if (drawable != null) {
            if (!this.f176 || drawable2 == null) {
                drawable.draw(canvas);
            } else {
                Rect rectM3158 = AbstractC0912.m3158(drawable2);
                drawable2.copyBounds(rect);
                rect.left += rectM3158.left;
                rect.right -= rectM3158.right;
                int iSave = canvas.save();
                canvas.clipRect(rect, Region.Op.DIFFERENCE);
                drawable.draw(canvas);
                canvas.restoreToCount(iSave);
            }
        }
        int iSave2 = canvas.save();
        if (drawable2 != null) {
            drawable2.draw(canvas);
        }
        StaticLayout staticLayout = getTargetCheckedState() ? this.f198 : this.f191;
        if (staticLayout != null) {
            int[] drawableState = getDrawableState();
            TextPaint textPaint = this.f177;
            ColorStateList colorStateList = this.f186;
            if (colorStateList != null) {
                textPaint.setColor(colorStateList.getColorForState(drawableState, 0));
            }
            textPaint.drawableState = drawableState;
            if (drawable2 != null) {
                Rect bounds = drawable2.getBounds();
                width = bounds.left + bounds.right;
            } else {
                width = getWidth();
            }
            canvas.translate((width / 2) - (staticLayout.getWidth() / 2), ((i3 + i4) / 2) - (staticLayout.getHeight() / 2));
            staticLayout.draw(canvas);
        }
        canvas.restoreToCount(iSave2);
    }

    @Override // android.view.View
    public final void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        super.onInitializeAccessibilityEvent(accessibilityEvent);
        accessibilityEvent.setClassName("android.widget.Switch");
    }

    @Override // android.view.View
    public final void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
        accessibilityNodeInfo.setClassName("android.widget.Switch");
        if (Build.VERSION.SDK_INT < 30) {
            CharSequence charSequence = isChecked() ? this.f174 : this.f183;
            if (TextUtils.isEmpty(charSequence)) {
                return;
            }
            CharSequence text = accessibilityNodeInfo.getText();
            if (TextUtils.isEmpty(text)) {
                accessibilityNodeInfo.setText(charSequence);
                return;
            }
            StringBuilder sb = new StringBuilder();
            sb.append(text);
            sb.append(' ');
            sb.append(charSequence);
            accessibilityNodeInfo.setText(sb);
        }
    }

    @Override // android.widget.TextView, android.view.View
    public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int iMax;
        int width;
        int paddingLeft;
        int height;
        int paddingTop;
        super.onLayout(z, i, i2, i3, i4);
        int iMax2 = 0;
        if (this.f187 != null) {
            Drawable drawable = this.f211;
            Rect rect = this.f189;
            if (drawable != null) {
                drawable.getPadding(rect);
            } else {
                rect.setEmpty();
            }
            Rect rectM3158 = AbstractC0912.m3158(this.f187);
            iMax = Math.max(0, rectM3158.left - rect.left);
            iMax2 = Math.max(0, rectM3158.right - rect.right);
        } else {
            iMax = 0;
        }
        boolean z2 = AbstractC2514.f9717;
        if (getLayoutDirection() == 1) {
            paddingLeft = getPaddingLeft() + iMax;
            width = ((this.f173 + paddingLeft) - iMax) - iMax2;
        } else {
            width = (getWidth() - getPaddingRight()) - iMax2;
            paddingLeft = (width - this.f173) + iMax + iMax2;
        }
        int gravity = getGravity() & 112;
        if (gravity == 16) {
            int height2 = ((getHeight() + getPaddingTop()) - getPaddingBottom()) / 2;
            int i5 = this.f190;
            int i6 = height2 - (i5 / 2);
            height = i5 + i6;
            paddingTop = i6;
        } else if (gravity != 80) {
            paddingTop = getPaddingTop();
            height = this.f190 + paddingTop;
        } else {
            height = getHeight() - getPaddingBottom();
            paddingTop = height - this.f190;
        }
        this.f172 = paddingLeft;
        this.f202 = paddingTop;
        this.f185 = height;
        this.f203 = width;
    }

    @Override // android.widget.TextView, android.view.View
    public final void onMeasure(int i, int i2) {
        int intrinsicWidth;
        int intrinsicHeight;
        int intrinsicHeight2 = 0;
        if (this.f209) {
            StaticLayout staticLayout = this.f198;
            TextPaint textPaint = this.f177;
            if (staticLayout == null) {
                CharSequence charSequence = this.f184;
                this.f198 = new StaticLayout(charSequence, textPaint, charSequence != null ? (int) Math.ceil(Layout.getDesiredWidth(charSequence, textPaint)) : 0, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
            }
            if (this.f191 == null) {
                CharSequence charSequence2 = this.f197;
                this.f191 = new StaticLayout(charSequence2, textPaint, charSequence2 != null ? (int) Math.ceil(Layout.getDesiredWidth(charSequence2, textPaint)) : 0, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
            }
        }
        Drawable drawable = this.f187;
        Rect rect = this.f189;
        if (drawable != null) {
            drawable.getPadding(rect);
            intrinsicWidth = (this.f187.getIntrinsicWidth() - rect.left) - rect.right;
            intrinsicHeight = this.f187.getIntrinsicHeight();
        } else {
            intrinsicWidth = 0;
            intrinsicHeight = 0;
        }
        this.f196 = Math.max(this.f209 ? (this.f171 * 2) + Math.max(this.f198.getWidth(), this.f191.getWidth()) : 0, intrinsicWidth);
        Drawable drawable2 = this.f211;
        if (drawable2 != null) {
            drawable2.getPadding(rect);
            intrinsicHeight2 = this.f211.getIntrinsicHeight();
        } else {
            rect.setEmpty();
        }
        int iMax = rect.left;
        int iMax2 = rect.right;
        Drawable drawable3 = this.f187;
        if (drawable3 != null) {
            Rect rectM3158 = AbstractC0912.m3158(drawable3);
            iMax = Math.max(iMax, rectM3158.left);
            iMax2 = Math.max(iMax2, rectM3158.right);
        }
        boolean z = this.f180;
        int iMax3 = this.f201;
        if (z) {
            iMax3 = Math.max(iMax3, (this.f196 * 2) + iMax + iMax2);
        }
        int iMax4 = Math.max(intrinsicHeight2, intrinsicHeight);
        this.f173 = iMax3;
        this.f190 = iMax4;
        super.onMeasure(i, i2);
        if (getMeasuredHeight() < iMax4) {
            setMeasuredDimension(getMeasuredWidthAndState(), iMax4);
        }
    }

    @Override // android.view.View
    public final void onPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        super.onPopulateAccessibilityEvent(accessibilityEvent);
        CharSequence charSequence = isChecked() ? this.f174 : this.f183;
        if (charSequence != null) {
            accessibilityEvent.getText().add(charSequence);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x008e  */
    @Override // android.widget.TextView, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        boolean targetCheckedState;
        VelocityTracker velocityTracker = this.f200;
        velocityTracker.addMovement(motionEvent);
        int actionMasked = motionEvent.getActionMasked();
        int i = this.f170;
        if (actionMasked != 0) {
            if (actionMasked == 1) {
                if (this.f192 == 2) {
                    this.f192 = 0;
                    boolean z = motionEvent.getAction() == 1 && isEnabled();
                    boolean zIsChecked = isChecked();
                    if (z) {
                        velocityTracker.computeCurrentVelocity(1000);
                        float xVelocity = velocityTracker.getXVelocity();
                        if (Math.abs(xVelocity) > this.f182) {
                            boolean z2 = AbstractC2514.f9717;
                            targetCheckedState = getLayoutDirection() != 1 ? xVelocity > 0.0f : xVelocity < 0.0f;
                        } else {
                            targetCheckedState = getTargetCheckedState();
                        }
                    } else {
                        targetCheckedState = zIsChecked;
                    }
                    if (targetCheckedState != zIsChecked) {
                        playSoundEffect(0);
                    }
                    setChecked(targetCheckedState);
                    MotionEvent motionEventObtain = MotionEvent.obtain(motionEvent);
                    motionEventObtain.setAction(3);
                    super.onTouchEvent(motionEventObtain);
                    motionEventObtain.recycle();
                    super.onTouchEvent(motionEvent);
                    return true;
                }
                this.f192 = 0;
                velocityTracker.clear();
            } else if (actionMasked == 2) {
                int i2 = this.f192;
                if (i2 == 1) {
                    float x = motionEvent.getX();
                    float y = motionEvent.getY();
                    float f = i;
                    if (Math.abs(x - this.f179) > f || Math.abs(y - this.f204) > f) {
                        this.f192 = 2;
                        getParent().requestDisallowInterceptTouchEvent(true);
                        this.f179 = x;
                        this.f204 = y;
                        return true;
                    }
                } else if (i2 == 2) {
                    float x2 = motionEvent.getX();
                    int thumbScrollRange = getThumbScrollRange();
                    float f2 = x2 - this.f179;
                    float f3 = thumbScrollRange != 0 ? f2 / thumbScrollRange : f2 > 0.0f ? 1.0f : -1.0f;
                    boolean z3 = AbstractC2514.f9717;
                    if (getLayoutDirection() == 1) {
                        f3 = -f3;
                    }
                    float f4 = this.f175;
                    float f5 = f3 + f4;
                    float f6 = f5 >= 0.0f ? f5 > 1.0f ? 1.0f : f5 : 0.0f;
                    if (f6 != f4) {
                        this.f179 = x2;
                        setThumbPosition(f6);
                    }
                    return true;
                }
            } else if (actionMasked == 3) {
            }
        } else {
            float x3 = motionEvent.getX();
            float y2 = motionEvent.getY();
            if (isEnabled() && this.f187 != null) {
                int thumbOffset = getThumbOffset();
                Drawable drawable = this.f187;
                Rect rect = this.f189;
                drawable.getPadding(rect);
                int i3 = this.f202 - i;
                int i4 = (this.f172 + thumbOffset) - i;
                int i5 = this.f196 + i4 + rect.left + rect.right + i;
                int i6 = this.f185 + i;
                if (x3 > i4 && x3 < i5 && y2 > i3 && y2 < i6) {
                    this.f192 = 1;
                    this.f179 = x3;
                    this.f204 = y2;
                }
            }
        }
        return super.onTouchEvent(motionEvent);
    }

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

    @Override // android.widget.CompoundButton, android.widget.Checkable
    public void setChecked(boolean z) {
        super.setChecked(z);
        boolean zIsChecked = isChecked();
        if (zIsChecked) {
            if (Build.VERSION.SDK_INT >= 30) {
                Object string = this.f174;
                if (string == null) {
                    string = getResources().getString(ar.tvplayer.tv.R.string.h);
                }
                Object obj = string;
                WeakHashMap weakHashMap = AbstractC2746.f10556;
                new C0180(ar.tvplayer.tv.R.id.h, CharSequence.class, 64, 30, 2).m6400(this, obj);
            }
        } else if (Build.VERSION.SDK_INT >= 30) {
            Object string2 = this.f183;
            if (string2 == null) {
                string2 = getResources().getString(ar.tvplayer.tv.R.string.h);
            }
            Object obj2 = string2;
            WeakHashMap weakHashMap2 = AbstractC2746.f10556;
            new C0180(ar.tvplayer.tv.R.id.h, CharSequence.class, 64, 30, 2).m6400(this, obj2);
        }
        if (getWindowToken() == null || !isLaidOut()) {
            ObjectAnimator objectAnimator = this.f206;
            if (objectAnimator != null) {
                objectAnimator.cancel();
            }
            setThumbPosition(zIsChecked ? 1.0f : 0.0f);
            return;
        }
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(this, f169, zIsChecked ? 1.0f : 0.0f);
        this.f206 = objectAnimatorOfFloat;
        objectAnimatorOfFloat.setDuration(250L);
        this.f206.setAutoCancel(true);
        this.f206.start();
    }

    @Override // android.widget.TextView
    public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(ᵷᵸˁ.ᵠˏˏ(callback, this));
    }

    public void setEmojiCompatEnabled(boolean z) {
        getEmojiTextViewHelper().m3157(z);
        setTextOnInternal(this.f174);
        setTextOffInternal(this.f183);
        requestLayout();
    }

    public final void setEnforceSwitchWidth(boolean z) {
        this.f180 = z;
        invalidate();
    }

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

    public void setShowText(boolean z) {
        if (this.f209 != z) {
            this.f209 = z;
            requestLayout();
            if (z) {
                m41();
            }
        }
    }

    public void setSplitTrack(boolean z) {
        this.f176 = z;
        invalidate();
    }

    public void setSwitchMinWidth(int i) {
        this.f201 = i;
        requestLayout();
    }

    public void setSwitchPadding(int i) {
        this.f181 = i;
        requestLayout();
    }

    public void setSwitchTypeface(Typeface typeface) {
        TextPaint textPaint = this.f177;
        if ((textPaint.getTypeface() == null || textPaint.getTypeface().equals(typeface)) && (textPaint.getTypeface() != null || typeface == null)) {
            return;
        }
        textPaint.setTypeface(typeface);
        requestLayout();
        invalidate();
    }

    public void setTextOff(CharSequence charSequence) {
        setTextOffInternal(charSequence);
        requestLayout();
        if (isChecked() || Build.VERSION.SDK_INT < 30) {
            return;
        }
        Object string = this.f183;
        if (string == null) {
            string = getResources().getString(ar.tvplayer.tv.R.string.h);
        }
        WeakHashMap weakHashMap = AbstractC2746.f10556;
        new C0180(ar.tvplayer.tv.R.id.h, CharSequence.class, 64, 30, 2).m6400(this, string);
    }

    public void setTextOn(CharSequence charSequence) {
        setTextOnInternal(charSequence);
        requestLayout();
        if (!isChecked() || Build.VERSION.SDK_INT < 30) {
            return;
        }
        Object string = this.f174;
        if (string == null) {
            string = getResources().getString(ar.tvplayer.tv.R.string.h);
        }
        WeakHashMap weakHashMap = AbstractC2746.f10556;
        new C0180(ar.tvplayer.tv.R.id.h, CharSequence.class, 64, 30, 2).m6400(this, string);
    }

    public void setThumbDrawable(Drawable drawable) {
        Drawable drawable2 = this.f187;
        if (drawable2 != null) {
            drawable2.setCallback(null);
        }
        this.f187 = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
        }
        requestLayout();
    }

    public void setThumbPosition(float f) {
        this.f175 = f;
        invalidate();
    }

    public void setThumbResource(int i) {
        setThumbDrawable(ᵥˇᵛˎ.ᵶˇᵱ(getContext(), i));
    }

    public void setThumbTextPadding(int i) {
        this.f171 = i;
        requestLayout();
    }

    public void setThumbTintList(ColorStateList colorStateList) {
        this.f199 = colorStateList;
        this.f205 = true;
        m40();
    }

    public void setThumbTintMode(PorterDuff.Mode mode) {
        this.f194 = mode;
        this.f208 = true;
        m40();
    }

    public void setTrackDrawable(Drawable drawable) {
        Drawable drawable2 = this.f211;
        if (drawable2 != null) {
            drawable2.setCallback(null);
        }
        this.f211 = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
        }
        requestLayout();
    }

    public void setTrackResource(int i) {
        setTrackDrawable(ᵥˇᵛˎ.ᵶˇᵱ(getContext(), i));
    }

    public void setTrackTintList(ColorStateList colorStateList) {
        this.f178 = colorStateList;
        this.f212 = true;
        m38();
    }

    public void setTrackTintMode(PorterDuff.Mode mode) {
        this.f188 = mode;
        this.f193 = true;
        m38();
    }

    @Override // android.widget.CompoundButton, android.widget.Checkable
    public final void toggle() {
        setChecked(!isChecked());
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public final boolean verifyDrawable(Drawable drawable) {
        return super.verifyDrawable(drawable) || drawable == this.f187 || drawable == this.f211;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m38() {
        Drawable drawable = this.f211;
        if (drawable != null) {
            if (this.f212 || this.f193) {
                Drawable drawableMutate = drawable.mutate();
                this.f211 = drawableMutate;
                if (this.f212) {
                    drawableMutate.setTintList(this.f178);
                }
                if (this.f193) {
                    this.f211.setTintMode(this.f188);
                }
                if (this.f211.isStateful()) {
                    this.f211.setState(getDrawableState());
                }
            }
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m39() {
        setTextOnInternal(this.f174);
        setTextOffInternal(this.f183);
        requestLayout();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m40() {
        Drawable drawable = this.f187;
        if (drawable != null) {
            if (this.f205 || this.f208) {
                Drawable drawableMutate = drawable.mutate();
                this.f187 = drawableMutate;
                if (this.f205) {
                    drawableMutate.setTintList(this.f199);
                }
                if (this.f208) {
                    this.f187.setTintMode(this.f194);
                }
                if (this.f187.isStateful()) {
                    this.f187.setState(getDrawableState());
                }
            }
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void m41() {
        if (this.f207 == null && ((ᵶᵦ) this.f210.f3997.f4404).ˉᵲ() && C3880.f14798 != null) {
            C3880 c3880M8582 = C3880.m8582();
            int iM8583 = c3880M8582.m8583();
            if (iM8583 == 3 || iM8583 == 0) {
                C4832 c4832 = new C4832(this);
                this.f207 = c4832;
                c3880M8582.m8587(c4832);
            }
        }
    }
}
