what-the-bank/sources/androidx/appcompat/widget/SwitchCompat.java

1098 lines
34 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.appcompat.widget;
import android.R;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
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.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 androidx.core.view.ViewCompat;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import o.AgY;
import o.C0683McA;
import o.C16349neT;
import o.C4077bPV;
import o.FIj;
import o.SYO;
import o.Tlu;
import o.URz;
import o.WvB;
import o.Yoi;
import o.mxt;
import o.nKv;
/* loaded from: classes.dex */
public class SwitchCompat extends CompoundButton {
private static final Property<SwitchCompat, Float> a = new Property<SwitchCompat, Float>(Float.class, "thumbPos") { // from class: androidx.appcompat.widget.SwitchCompat.4
@Override // android.util.Property
/* renamed from: c, reason: merged with bridge method [inline-methods] */
public Float get(SwitchCompat switchCompat) {
return Float.valueOf(switchCompat.d);
}
@Override // android.util.Property
/* renamed from: b, reason: merged with bridge method [inline-methods] */
public void set(SwitchCompat switchCompat, Float f) {
switchCompat.b(f.floatValue());
}
};
private static final int[] e = {R.attr.state_checked};
private ColorStateList A;
private final Rect B;
private CharSequence C;
private final Yoi D;
private CharSequence E;
private int F;
private CharSequence G;
private final TextPaint H;
private Drawable I;
private int J;
private int K;
private ColorStateList L;
private PorterDuff.Mode M;
private int N;
private PorterDuff.Mode O;
private Drawable P;
private ColorStateList Q;
private float R;
private float S;
private VelocityTracker U;
ObjectAnimator b;
private WvB c;
float d;
private boolean f;
private boolean g;
private boolean h;
private RVV i;
private boolean j;
private int k;
private Layout l;
private boolean m;
private boolean n;
/* renamed from: o, reason: collision with root package name */
private Layout f6378o;
private int p;
private boolean q;
private int r;
private int s;
private int t;
private int u;
private int v;
private int w;
private int x;
private TransformationMethod y;
private CharSequence z;
private static float b(float f, float f2, float f3) {
return f >= f2 ? f > f3 ? f3 : f : f2;
}
public SwitchCompat(Context context) {
this(context, null);
}
public SwitchCompat(Context context, AttributeSet attributeSet) {
this(context, attributeSet, SYO.IeS.switchStyle);
}
public SwitchCompat(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.L = null;
this.M = null;
this.g = false;
this.j = false;
this.Q = null;
this.O = null;
this.f = false;
this.m = false;
this.U = VelocityTracker.obtain();
this.h = true;
this.B = new Rect();
nKv.b(getContext());
TextPaint textPaint = new TextPaint(1);
this.H = textPaint;
textPaint.density = getResources().getDisplayMetrics().density;
C0683McA c0683McA = new C0683McA(context, context.obtainStyledAttributes(attributeSet, SYO.ZqN.SwitchCompat, i, 0));
ViewCompat.sm_(this, context, SYO.ZqN.SwitchCompat, attributeSet, c0683McA.d, i, 0);
Drawable jL_ = c0683McA.jL_(SYO.ZqN.SwitchCompat_android_thumb);
this.I = jL_;
if (jL_ != null) {
jL_.setCallback(this);
}
Drawable jL_2 = c0683McA.jL_(SYO.ZqN.SwitchCompat_track);
this.P = jL_2;
if (jL_2 != null) {
jL_2.setCallback(this);
}
c(c0683McA.d.getText(SYO.ZqN.SwitchCompat_android_textOn));
d(c0683McA.d.getText(SYO.ZqN.SwitchCompat_android_textOff));
this.n = c0683McA.d.getBoolean(SYO.ZqN.SwitchCompat_showText, true);
this.F = c0683McA.d.getDimensionPixelSize(SYO.ZqN.SwitchCompat_thumbTextPadding, 0);
this.t = c0683McA.d.getDimensionPixelSize(SYO.ZqN.SwitchCompat_switchMinWidth, 0);
this.v = c0683McA.d.getDimensionPixelSize(SYO.ZqN.SwitchCompat_switchPadding, 0);
this.q = c0683McA.d.getBoolean(SYO.ZqN.SwitchCompat_splitTrack, false);
ColorStateList jK_ = c0683McA.jK_(SYO.ZqN.SwitchCompat_thumbTint);
if (jK_ != null) {
this.L = jK_;
this.g = true;
}
PorterDuff.Mode hZ_ = FIj.hZ_(c0683McA.d.getInt(SYO.ZqN.SwitchCompat_thumbTintMode, -1), null);
if (this.M != hZ_) {
this.M = hZ_;
this.j = true;
}
if (this.g || this.j) {
e();
}
ColorStateList jK_2 = c0683McA.jK_(SYO.ZqN.SwitchCompat_trackTint);
if (jK_2 != null) {
this.Q = jK_2;
this.f = true;
}
PorterDuff.Mode hZ_2 = FIj.hZ_(c0683McA.d.getInt(SYO.ZqN.SwitchCompat_trackTintMode, -1), null);
if (this.O != hZ_2) {
this.O = hZ_2;
this.m = true;
}
if (this.f || this.m) {
a();
}
int resourceId = c0683McA.d.getResourceId(SYO.ZqN.SwitchCompat_switchTextAppearance, 0);
if (resourceId != 0) {
setSwitchTextAppearance(context, resourceId);
}
Yoi yoi = new Yoi(this);
this.D = yoi;
yoi.he_(attributeSet, i);
c0683McA.d.recycle();
ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
this.J = viewConfiguration.getScaledTouchSlop();
this.k = viewConfiguration.getScaledMinimumFlingVelocity();
b().gm_(attributeSet, i);
refreshDrawableState();
setChecked(isChecked());
}
public void setSwitchTextAppearance(Context context, int i) {
C0683McA c0683McA = new C0683McA(context, context.obtainStyledAttributes(i, SYO.ZqN.TextAppearance));
ColorStateList jK_ = c0683McA.jK_(SYO.ZqN.TextAppearance_android_textColor);
if (jK_ != null) {
this.A = jK_;
} else {
this.A = getTextColors();
}
int dimensionPixelSize = c0683McA.d.getDimensionPixelSize(SYO.ZqN.TextAppearance_android_textSize, 0);
if (dimensionPixelSize != 0) {
float f = dimensionPixelSize;
if (f != this.H.getTextSize()) {
this.H.setTextSize(f);
requestLayout();
}
}
a(c0683McA.d.getInt(SYO.ZqN.TextAppearance_android_typeface, -1), c0683McA.d.getInt(SYO.ZqN.TextAppearance_android_textStyle, -1));
this.y = c0683McA.d.getBoolean(SYO.ZqN.TextAppearance_textAllCaps, false) ? new C4077bPV(getContext()) : null;
c(this.E);
d(this.C);
c0683McA.d.recycle();
}
private void a(int i, int i2) {
Typeface typeface;
if (i == 1) {
typeface = Typeface.SANS_SERIF;
} else if (i == 2) {
typeface = Typeface.SERIF;
} else {
typeface = i != 3 ? null : Typeface.MONOSPACE;
}
setSwitchTypeface(typeface, i2);
}
public void setSwitchTypeface(Typeface typeface, int i) {
Typeface create;
float f = BitmapDescriptorFactory.HUE_RED;
if (i > 0) {
if (typeface == null) {
create = Typeface.defaultFromStyle(i);
} else {
create = Typeface.create(typeface, i);
}
setSwitchTypeface(create);
int i2 = (~(create != null ? create.getStyle() : 0)) & i;
this.H.setFakeBoldText((i2 & 1) != 0);
TextPaint textPaint = this.H;
if ((i2 & 2) != 0) {
f = -0.25f;
}
textPaint.setTextSkewX(f);
return;
}
this.H.setFakeBoldText(false);
this.H.setTextSkewX(BitmapDescriptorFactory.HUE_RED);
setSwitchTypeface(typeface);
}
public void setSwitchTypeface(Typeface typeface) {
if ((this.H.getTypeface() == null || this.H.getTypeface().equals(typeface)) && (this.H.getTypeface() != null || typeface == null)) {
return;
}
this.H.setTypeface(typeface);
requestLayout();
invalidate();
}
public void setSwitchPadding(int i) {
this.v = i;
requestLayout();
}
public void setSwitchMinWidth(int i) {
this.t = i;
requestLayout();
}
public void setThumbTextPadding(int i) {
this.F = i;
requestLayout();
}
public void setTrackDrawable(Drawable drawable) {
Drawable drawable2 = this.P;
if (drawable2 != null) {
drawable2.setCallback(null);
}
this.P = drawable;
if (drawable != null) {
drawable.setCallback(this);
}
requestLayout();
}
public void setTrackResource(int i) {
setTrackDrawable(AgY.dT_(getContext(), i));
}
public void setTrackTintList(ColorStateList colorStateList) {
this.Q = colorStateList;
this.f = true;
a();
}
public void setTrackTintMode(PorterDuff.Mode mode) {
this.O = mode;
this.m = true;
a();
}
private void a() {
Drawable drawable = this.P;
if (drawable != null) {
if (this.f || this.m) {
Drawable mutate = Tlu.pI_(drawable).mutate();
this.P = mutate;
if (this.f) {
Tlu.pF_(mutate, this.Q);
}
if (this.m) {
Tlu.pG_(this.P, this.O);
}
if (this.P.isStateful()) {
this.P.setState(getDrawableState());
}
}
}
}
public void setThumbDrawable(Drawable drawable) {
Drawable drawable2 = this.I;
if (drawable2 != null) {
drawable2.setCallback(null);
}
this.I = drawable;
if (drawable != null) {
drawable.setCallback(this);
}
requestLayout();
}
public void setThumbResource(int i) {
setThumbDrawable(AgY.dT_(getContext(), i));
}
public void setThumbTintList(ColorStateList colorStateList) {
this.L = colorStateList;
this.g = true;
e();
}
public void setThumbTintMode(PorterDuff.Mode mode) {
this.M = mode;
this.j = true;
e();
}
private void e() {
Drawable drawable = this.I;
if (drawable != null) {
if (this.g || this.j) {
Drawable mutate = Tlu.pI_(drawable).mutate();
this.I = mutate;
if (this.g) {
Tlu.pF_(mutate, this.L);
}
if (this.j) {
Tlu.pG_(this.I, this.M);
}
if (this.I.isStateful()) {
this.I.setState(getDrawableState());
}
}
}
}
public void setSplitTrack(boolean z) {
this.q = z;
invalidate();
}
private void c(CharSequence charSequence) {
this.E = charSequence;
this.G = a(charSequence);
this.f6378o = null;
if (this.n) {
m();
}
}
public void setTextOn(CharSequence charSequence) {
c(charSequence);
requestLayout();
if (isChecked()) {
j();
}
}
private void d(CharSequence charSequence) {
this.C = charSequence;
this.z = a(charSequence);
this.l = null;
if (this.n) {
m();
}
}
public void setTextOff(CharSequence charSequence) {
d(charSequence);
requestLayout();
if (isChecked()) {
return;
}
h();
}
private CharSequence a(CharSequence charSequence) {
TransformationMethod gn_ = b().gn_(this.y);
return gn_ != null ? gn_.getTransformation(charSequence, this) : charSequence;
}
public void setShowText(boolean z) {
if (this.n != z) {
this.n = z;
requestLayout();
if (z) {
m();
}
}
}
@Override // android.widget.TextView, android.view.View
public void onMeasure(int i, int i2) {
int i3;
int i4;
if (this.n) {
if (this.f6378o == null) {
this.f6378o = jG_(this.G);
}
if (this.l == null) {
this.l = jG_(this.z);
}
}
Rect rect = this.B;
Drawable drawable = this.I;
int i5 = 0;
if (drawable != null) {
drawable.getPadding(rect);
i3 = (this.I.getIntrinsicWidth() - rect.left) - rect.right;
i4 = this.I.getIntrinsicHeight();
} else {
i3 = 0;
i4 = 0;
}
this.K = Math.max(this.n ? Math.max(this.f6378o.getWidth(), this.l.getWidth()) + (this.F << 1) : 0, i3);
Drawable drawable2 = this.P;
if (drawable2 != null) {
drawable2.getPadding(rect);
i5 = this.P.getIntrinsicHeight();
} else {
rect.setEmpty();
}
int i6 = rect.left;
int i7 = rect.right;
Drawable drawable3 = this.I;
if (drawable3 != null) {
Rect hY_ = FIj.hY_(drawable3);
i6 = Math.max(i6, hY_.left);
i7 = Math.max(i7, hY_.right);
}
int max = this.h ? Math.max(this.t, (this.K << 1) + i6 + i7) : this.t;
int max2 = Math.max(i5, i4);
this.x = max;
this.s = max2;
super.onMeasure(i, i2);
if (getMeasuredHeight() < max2) {
setMeasuredDimension(getMeasuredWidthAndState(), max2);
}
}
@Override // android.view.View
public void onPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
super.onPopulateAccessibilityEvent(accessibilityEvent);
CharSequence charSequence = isChecked() ? this.E : this.C;
if (charSequence != null) {
accessibilityEvent.getText().add(charSequence);
}
}
private Layout jG_(CharSequence charSequence) {
return new StaticLayout(charSequence, this.H, charSequence != null ? (int) Math.ceil(Layout.getDesiredWidth(charSequence, r2)) : 0, Layout.Alignment.ALIGN_NORMAL, 1.0f, BitmapDescriptorFactory.HUE_RED, true);
}
private boolean d(float f, float f2) {
if (this.I == null) {
return false;
}
int f3 = f();
this.I.getPadding(this.B);
int i = this.w;
int i2 = this.J;
int i3 = (this.p + f3) - i2;
int i4 = this.K;
int i5 = this.B.left;
int i6 = this.B.right;
int i7 = this.J;
return f > ((float) i3) && f < ((float) ((((i4 + i3) + i5) + i6) + i7)) && f2 > ((float) (i - i2)) && f2 < ((float) (this.r + i7));
}
/* JADX WARN: Code restructure failed: missing block: B:7:0x0012, code lost:
if (r0 != 3) goto L43;
*/
@Override // android.widget.TextView, android.view.View
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public boolean onTouchEvent(android.view.MotionEvent r7) {
/*
r6 = this;
android.view.VelocityTracker r0 = r6.U
r0.addMovement(r7)
int r0 = r7.getActionMasked()
r1 = 1
if (r0 == 0) goto L9a
r2 = 2
if (r0 == r1) goto L86
if (r0 == r2) goto L16
r3 = 3
if (r0 == r3) goto L86
goto Lb4
L16:
int r0 = r6.N
if (r0 == r1) goto L52
if (r0 != r2) goto Lb4
float r7 = r7.getX()
int r0 = r6.g()
float r2 = r6.R
float r2 = r7 - r2
r3 = 1065353216(0x3f800000, float:1.0)
r4 = 0
if (r0 == 0) goto L30
float r0 = (float) r0
float r2 = r2 / r0
goto L38
L30:
int r0 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
if (r0 <= 0) goto L36
r2 = r3
goto L38
L36:
r2 = -1082130432(0xffffffffbf800000, float:-1.0)
L38:
boolean r0 = o.mxt.b(r6)
if (r0 == 0) goto L3f
float r2 = -r2
L3f:
float r0 = r6.d
float r0 = r0 + r2
float r0 = b(r0, r4, r3)
float r2 = r6.d
int r2 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
if (r2 == 0) goto L51
r6.R = r7
r6.b(r0)
L51:
return r1
L52:
float r0 = r7.getX()
float r3 = r7.getY()
float r4 = r6.R
float r4 = r0 - r4
float r4 = java.lang.Math.abs(r4)
int r5 = r6.J
float r5 = (float) r5
int r4 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1))
if (r4 > 0) goto L78
float r4 = r6.S
float r4 = r3 - r4
float r4 = java.lang.Math.abs(r4)
int r5 = r6.J
float r5 = (float) r5
int r4 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1))
if (r4 <= 0) goto Lb4
L78:
r6.N = r2
android.view.ViewParent r7 = r6.getParent()
r7.requestDisallowInterceptTouchEvent(r1)
r6.R = r0
r6.S = r3
return r1
L86:
int r0 = r6.N
if (r0 != r2) goto L91
r6.jH_(r7)
super.onTouchEvent(r7)
return r1
L91:
r0 = 0
r6.N = r0
android.view.VelocityTracker r0 = r6.U
r0.clear()
goto Lb4
L9a:
float r0 = r7.getX()
float r2 = r7.getY()
boolean r3 = r6.isEnabled()
if (r3 == 0) goto Lb4
boolean r3 = r6.d(r0, r2)
if (r3 == 0) goto Lb4
r6.N = r1
r6.R = r0
r6.S = r2
Lb4:
boolean r7 = super.onTouchEvent(r7)
return r7
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.SwitchCompat.onTouchEvent(android.view.MotionEvent):boolean");
}
private void jF_(MotionEvent motionEvent) {
MotionEvent obtain = MotionEvent.obtain(motionEvent);
obtain.setAction(3);
super.onTouchEvent(obtain);
obtain.recycle();
}
private void jH_(MotionEvent motionEvent) {
this.N = 0;
boolean z = true;
boolean z2 = motionEvent.getAction() == 1 && isEnabled();
boolean isChecked = isChecked();
if (z2) {
this.U.computeCurrentVelocity(1000);
float xVelocity = this.U.getXVelocity();
if (Math.abs(xVelocity) > this.k) {
if (!mxt.b(this) ? xVelocity <= BitmapDescriptorFactory.HUE_RED : xVelocity >= BitmapDescriptorFactory.HUE_RED) {
z = false;
}
} else {
z = i();
}
} else {
z = isChecked;
}
if (z != isChecked) {
playSoundEffect(0);
}
setChecked(z);
jF_(motionEvent);
}
private void a(boolean z) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, a, z ? 1.0f : BitmapDescriptorFactory.HUE_RED);
this.b = ofFloat;
ofFloat.setDuration(250L);
LWm.jI_(this.b, true);
this.b.start();
}
private void d() {
ObjectAnimator objectAnimator = this.b;
if (objectAnimator != null) {
objectAnimator.cancel();
}
}
void b(float f) {
this.d = f;
invalidate();
}
@Override // android.widget.CompoundButton, android.widget.Checkable
public void toggle() {
setChecked(!isChecked());
}
@Override // android.widget.CompoundButton, android.widget.Checkable
public void setChecked(boolean z) {
super.setChecked(z);
boolean isChecked = isChecked();
if (isChecked) {
j();
} else {
h();
}
if (getWindowToken() != null && ViewCompat.G(this)) {
a(isChecked);
} else {
d();
b(isChecked ? 1.0f : BitmapDescriptorFactory.HUE_RED);
}
}
@Override // android.widget.TextView, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5;
int width;
int i6;
int i7;
int i8;
int i9;
int i10;
super.onLayout(z, i, i2, i3, i4);
int i11 = 0;
if (this.I != null) {
Rect rect = this.B;
Drawable drawable = this.P;
if (drawable != null) {
drawable.getPadding(rect);
} else {
rect.setEmpty();
}
Rect hY_ = FIj.hY_(this.I);
i5 = Math.max(0, hY_.left - rect.left);
i11 = Math.max(0, hY_.right - rect.right);
} else {
i5 = 0;
}
if (mxt.b(this)) {
i6 = getPaddingLeft() + i5;
width = ((this.x + i6) - i5) - i11;
} else {
width = (getWidth() - getPaddingRight()) - i11;
i6 = (width - this.x) + i5 + i11;
}
int gravity = getGravity() & 112;
if (gravity == 16) {
int paddingTop = ((getPaddingTop() + getHeight()) - getPaddingBottom()) / 2;
i7 = this.s;
i8 = paddingTop - (i7 / 2);
} else if (gravity != 80) {
i8 = getPaddingTop();
i7 = this.s;
} else {
i10 = getHeight() - getPaddingBottom();
i9 = i10 - this.s;
this.p = i6;
this.w = i9;
this.r = i10;
this.u = width;
}
int i12 = i7 + i8;
i9 = i8;
i10 = i12;
this.p = i6;
this.w = i9;
this.r = i10;
this.u = width;
}
@Override // android.view.View
public void draw(Canvas canvas) {
Rect rect;
int i;
int i2;
Rect rect2 = this.B;
int i3 = this.p;
int i4 = this.w;
int i5 = this.u;
int i6 = this.r;
int f = f() + i3;
Drawable drawable = this.I;
if (drawable != null) {
rect = FIj.hY_(drawable);
} else {
rect = FIj.d;
}
Drawable drawable2 = this.P;
if (drawable2 != null) {
drawable2.getPadding(rect2);
f += rect2.left;
if (rect != null) {
if (rect.left > rect2.left) {
i3 += rect.left - rect2.left;
}
i = rect.top > rect2.top ? (rect.top - rect2.top) + i4 : i4;
if (rect.right > rect2.right) {
i5 -= rect.right - rect2.right;
}
if (rect.bottom > rect2.bottom) {
i2 = i6 - (rect.bottom - rect2.bottom);
this.P.setBounds(i3, i, i5, i2);
}
} else {
i = i4;
}
i2 = i6;
this.P.setBounds(i3, i, i5, i2);
}
Drawable drawable3 = this.I;
if (drawable3 != null) {
drawable3.getPadding(rect2);
int i7 = f - rect2.left;
int i8 = f + this.K + rect2.right;
this.I.setBounds(i7, i4, i8, i6);
Drawable background = getBackground();
if (background != null) {
Tlu.pC_(background, i7, i4, i8, i6);
}
}
super.draw(canvas);
}
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
protected void onDraw(Canvas canvas) {
int width;
super.onDraw(canvas);
Rect rect = this.B;
Drawable drawable = this.P;
if (drawable != null) {
drawable.getPadding(rect);
} else {
rect.setEmpty();
}
int i = this.w;
int i2 = this.r;
int i3 = rect.top;
int i4 = rect.bottom;
Drawable drawable2 = this.I;
if (drawable != null) {
if (this.q && drawable2 != null) {
Rect hY_ = FIj.hY_(drawable2);
drawable2.copyBounds(rect);
rect.left += hY_.left;
rect.right -= hY_.right;
int save = canvas.save();
canvas.clipRect(rect, Region.Op.DIFFERENCE);
drawable.draw(canvas);
canvas.restoreToCount(save);
} else {
drawable.draw(canvas);
}
}
int save2 = canvas.save();
if (drawable2 != null) {
drawable2.draw(canvas);
}
Layout layout = i() ? this.f6378o : this.l;
if (layout != null) {
int[] drawableState = getDrawableState();
ColorStateList colorStateList = this.A;
if (colorStateList != null) {
this.H.setColor(colorStateList.getColorForState(drawableState, 0));
}
this.H.drawableState = drawableState;
if (drawable2 != null) {
Rect bounds = drawable2.getBounds();
width = bounds.left + bounds.right;
} else {
width = getWidth();
}
canvas.translate((width / 2) - (layout.getWidth() / 2), (((i + i3) + (i2 - i4)) / 2) - (layout.getHeight() / 2));
layout.draw(canvas);
}
canvas.restoreToCount(save2);
}
@Override // android.widget.CompoundButton, android.widget.TextView
public int getCompoundPaddingLeft() {
if (!mxt.b(this)) {
return super.getCompoundPaddingLeft();
}
int compoundPaddingLeft = super.getCompoundPaddingLeft() + this.x;
return !TextUtils.isEmpty(getText()) ? compoundPaddingLeft + this.v : compoundPaddingLeft;
}
@Override // android.widget.CompoundButton, android.widget.TextView
public int getCompoundPaddingRight() {
if (mxt.b(this)) {
return super.getCompoundPaddingRight();
}
int compoundPaddingRight = super.getCompoundPaddingRight() + this.x;
return !TextUtils.isEmpty(getText()) ? compoundPaddingRight + this.v : compoundPaddingRight;
}
private int f() {
return (int) (((mxt.b(this) ? 1.0f - this.d : this.d) * g()) + 0.5f);
}
private int g() {
Rect rect;
Drawable drawable = this.P;
if (drawable == null) {
return 0;
}
Rect rect2 = this.B;
drawable.getPadding(rect2);
Drawable drawable2 = this.I;
if (drawable2 != null) {
rect = FIj.hY_(drawable2);
} else {
rect = FIj.d;
}
return ((((this.x - this.K) - rect2.left) - rect2.right) - rect.left) - rect.right;
}
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
protected int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 1);
if (isChecked()) {
mergeDrawableStates(onCreateDrawableState, e);
}
return onCreateDrawableState;
}
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
int[] drawableState = getDrawableState();
Drawable drawable = this.I;
boolean state = (drawable == null || !drawable.isStateful()) ? false : drawable.setState(drawableState);
Drawable drawable2 = this.P;
if (drawable2 != null && drawable2.isStateful()) {
state |= drawable2.setState(drawableState);
}
if (state) {
invalidate();
}
}
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
public void drawableHotspotChanged(float f, float f2) {
super.drawableHotspotChanged(f, f2);
Drawable drawable = this.I;
if (drawable != null) {
Tlu.pB_(drawable, f, f2);
}
Drawable drawable2 = this.P;
if (drawable2 != null) {
Tlu.pB_(drawable2, f, f2);
}
}
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
protected boolean verifyDrawable(Drawable drawable) {
return super.verifyDrawable(drawable) || drawable == this.I || drawable == this.P;
}
@Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
public void jumpDrawablesToCurrentState() {
super.jumpDrawablesToCurrentState();
Drawable drawable = this.I;
if (drawable != null) {
drawable.jumpToCurrentState();
}
Drawable drawable2 = this.P;
if (drawable2 != null) {
drawable2.jumpToCurrentState();
}
ObjectAnimator objectAnimator = this.b;
if (objectAnimator == null || !objectAnimator.isStarted()) {
return;
}
this.b.end();
this.b = null;
}
@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");
if (Build.VERSION.SDK_INT < 30) {
CharSequence charSequence = isChecked() ? this.E : this.C;
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
public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
super.setCustomSelectionActionModeCallback(URz.wh_(this, callback));
}
@Override // android.widget.TextView
public ActionMode.Callback getCustomSelectionActionModeCallback() {
return URz.wg_(super.getCustomSelectionActionModeCallback());
}
private void j() {
if (Build.VERSION.SDK_INT >= 30) {
CharSequence charSequence = this.E;
if (charSequence == null) {
charSequence = getResources().getString(SYO.tOB.abc_capital_on);
}
ViewCompat.e(this, charSequence);
}
}
private void h() {
if (Build.VERSION.SDK_INT >= 30) {
CharSequence charSequence = this.C;
if (charSequence == null) {
charSequence = getResources().getString(SYO.tOB.abc_capital_off);
}
ViewCompat.e(this, charSequence);
}
}
@Override // android.widget.TextView
public void setAllCaps(boolean z) {
super.setAllCaps(z);
b().e(z);
}
@Override // android.widget.TextView
public void setFilters(InputFilter[] inputFilterArr) {
super.setFilters(b().gl_(inputFilterArr));
}
private WvB b() {
if (this.c == null) {
this.c = new WvB(this);
}
return this.c;
}
public void setEmojiCompatEnabled(boolean z) {
b().a(z);
c(this.E);
d(this.C);
requestLayout();
}
private void m() {
if (this.i == null && this.c.b() && C16349neT.b()) {
C16349neT e2 = C16349neT.e();
int a2 = e2.a();
if (a2 == 3 || a2 == 0) {
RVV rvv = new RVV(this);
this.i = rvv;
e2.c(rvv);
}
}
}
void c() {
c(this.E);
d(this.C);
requestLayout();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class RVV extends C16349neT.IeS {
private final Reference<SwitchCompat> d;
RVV(SwitchCompat switchCompat) {
this.d = new WeakReference(switchCompat);
}
@Override // o.C16349neT.IeS
public void b() {
SwitchCompat switchCompat = this.d.get();
if (switchCompat != null) {
switchCompat.c();
}
}
@Override // o.C16349neT.IeS
public void c(Throwable th) {
SwitchCompat switchCompat = this.d.get();
if (switchCompat != null) {
switchCompat.c();
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class LWm {
static void jI_(ObjectAnimator objectAnimator, boolean z) {
objectAnimator.setAutoCancel(z);
}
}
private boolean i() {
return this.d > 0.5f;
}
}