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.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.util.Property;
import android.view.ActionMode;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.CompoundButton;
import android.widget.TextView;
import p037.p041.C1468;
import p037.p041.C1477;
import p037.p041.p042.LayoutInflaterFactory2C1494;
import p037.p041.p043.p044.C1527;
import p037.p041.p048.C1546;
import p037.p041.p051.C1640;
import p037.p041.p051.C1650;
import p037.p041.p051.C1684;
import p037.p041.p051.C1689;
import p037.p041.p051.C1698;
import p037.p065.p078.C1920;

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

    /* JADX INFO: renamed from: ࢤ, reason: contains not printable characters */
    public static final Property<SwitchCompat, Float> f395 = new C0065(Float.class, "thumbPos");

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

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public Drawable f397;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public ColorStateList f398;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public PorterDuff.Mode f399;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public boolean f400;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public boolean f401;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public Drawable f402;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public ColorStateList f403;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public PorterDuff.Mode f404;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public boolean f405;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public boolean f406;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public int f407;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public int f408;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public int f409;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public boolean f410;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public CharSequence f411;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public CharSequence f412;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public boolean f413;

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public int f414;

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public int f415;

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public float f416;

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public float f417;

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public VelocityTracker f418;

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public int f419;

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public float f420;

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public int f421;

    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public int f422;

    /* JADX INFO: renamed from: ޝ, reason: contains not printable characters */
    public int f423;

    /* JADX INFO: renamed from: ޞ, reason: contains not printable characters */
    public int f424;

    /* JADX INFO: renamed from: ޟ, reason: contains not printable characters */
    public int f425;

    /* JADX INFO: renamed from: ޠ, reason: contains not printable characters */
    public int f426;

    /* JADX INFO: renamed from: ޡ, reason: contains not printable characters */
    public int f427;

    /* JADX INFO: renamed from: ޢ, reason: contains not printable characters */
    public final TextPaint f428;

    /* JADX INFO: renamed from: ޣ, reason: contains not printable characters */
    public ColorStateList f429;

    /* JADX INFO: renamed from: ޤ, reason: contains not printable characters */
    public Layout f430;

    /* JADX INFO: renamed from: ޥ, reason: contains not printable characters */
    public Layout f431;

    /* JADX INFO: renamed from: ޱ, reason: contains not printable characters */
    public TransformationMethod f432;

    /* JADX INFO: renamed from: ࢠ, reason: contains not printable characters */
    public ObjectAnimator f433;

    /* JADX INFO: renamed from: ࢢ, reason: contains not printable characters */
    public final C1640 f434;

    /* JADX INFO: renamed from: ࢣ, reason: contains not printable characters */
    public final Rect f435;

    /* JADX INFO: renamed from: androidx.appcompat.widget.SwitchCompat$֏, reason: contains not printable characters */
    public class C0065 extends Property<SwitchCompat, Float> {
        public C0065(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        public Float get(SwitchCompat switchCompat) {
            return Float.valueOf(switchCompat.f420);
        }

        @Override // android.util.Property
        public void set(SwitchCompat switchCompat, Float f) {
            switchCompat.setThumbPosition(f.floatValue());
        }
    }

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

    public SwitchCompat(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, C1468.switchStyle);
    }

    public SwitchCompat(Context context, AttributeSet attributeSet, int i) {
        int resourceId;
        super(context, attributeSet, i);
        this.f398 = null;
        this.f399 = null;
        this.f400 = false;
        this.f401 = false;
        this.f403 = null;
        this.f404 = null;
        this.f405 = false;
        this.f406 = false;
        this.f418 = VelocityTracker.obtain();
        this.f435 = new Rect();
        C1684.m3289(this, getContext());
        this.f428 = new TextPaint(1);
        this.f428.density = getResources().getDisplayMetrics().density;
        C1689 c1689 = new C1689(context, context.obtainStyledAttributes(attributeSet, C1477.SwitchCompat, i, 0));
        C1920.m3742(this, context, C1477.SwitchCompat, attributeSet, c1689.f5496, i, 0);
        Drawable drawableM3300 = c1689.m3300(C1477.SwitchCompat_android_thumb);
        this.f397 = drawableM3300;
        if (drawableM3300 != null) {
            drawableM3300.setCallback(this);
        }
        Drawable drawableM33002 = c1689.m3300(C1477.SwitchCompat_track);
        this.f402 = drawableM33002;
        if (drawableM33002 != null) {
            drawableM33002.setCallback(this);
        }
        this.f411 = c1689.m3306(C1477.SwitchCompat_android_textOn);
        this.f412 = c1689.m3306(C1477.SwitchCompat_android_textOff);
        this.f413 = c1689.m3298(C1477.SwitchCompat_showText, true);
        this.f407 = c1689.m3299(C1477.SwitchCompat_thumbTextPadding, 0);
        this.f408 = c1689.m3299(C1477.SwitchCompat_switchMinWidth, 0);
        this.f409 = c1689.m3299(C1477.SwitchCompat_switchPadding, 0);
        this.f410 = c1689.m3298(C1477.SwitchCompat_splitTrack, false);
        ColorStateList colorStateListM3296 = c1689.m3296(C1477.SwitchCompat_thumbTint);
        if (colorStateListM3296 != null) {
            this.f398 = colorStateListM3296;
            this.f400 = true;
        }
        PorterDuff.Mode modeM3240 = C1650.m3240(c1689.m3301(C1477.SwitchCompat_thumbTintMode, -1), null);
        if (this.f399 != modeM3240) {
            this.f399 = modeM3240;
            this.f401 = true;
        }
        if (this.f400 || this.f401) {
            m178();
        }
        ColorStateList colorStateListM32962 = c1689.m3296(C1477.SwitchCompat_trackTint);
        if (colorStateListM32962 != null) {
            this.f403 = colorStateListM32962;
            this.f405 = true;
        }
        PorterDuff.Mode modeM32402 = C1650.m3240(c1689.m3301(C1477.SwitchCompat_trackTintMode, -1), null);
        if (this.f404 != modeM32402) {
            this.f404 = modeM32402;
            this.f406 = true;
        }
        if (this.f405 || this.f406) {
            m179();
        }
        int iM3305 = c1689.m3305(C1477.SwitchCompat_switchTextAppearance, 0);
        if (iM3305 != 0) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(iM3305, C1477.TextAppearance);
            int i2 = C1477.TextAppearance_android_textColor;
            ColorStateList colorStateList = (!typedArrayObtainStyledAttributes.hasValue(i2) || (resourceId = typedArrayObtainStyledAttributes.getResourceId(i2, 0)) == 0 || (colorStateList = C1527.m3024(context, resourceId)) == null) ? typedArrayObtainStyledAttributes.getColorStateList(i2) : colorStateList;
            if (colorStateList != null) {
                this.f429 = colorStateList;
            } else {
                this.f429 = getTextColors();
            }
            int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(C1477.TextAppearance_android_textSize, 0);
            if (dimensionPixelSize != 0) {
                float f = dimensionPixelSize;
                if (f != this.f428.getTextSize()) {
                    this.f428.setTextSize(f);
                    requestLayout();
                }
            }
            int i3 = typedArrayObtainStyledAttributes.getInt(C1477.TextAppearance_android_typeface, -1);
            int i4 = typedArrayObtainStyledAttributes.getInt(C1477.TextAppearance_android_textStyle, -1);
            Typeface typeface = i3 != 1 ? i3 != 2 ? i3 != 3 ? null : Typeface.MONOSPACE : Typeface.SERIF : Typeface.SANS_SERIF;
            if (i4 > 0) {
                Typeface typefaceDefaultFromStyle = typeface == null ? Typeface.defaultFromStyle(i4) : Typeface.create(typeface, i4);
                setSwitchTypeface(typefaceDefaultFromStyle);
                int i5 = i4 & (~(typefaceDefaultFromStyle != null ? typefaceDefaultFromStyle.getStyle() : 0));
                this.f428.setFakeBoldText((i5 & 1) != 0);
                this.f428.setTextSkewX((i5 & 2) != 0 ? -0.25f : 0.0f);
            } else {
                this.f428.setFakeBoldText(false);
                this.f428.setTextSkewX(0.0f);
                setSwitchTypeface(typeface);
            }
            if (typedArrayObtainStyledAttributes.getBoolean(C1477.TextAppearance_textAllCaps, false)) {
                this.f432 = new C1546(getContext());
            } else {
                this.f432 = null;
            }
            typedArrayObtainStyledAttributes.recycle();
        }
        C1640 c1640 = new C1640(this);
        this.f434 = c1640;
        c1640.m3202(attributeSet, i);
        c1689.f5496.recycle();
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        this.f415 = viewConfiguration.getScaledTouchSlop();
        this.f419 = viewConfiguration.getScaledMinimumFlingVelocity();
        refreshDrawableState();
        setChecked(isChecked());
    }

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

    private int getThumbOffset() {
        return (int) (((C1698.m3318(this) ? 1.0f - this.f420 : this.f420) * getThumbScrollRange()) + 0.5f);
    }

    private int getThumbScrollRange() {
        Drawable drawable = this.f402;
        if (drawable == null) {
            return 0;
        }
        Rect rect = this.f435;
        drawable.getPadding(rect);
        Drawable drawable2 = this.f397;
        Rect rectM3243 = drawable2 != null ? C1650.m3243(drawable2) : C1650.f5349;
        return ((((this.f421 - this.f423) - rect.left) - rect.right) - rectM3243.left) - rectM3243.right;
    }

    @Override // android.view.View
    public void draw(Canvas canvas) {
        int i;
        int i2;
        Rect rect = this.f435;
        int i3 = this.f424;
        int i4 = this.f425;
        int i5 = this.f426;
        int i6 = this.f427;
        int thumbOffset = getThumbOffset() + i3;
        Drawable drawable = this.f397;
        Rect rectM3243 = drawable != null ? C1650.m3243(drawable) : C1650.f5349;
        Drawable drawable2 = this.f402;
        if (drawable2 != null) {
            drawable2.getPadding(rect);
            int i7 = rect.left;
            thumbOffset += i7;
            if (rectM3243 != null) {
                int i8 = rectM3243.left;
                if (i8 > i7) {
                    i3 += i8 - i7;
                }
                int i9 = rectM3243.top;
                int i10 = rect.top;
                i = i9 > i10 ? (i9 - i10) + i4 : i4;
                int i11 = rectM3243.right;
                int i12 = rect.right;
                if (i11 > i12) {
                    i5 -= i11 - i12;
                }
                int i13 = rectM3243.bottom;
                int i14 = rect.bottom;
                if (i13 > i14) {
                    i2 = i6 - (i13 - i14);
                }
                this.f402.setBounds(i3, i, i5, i2);
            } else {
                i = i4;
            }
            i2 = i6;
            this.f402.setBounds(i3, i, i5, i2);
        }
        Drawable drawable3 = this.f397;
        if (drawable3 != null) {
            drawable3.getPadding(rect);
            int i15 = thumbOffset - rect.left;
            int i16 = thumbOffset + this.f423 + rect.right;
            this.f397.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 void drawableHotspotChanged(float f, float f2) {
        super.drawableHotspotChanged(f, f2);
        Drawable drawable = this.f397;
        if (drawable != null) {
            drawable.setHotspot(f, f2);
        }
        Drawable drawable2 = this.f402;
        if (drawable2 != null) {
            drawable2.setHotspot(f, f2);
        }
    }

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

    @Override // android.widget.CompoundButton, android.widget.TextView
    public int getCompoundPaddingLeft() {
        if (!C1698.m3318(this)) {
            return super.getCompoundPaddingLeft();
        }
        int compoundPaddingLeft = super.getCompoundPaddingLeft() + this.f421;
        return !TextUtils.isEmpty(getText()) ? compoundPaddingLeft + this.f409 : compoundPaddingLeft;
    }

    @Override // android.widget.CompoundButton, android.widget.TextView
    public int getCompoundPaddingRight() {
        if (C1698.m3318(this)) {
            return super.getCompoundPaddingRight();
        }
        int compoundPaddingRight = super.getCompoundPaddingRight() + this.f421;
        return !TextUtils.isEmpty(getText()) ? compoundPaddingRight + this.f409 : compoundPaddingRight;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    public void onDraw(Canvas canvas) {
        int width;
        super.onDraw(canvas);
        Rect rect = this.f435;
        Drawable drawable = this.f402;
        if (drawable != null) {
            drawable.getPadding(rect);
        } else {
            rect.setEmpty();
        }
        int i = this.f425;
        int i2 = this.f427;
        int i3 = i + rect.top;
        int i4 = i2 - rect.bottom;
        Drawable drawable2 = this.f397;
        if (drawable != null) {
            if (!this.f410 || drawable2 == null) {
                drawable.draw(canvas);
            } else {
                Rect rectM3243 = C1650.m3243(drawable2);
                drawable2.copyBounds(rect);
                rect.left += rectM3243.left;
                rect.right -= rectM3243.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);
        }
        Layout layout = getTargetCheckedState() ? this.f430 : this.f431;
        if (layout != null) {
            int[] drawableState = getDrawableState();
            ColorStateList colorStateList = this.f429;
            if (colorStateList != null) {
                this.f428.setColor(colorStateList.getColorForState(drawableState, 0));
            }
            this.f428.drawableState = drawableState;
            if (drawable2 != null) {
                Rect bounds = drawable2.getBounds();
                width = bounds.left + bounds.right;
            } else {
                width = getWidth();
            }
            canvas.translate((width / 2) - (layout.getWidth() / 2), ((i3 + i4) / 2) - (layout.getHeight() / 2));
            layout.draw(canvas);
        }
        canvas.restoreToCount(iSave2);
    }

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

    @Override // android.view.View
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
        accessibilityNodeInfo.setClassName("android.widget.Switch");
        CharSequence charSequence = isChecked() ? this.f411 : this.f412;
        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 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.f397 != null) {
            Rect rect = this.f435;
            Drawable drawable = this.f402;
            if (drawable != null) {
                drawable.getPadding(rect);
            } else {
                rect.setEmpty();
            }
            Rect rectM3243 = C1650.m3243(this.f397);
            iMax = Math.max(0, rectM3243.left - rect.left);
            iMax2 = Math.max(0, rectM3243.right - rect.right);
        } else {
            iMax = 0;
        }
        if (C1698.m3318(this)) {
            paddingLeft = getPaddingLeft() + iMax;
            width = ((this.f421 + paddingLeft) - iMax) - iMax2;
        } else {
            width = (getWidth() - getPaddingRight()) - iMax2;
            paddingLeft = (width - this.f421) + iMax + iMax2;
        }
        int gravity = getGravity() & 112;
        if (gravity == 16) {
            int height2 = ((getHeight() + getPaddingTop()) - getPaddingBottom()) / 2;
            int i5 = this.f422;
            int i6 = height2 - (i5 / 2);
            height = i5 + i6;
            paddingTop = i6;
        } else if (gravity != 80) {
            paddingTop = getPaddingTop();
            height = this.f422 + paddingTop;
        } else {
            height = getHeight() - getPaddingBottom();
            paddingTop = height - this.f422;
        }
        this.f424 = paddingLeft;
        this.f425 = paddingTop;
        this.f427 = height;
        this.f426 = width;
    }

    @Override // android.widget.TextView, android.view.View
    public void onMeasure(int i, int i2) {
        int intrinsicWidth;
        int intrinsicHeight;
        int iMax;
        if (this.f413) {
            if (this.f430 == null) {
                this.f430 = m177(this.f411);
            }
            if (this.f431 == null) {
                this.f431 = m177(this.f412);
            }
        }
        Rect rect = this.f435;
        Drawable drawable = this.f397;
        int intrinsicHeight2 = 0;
        if (drawable != null) {
            drawable.getPadding(rect);
            intrinsicWidth = (this.f397.getIntrinsicWidth() - rect.left) - rect.right;
            intrinsicHeight = this.f397.getIntrinsicHeight();
        } else {
            intrinsicWidth = 0;
            intrinsicHeight = 0;
        }
        if (this.f413) {
            iMax = (this.f407 * 2) + Math.max(this.f430.getWidth(), this.f431.getWidth());
        } else {
            iMax = 0;
        }
        this.f423 = Math.max(iMax, intrinsicWidth);
        Drawable drawable2 = this.f402;
        if (drawable2 != null) {
            drawable2.getPadding(rect);
            intrinsicHeight2 = this.f402.getIntrinsicHeight();
        } else {
            rect.setEmpty();
        }
        int iMax2 = rect.left;
        int iMax3 = rect.right;
        Drawable drawable3 = this.f397;
        if (drawable3 != null) {
            Rect rectM3243 = C1650.m3243(drawable3);
            iMax2 = Math.max(iMax2, rectM3243.left);
            iMax3 = Math.max(iMax3, rectM3243.right);
        }
        int iMax4 = Math.max(this.f408, (this.f423 * 2) + iMax2 + iMax3);
        int iMax5 = Math.max(intrinsicHeight2, intrinsicHeight);
        this.f421 = iMax4;
        this.f422 = iMax5;
        super.onMeasure(i, i2);
        if (getMeasuredHeight() < iMax5) {
            setMeasuredDimension(getMeasuredWidthAndState(), iMax5);
        }
    }

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

    /* JADX WARN: Removed duplicated region for block: B:40:0x0095  */
    @Override // android.widget.TextView, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean onTouchEvent(MotionEvent motionEvent) {
        boolean targetCheckedState;
        this.f418.addMovement(motionEvent);
        int actionMasked = motionEvent.getActionMasked();
        boolean z = false;
        if (actionMasked != 0) {
            if (actionMasked == 1) {
                if (this.f414 == 2) {
                    this.f414 = 0;
                    boolean z2 = motionEvent.getAction() == 1 && isEnabled();
                    boolean zIsChecked = isChecked();
                    if (z2) {
                        this.f418.computeCurrentVelocity(1000);
                        float xVelocity = this.f418.getXVelocity();
                        targetCheckedState = Math.abs(xVelocity) > ((float) this.f419) ? !C1698.m3318(this) ? xVelocity <= 0.0f : xVelocity >= 0.0f : 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.f414 = 0;
                this.f418.clear();
            } else if (actionMasked == 2) {
                int i = this.f414;
                if (i == 1) {
                    float x = motionEvent.getX();
                    float y = motionEvent.getY();
                    if (Math.abs(x - this.f416) > this.f415 || Math.abs(y - this.f417) > this.f415) {
                        this.f414 = 2;
                        getParent().requestDisallowInterceptTouchEvent(true);
                        this.f416 = x;
                        this.f417 = y;
                        return true;
                    }
                } else if (i == 2) {
                    float x2 = motionEvent.getX();
                    int thumbScrollRange = getThumbScrollRange();
                    float f = x2 - this.f416;
                    float f2 = thumbScrollRange != 0 ? f / thumbScrollRange : f > 0.0f ? 1.0f : -1.0f;
                    if (C1698.m3318(this)) {
                        f2 = -f2;
                    }
                    float f3 = this.f420 + f2;
                    float f4 = f3 >= 0.0f ? f3 > 1.0f ? 1.0f : f3 : 0.0f;
                    if (f4 != this.f420) {
                        this.f416 = x2;
                        setThumbPosition(f4);
                    }
                    return true;
                }
            } else if (actionMasked == 3) {
            }
        } else {
            float x3 = motionEvent.getX();
            float y2 = motionEvent.getY();
            if (isEnabled()) {
                if (this.f397 != null) {
                    int thumbOffset = getThumbOffset();
                    this.f397.getPadding(this.f435);
                    int i2 = this.f425;
                    int i3 = this.f415;
                    int i4 = i2 - i3;
                    int i5 = (this.f424 + thumbOffset) - i3;
                    int i6 = this.f423 + i5;
                    Rect rect = this.f435;
                    int i7 = i6 + rect.left + rect.right + i3;
                    int i8 = this.f427 + i3;
                    if (x3 > i5 && x3 < i7 && y2 > i4 && y2 < i8) {
                        z = true;
                    }
                }
                if (z) {
                    this.f414 = 1;
                    this.f416 = x3;
                    this.f417 = y2;
                }
            }
        }
        return super.onTouchEvent(motionEvent);
    }

    @Override // android.widget.CompoundButton, android.widget.Checkable
    public void setChecked(boolean z) {
        super.setChecked(z);
        boolean zIsChecked = isChecked();
        if (getWindowToken() == null || !C1920.m3770(this)) {
            ObjectAnimator objectAnimator = this.f433;
            if (objectAnimator != null) {
                objectAnimator.cancel();
            }
            setThumbPosition(zIsChecked ? 1.0f : 0.0f);
            return;
        }
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(this, f395, zIsChecked ? 1.0f : 0.0f);
        this.f433 = objectAnimatorOfFloat;
        objectAnimatorOfFloat.setDuration(250L);
        this.f433.setAutoCancel(true);
        this.f433.start();
    }

    @Override // android.widget.TextView
    public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(LayoutInflaterFactory2C1494.C1505.m2897((TextView) this, callback));
    }

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

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

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

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

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

    public void setTextOff(CharSequence charSequence) {
        this.f412 = charSequence;
        requestLayout();
    }

    public void setTextOn(CharSequence charSequence) {
        this.f411 = charSequence;
        requestLayout();
    }

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

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

    public void setThumbResource(int i) {
        setThumbDrawable(C1527.m3025(getContext(), i));
    }

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

    public void setThumbTintList(ColorStateList colorStateList) {
        this.f398 = colorStateList;
        this.f400 = true;
        m178();
    }

    public void setThumbTintMode(PorterDuff.Mode mode) {
        this.f399 = mode;
        this.f401 = true;
        m178();
    }

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

    public void setTrackResource(int i) {
        setTrackDrawable(C1527.m3025(getContext(), i));
    }

    public void setTrackTintList(ColorStateList colorStateList) {
        this.f403 = colorStateList;
        this.f405 = true;
        m179();
    }

    public void setTrackTintMode(PorterDuff.Mode mode) {
        this.f404 = mode;
        this.f406 = true;
        m179();
    }

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

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

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Layout m177(CharSequence charSequence) {
        TransformationMethod transformationMethod = this.f432;
        if (transformationMethod != null) {
            charSequence = transformationMethod.getTransformation(charSequence, this);
        }
        CharSequence charSequence2 = charSequence;
        return new StaticLayout(charSequence2, this.f428, charSequence2 != null ? (int) Math.ceil(Layout.getDesiredWidth(charSequence2, r2)) : 0, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m178() {
        if (this.f397 != null) {
            if (this.f400 || this.f401) {
                Drawable drawableMutate = LayoutInflaterFactory2C1494.C1505.m2972(this.f397).mutate();
                this.f397 = drawableMutate;
                if (this.f400) {
                    drawableMutate.setTintList(this.f398);
                }
                if (this.f401) {
                    this.f397.setTintMode(this.f399);
                }
                if (this.f397.isStateful()) {
                    this.f397.setState(getDrawableState());
                }
            }
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m179() {
        if (this.f402 != null) {
            if (this.f405 || this.f406) {
                Drawable drawableMutate = LayoutInflaterFactory2C1494.C1505.m2972(this.f402).mutate();
                this.f402 = drawableMutate;
                if (this.f405) {
                    drawableMutate.setTintList(this.f403);
                }
                if (this.f406) {
                    this.f402.setTintMode(this.f404);
                }
                if (this.f402.isStateful()) {
                    this.f402.setState(getDrawableState());
                }
            }
        }
    }
}
