1158 lines
		
	
	
		
			43 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			1158 lines
		
	
	
		
			43 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| 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.appcompat.content.res.AppCompatResources;
 | |
| import androidx.appcompat.text.AllCapsTransformationMethod;
 | |
| import androidx.core.graphics.drawable.DrawableCompat;
 | |
| import androidx.core.view.ViewCompat;
 | |
| import androidx.core.widget.TextViewCompat;
 | |
| import androidx.emoji2.text.EmojiCompat;
 | |
| import java.lang.ref.Reference;
 | |
| import java.lang.ref.WeakReference;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| public class SwitchCompat extends CompoundButton implements EmojiCompatConfigurationView {
 | |
|     private static final String ACCESSIBILITY_EVENT_CLASS_NAME = "android.widget.Switch";
 | |
|     private static final int MONOSPACE = 3;
 | |
|     private static final int SANS = 1;
 | |
|     private static final int SERIF = 2;
 | |
|     private static final int THUMB_ANIMATION_DURATION = 250;
 | |
|     private static final int TOUCH_MODE_DOWN = 1;
 | |
|     private static final int TOUCH_MODE_DRAGGING = 2;
 | |
|     private static final int TOUCH_MODE_IDLE = 0;
 | |
|     private AppCompatEmojiTextHelper mAppCompatEmojiTextHelper;
 | |
|     private EmojiCompatInitCallback mEmojiCompatInitCallback;
 | |
|     private boolean mEnforceSwitchWidth;
 | |
|     private boolean mHasThumbTint;
 | |
|     private boolean mHasThumbTintMode;
 | |
|     private boolean mHasTrackTint;
 | |
|     private boolean mHasTrackTintMode;
 | |
|     private int mMinFlingVelocity;
 | |
|     private Layout mOffLayout;
 | |
|     private Layout mOnLayout;
 | |
|     ObjectAnimator mPositionAnimator;
 | |
|     private boolean mShowText;
 | |
|     private boolean mSplitTrack;
 | |
|     private int mSwitchBottom;
 | |
|     private int mSwitchHeight;
 | |
|     private int mSwitchLeft;
 | |
|     private int mSwitchMinWidth;
 | |
|     private int mSwitchPadding;
 | |
|     private int mSwitchRight;
 | |
|     private int mSwitchTop;
 | |
|     private TransformationMethod mSwitchTransformationMethod;
 | |
|     private int mSwitchWidth;
 | |
|     private final Rect mTempRect;
 | |
|     private ColorStateList mTextColors;
 | |
|     private final AppCompatTextHelper mTextHelper;
 | |
|     private CharSequence mTextOff;
 | |
|     private CharSequence mTextOffTransformed;
 | |
|     private CharSequence mTextOn;
 | |
|     private CharSequence mTextOnTransformed;
 | |
|     private final TextPaint mTextPaint;
 | |
|     private Drawable mThumbDrawable;
 | |
|     float mThumbPosition;
 | |
|     private int mThumbTextPadding;
 | |
|     private ColorStateList mThumbTintList;
 | |
|     private PorterDuff.Mode mThumbTintMode;
 | |
|     private int mThumbWidth;
 | |
|     private int mTouchMode;
 | |
|     private int mTouchSlop;
 | |
|     private float mTouchX;
 | |
|     private float mTouchY;
 | |
|     private Drawable mTrackDrawable;
 | |
|     private ColorStateList mTrackTintList;
 | |
|     private PorterDuff.Mode mTrackTintMode;
 | |
|     private VelocityTracker mVelocityTracker;
 | |
|     private static final Property<SwitchCompat, Float> THUMB_POS = new Property<SwitchCompat, Float>(Float.class, "thumbPos") { // from class: androidx.appcompat.widget.SwitchCompat.1
 | |
|         @Override // android.util.Property
 | |
|         public Float get(SwitchCompat switchCompat) {
 | |
|             return Float.valueOf(switchCompat.mThumbPosition);
 | |
|         }
 | |
| 
 | |
|         @Override // android.util.Property
 | |
|         public void set(SwitchCompat switchCompat, Float f) {
 | |
|             switchCompat.setThumbPosition(f.floatValue());
 | |
|         }
 | |
|     };
 | |
|     private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
 | |
| 
 | |
|     private static float constrain(float f, float f2, float f3) {
 | |
|         return f < f2 ? f2 : f > f3 ? f3 : f;
 | |
|     }
 | |
| 
 | |
|     private boolean getTargetCheckedState() {
 | |
|         return this.mThumbPosition > 0.5f;
 | |
|     }
 | |
| 
 | |
|     public boolean getShowText() {
 | |
|         return this.mShowText;
 | |
|     }
 | |
| 
 | |
|     public boolean getSplitTrack() {
 | |
|         return this.mSplitTrack;
 | |
|     }
 | |
| 
 | |
|     public int getSwitchMinWidth() {
 | |
|         return this.mSwitchMinWidth;
 | |
|     }
 | |
| 
 | |
|     public int getSwitchPadding() {
 | |
|         return this.mSwitchPadding;
 | |
|     }
 | |
| 
 | |
|     public CharSequence getTextOff() {
 | |
|         return this.mTextOff;
 | |
|     }
 | |
| 
 | |
|     public CharSequence getTextOn() {
 | |
|         return this.mTextOn;
 | |
|     }
 | |
| 
 | |
|     public Drawable getThumbDrawable() {
 | |
|         return this.mThumbDrawable;
 | |
|     }
 | |
| 
 | |
|     protected final float getThumbPosition() {
 | |
|         return this.mThumbPosition;
 | |
|     }
 | |
| 
 | |
|     public int getThumbTextPadding() {
 | |
|         return this.mThumbTextPadding;
 | |
|     }
 | |
| 
 | |
|     public ColorStateList getThumbTintList() {
 | |
|         return this.mThumbTintList;
 | |
|     }
 | |
| 
 | |
|     public PorterDuff.Mode getThumbTintMode() {
 | |
|         return this.mThumbTintMode;
 | |
|     }
 | |
| 
 | |
|     public Drawable getTrackDrawable() {
 | |
|         return this.mTrackDrawable;
 | |
|     }
 | |
| 
 | |
|     public ColorStateList getTrackTintList() {
 | |
|         return this.mTrackTintList;
 | |
|     }
 | |
| 
 | |
|     public PorterDuff.Mode getTrackTintMode() {
 | |
|         return this.mTrackTintMode;
 | |
|     }
 | |
| 
 | |
|     public SwitchCompat(Context context) {
 | |
|         this(context, null);
 | |
|     }
 | |
| 
 | |
|     public SwitchCompat(Context context, AttributeSet attributeSet) {
 | |
|         this(context, attributeSet, androidx.appcompat.R.attr.switchStyle);
 | |
|     }
 | |
| 
 | |
|     public SwitchCompat(Context context, AttributeSet attributeSet, int i) {
 | |
|         super(context, attributeSet, i);
 | |
|         this.mThumbTintList = null;
 | |
|         this.mThumbTintMode = null;
 | |
|         this.mHasThumbTint = false;
 | |
|         this.mHasThumbTintMode = false;
 | |
|         this.mTrackTintList = null;
 | |
|         this.mTrackTintMode = null;
 | |
|         this.mHasTrackTint = false;
 | |
|         this.mHasTrackTintMode = false;
 | |
|         this.mVelocityTracker = VelocityTracker.obtain();
 | |
|         this.mEnforceSwitchWidth = true;
 | |
|         this.mTempRect = new Rect();
 | |
|         ThemeUtils.checkAppCompatTheme(this, getContext());
 | |
|         TextPaint textPaint = new TextPaint(1);
 | |
|         this.mTextPaint = textPaint;
 | |
|         textPaint.density = getResources().getDisplayMetrics().density;
 | |
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, androidx.appcompat.R.styleable.SwitchCompat, i, 0);
 | |
|         ViewCompat.saveAttributeDataForStyleable(this, context, androidx.appcompat.R.styleable.SwitchCompat, attributeSet, obtainStyledAttributes.getWrappedTypeArray(), i, 0);
 | |
|         Drawable drawable = obtainStyledAttributes.getDrawable(androidx.appcompat.R.styleable.SwitchCompat_android_thumb);
 | |
|         this.mThumbDrawable = drawable;
 | |
|         if (drawable != null) {
 | |
|             drawable.setCallback(this);
 | |
|         }
 | |
|         Drawable drawable2 = obtainStyledAttributes.getDrawable(androidx.appcompat.R.styleable.SwitchCompat_track);
 | |
|         this.mTrackDrawable = drawable2;
 | |
|         if (drawable2 != null) {
 | |
|             drawable2.setCallback(this);
 | |
|         }
 | |
|         setTextOnInternal(obtainStyledAttributes.getText(androidx.appcompat.R.styleable.SwitchCompat_android_textOn));
 | |
|         setTextOffInternal(obtainStyledAttributes.getText(androidx.appcompat.R.styleable.SwitchCompat_android_textOff));
 | |
|         this.mShowText = obtainStyledAttributes.getBoolean(androidx.appcompat.R.styleable.SwitchCompat_showText, true);
 | |
|         this.mThumbTextPadding = obtainStyledAttributes.getDimensionPixelSize(androidx.appcompat.R.styleable.SwitchCompat_thumbTextPadding, 0);
 | |
|         this.mSwitchMinWidth = obtainStyledAttributes.getDimensionPixelSize(androidx.appcompat.R.styleable.SwitchCompat_switchMinWidth, 0);
 | |
|         this.mSwitchPadding = obtainStyledAttributes.getDimensionPixelSize(androidx.appcompat.R.styleable.SwitchCompat_switchPadding, 0);
 | |
|         this.mSplitTrack = obtainStyledAttributes.getBoolean(androidx.appcompat.R.styleable.SwitchCompat_splitTrack, false);
 | |
|         ColorStateList colorStateList = obtainStyledAttributes.getColorStateList(androidx.appcompat.R.styleable.SwitchCompat_thumbTint);
 | |
|         if (colorStateList != null) {
 | |
|             this.mThumbTintList = colorStateList;
 | |
|             this.mHasThumbTint = true;
 | |
|         }
 | |
|         PorterDuff.Mode parseTintMode = DrawableUtils.parseTintMode(obtainStyledAttributes.getInt(androidx.appcompat.R.styleable.SwitchCompat_thumbTintMode, -1), null);
 | |
|         if (this.mThumbTintMode != parseTintMode) {
 | |
|             this.mThumbTintMode = parseTintMode;
 | |
|             this.mHasThumbTintMode = true;
 | |
|         }
 | |
|         if (this.mHasThumbTint || this.mHasThumbTintMode) {
 | |
|             applyThumbTint();
 | |
|         }
 | |
|         ColorStateList colorStateList2 = obtainStyledAttributes.getColorStateList(androidx.appcompat.R.styleable.SwitchCompat_trackTint);
 | |
|         if (colorStateList2 != null) {
 | |
|             this.mTrackTintList = colorStateList2;
 | |
|             this.mHasTrackTint = true;
 | |
|         }
 | |
|         PorterDuff.Mode parseTintMode2 = DrawableUtils.parseTintMode(obtainStyledAttributes.getInt(androidx.appcompat.R.styleable.SwitchCompat_trackTintMode, -1), null);
 | |
|         if (this.mTrackTintMode != parseTintMode2) {
 | |
|             this.mTrackTintMode = parseTintMode2;
 | |
|             this.mHasTrackTintMode = true;
 | |
|         }
 | |
|         if (this.mHasTrackTint || this.mHasTrackTintMode) {
 | |
|             applyTrackTint();
 | |
|         }
 | |
|         int resourceId = obtainStyledAttributes.getResourceId(androidx.appcompat.R.styleable.SwitchCompat_switchTextAppearance, 0);
 | |
|         if (resourceId != 0) {
 | |
|             setSwitchTextAppearance(context, resourceId);
 | |
|         }
 | |
|         AppCompatTextHelper appCompatTextHelper = new AppCompatTextHelper(this);
 | |
|         this.mTextHelper = appCompatTextHelper;
 | |
|         appCompatTextHelper.loadFromAttributes(attributeSet, i);
 | |
|         obtainStyledAttributes.recycle();
 | |
|         ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
 | |
|         this.mTouchSlop = viewConfiguration.getScaledTouchSlop();
 | |
|         this.mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
 | |
|         getEmojiTextViewHelper().loadFromAttributes(attributeSet, i);
 | |
|         refreshDrawableState();
 | |
|         setChecked(isChecked());
 | |
|     }
 | |
| 
 | |
|     public void setSwitchTextAppearance(Context context, int i) {
 | |
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, i, androidx.appcompat.R.styleable.TextAppearance);
 | |
|         ColorStateList colorStateList = obtainStyledAttributes.getColorStateList(androidx.appcompat.R.styleable.TextAppearance_android_textColor);
 | |
|         if (colorStateList != null) {
 | |
|             this.mTextColors = colorStateList;
 | |
|         } else {
 | |
|             this.mTextColors = getTextColors();
 | |
|         }
 | |
|         int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(androidx.appcompat.R.styleable.TextAppearance_android_textSize, 0);
 | |
|         if (dimensionPixelSize != 0) {
 | |
|             float f = dimensionPixelSize;
 | |
|             if (f != this.mTextPaint.getTextSize()) {
 | |
|                 this.mTextPaint.setTextSize(f);
 | |
|                 requestLayout();
 | |
|             }
 | |
|         }
 | |
|         setSwitchTypefaceByIndex(obtainStyledAttributes.getInt(androidx.appcompat.R.styleable.TextAppearance_android_typeface, -1), obtainStyledAttributes.getInt(androidx.appcompat.R.styleable.TextAppearance_android_textStyle, -1));
 | |
|         if (obtainStyledAttributes.getBoolean(androidx.appcompat.R.styleable.TextAppearance_textAllCaps, false)) {
 | |
|             this.mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext());
 | |
|         } else {
 | |
|             this.mSwitchTransformationMethod = null;
 | |
|         }
 | |
|         setTextOnInternal(this.mTextOn);
 | |
|         setTextOffInternal(this.mTextOff);
 | |
|         obtainStyledAttributes.recycle();
 | |
|     }
 | |
| 
 | |
|     private void setSwitchTypefaceByIndex(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;
 | |
|         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.mTextPaint.setFakeBoldText((i2 & 1) != 0);
 | |
|             this.mTextPaint.setTextSkewX((i2 & 2) != 0 ? -0.25f : 0.0f);
 | |
|             return;
 | |
|         }
 | |
|         this.mTextPaint.setFakeBoldText(false);
 | |
|         this.mTextPaint.setTextSkewX(0.0f);
 | |
|         setSwitchTypeface(typeface);
 | |
|     }
 | |
| 
 | |
|     public void setSwitchTypeface(Typeface typeface) {
 | |
|         if ((this.mTextPaint.getTypeface() == null || this.mTextPaint.getTypeface().equals(typeface)) && (this.mTextPaint.getTypeface() != null || typeface == null)) {
 | |
|             return;
 | |
|         }
 | |
|         this.mTextPaint.setTypeface(typeface);
 | |
|         requestLayout();
 | |
|         invalidate();
 | |
|     }
 | |
| 
 | |
|     public void setSwitchPadding(int i) {
 | |
|         this.mSwitchPadding = i;
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     public void setSwitchMinWidth(int i) {
 | |
|         this.mSwitchMinWidth = i;
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     public void setThumbTextPadding(int i) {
 | |
|         this.mThumbTextPadding = i;
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     public void setTrackDrawable(Drawable drawable) {
 | |
|         Drawable drawable2 = this.mTrackDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             drawable2.setCallback(null);
 | |
|         }
 | |
|         this.mTrackDrawable = drawable;
 | |
|         if (drawable != null) {
 | |
|             drawable.setCallback(this);
 | |
|         }
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     public void setTrackResource(int i) {
 | |
|         setTrackDrawable(AppCompatResources.getDrawable(getContext(), i));
 | |
|     }
 | |
| 
 | |
|     public void setTrackTintList(ColorStateList colorStateList) {
 | |
|         this.mTrackTintList = colorStateList;
 | |
|         this.mHasTrackTint = true;
 | |
|         applyTrackTint();
 | |
|     }
 | |
| 
 | |
|     public void setTrackTintMode(PorterDuff.Mode mode) {
 | |
|         this.mTrackTintMode = mode;
 | |
|         this.mHasTrackTintMode = true;
 | |
|         applyTrackTint();
 | |
|     }
 | |
| 
 | |
|     private void applyTrackTint() {
 | |
|         Drawable drawable = this.mTrackDrawable;
 | |
|         if (drawable != null) {
 | |
|             if (this.mHasTrackTint || this.mHasTrackTintMode) {
 | |
|                 Drawable mutate = DrawableCompat.wrap(drawable).mutate();
 | |
|                 this.mTrackDrawable = mutate;
 | |
|                 if (this.mHasTrackTint) {
 | |
|                     DrawableCompat.setTintList(mutate, this.mTrackTintList);
 | |
|                 }
 | |
|                 if (this.mHasTrackTintMode) {
 | |
|                     DrawableCompat.setTintMode(this.mTrackDrawable, this.mTrackTintMode);
 | |
|                 }
 | |
|                 if (this.mTrackDrawable.isStateful()) {
 | |
|                     this.mTrackDrawable.setState(getDrawableState());
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void setThumbDrawable(Drawable drawable) {
 | |
|         Drawable drawable2 = this.mThumbDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             drawable2.setCallback(null);
 | |
|         }
 | |
|         this.mThumbDrawable = drawable;
 | |
|         if (drawable != null) {
 | |
|             drawable.setCallback(this);
 | |
|         }
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     public void setThumbResource(int i) {
 | |
|         setThumbDrawable(AppCompatResources.getDrawable(getContext(), i));
 | |
|     }
 | |
| 
 | |
|     public void setThumbTintList(ColorStateList colorStateList) {
 | |
|         this.mThumbTintList = colorStateList;
 | |
|         this.mHasThumbTint = true;
 | |
|         applyThumbTint();
 | |
|     }
 | |
| 
 | |
|     public void setThumbTintMode(PorterDuff.Mode mode) {
 | |
|         this.mThumbTintMode = mode;
 | |
|         this.mHasThumbTintMode = true;
 | |
|         applyThumbTint();
 | |
|     }
 | |
| 
 | |
|     private void applyThumbTint() {
 | |
|         Drawable drawable = this.mThumbDrawable;
 | |
|         if (drawable != null) {
 | |
|             if (this.mHasThumbTint || this.mHasThumbTintMode) {
 | |
|                 Drawable mutate = DrawableCompat.wrap(drawable).mutate();
 | |
|                 this.mThumbDrawable = mutate;
 | |
|                 if (this.mHasThumbTint) {
 | |
|                     DrawableCompat.setTintList(mutate, this.mThumbTintList);
 | |
|                 }
 | |
|                 if (this.mHasThumbTintMode) {
 | |
|                     DrawableCompat.setTintMode(this.mThumbDrawable, this.mThumbTintMode);
 | |
|                 }
 | |
|                 if (this.mThumbDrawable.isStateful()) {
 | |
|                     this.mThumbDrawable.setState(getDrawableState());
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void setSplitTrack(boolean z) {
 | |
|         this.mSplitTrack = z;
 | |
|         invalidate();
 | |
|     }
 | |
| 
 | |
|     private void setTextOnInternal(CharSequence charSequence) {
 | |
|         this.mTextOn = charSequence;
 | |
|         this.mTextOnTransformed = doTransformForOnOffText(charSequence);
 | |
|         this.mOnLayout = null;
 | |
|         if (this.mShowText) {
 | |
|             setupEmojiCompatLoadCallback();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void setTextOn(CharSequence charSequence) {
 | |
|         setTextOnInternal(charSequence);
 | |
|         requestLayout();
 | |
|         if (isChecked()) {
 | |
|             setOnStateDescriptionOnRAndAbove();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void setTextOffInternal(CharSequence charSequence) {
 | |
|         this.mTextOff = charSequence;
 | |
|         this.mTextOffTransformed = doTransformForOnOffText(charSequence);
 | |
|         this.mOffLayout = null;
 | |
|         if (this.mShowText) {
 | |
|             setupEmojiCompatLoadCallback();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void setTextOff(CharSequence charSequence) {
 | |
|         setTextOffInternal(charSequence);
 | |
|         requestLayout();
 | |
|         if (isChecked()) {
 | |
|             return;
 | |
|         }
 | |
|         setOffStateDescriptionOnRAndAbove();
 | |
|     }
 | |
| 
 | |
|     private CharSequence doTransformForOnOffText(CharSequence charSequence) {
 | |
|         TransformationMethod wrapTransformationMethod = getEmojiTextViewHelper().wrapTransformationMethod(this.mSwitchTransformationMethod);
 | |
|         return wrapTransformationMethod != null ? wrapTransformationMethod.getTransformation(charSequence, this) : charSequence;
 | |
|     }
 | |
| 
 | |
|     public void setShowText(boolean z) {
 | |
|         if (this.mShowText != z) {
 | |
|             this.mShowText = z;
 | |
|             requestLayout();
 | |
|             if (z) {
 | |
|                 setupEmojiCompatLoadCallback();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.TextView, android.view.View
 | |
|     public void onMeasure(int i, int i2) {
 | |
|         int i3;
 | |
|         int i4;
 | |
|         if (this.mShowText) {
 | |
|             if (this.mOnLayout == null) {
 | |
|                 this.mOnLayout = makeLayout(this.mTextOnTransformed);
 | |
|             }
 | |
|             if (this.mOffLayout == null) {
 | |
|                 this.mOffLayout = makeLayout(this.mTextOffTransformed);
 | |
|             }
 | |
|         }
 | |
|         Rect rect = this.mTempRect;
 | |
|         Drawable drawable = this.mThumbDrawable;
 | |
|         int i5 = 0;
 | |
|         if (drawable != null) {
 | |
|             drawable.getPadding(rect);
 | |
|             i3 = (this.mThumbDrawable.getIntrinsicWidth() - rect.left) - rect.right;
 | |
|             i4 = this.mThumbDrawable.getIntrinsicHeight();
 | |
|         } else {
 | |
|             i3 = 0;
 | |
|             i4 = 0;
 | |
|         }
 | |
|         this.mThumbWidth = Math.max(this.mShowText ? Math.max(this.mOnLayout.getWidth(), this.mOffLayout.getWidth()) + (this.mThumbTextPadding * 2) : 0, i3);
 | |
|         Drawable drawable2 = this.mTrackDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             drawable2.getPadding(rect);
 | |
|             i5 = this.mTrackDrawable.getIntrinsicHeight();
 | |
|         } else {
 | |
|             rect.setEmpty();
 | |
|         }
 | |
|         int i6 = rect.left;
 | |
|         int i7 = rect.right;
 | |
|         Drawable drawable3 = this.mThumbDrawable;
 | |
|         if (drawable3 != null) {
 | |
|             Rect opticalBounds = DrawableUtils.getOpticalBounds(drawable3);
 | |
|             i6 = Math.max(i6, opticalBounds.left);
 | |
|             i7 = Math.max(i7, opticalBounds.right);
 | |
|         }
 | |
|         int max = this.mEnforceSwitchWidth ? Math.max(this.mSwitchMinWidth, (this.mThumbWidth * 2) + i6 + i7) : this.mSwitchMinWidth;
 | |
|         int max2 = Math.max(i5, i4);
 | |
|         this.mSwitchWidth = max;
 | |
|         this.mSwitchHeight = 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.mTextOn : this.mTextOff;
 | |
|         if (charSequence != null) {
 | |
|             accessibilityEvent.getText().add(charSequence);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private Layout makeLayout(CharSequence charSequence) {
 | |
|         return new StaticLayout(charSequence, this.mTextPaint, charSequence != null ? (int) Math.ceil(Layout.getDesiredWidth(charSequence, r2)) : 0, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
 | |
|     }
 | |
| 
 | |
|     private boolean hitThumb(float f, float f2) {
 | |
|         if (this.mThumbDrawable == null) {
 | |
|             return false;
 | |
|         }
 | |
|         int thumbOffset = getThumbOffset();
 | |
|         this.mThumbDrawable.getPadding(this.mTempRect);
 | |
|         int i = this.mSwitchTop;
 | |
|         int i2 = this.mTouchSlop;
 | |
|         int i3 = i - i2;
 | |
|         int i4 = (this.mSwitchLeft + thumbOffset) - i2;
 | |
|         int i5 = this.mThumbWidth + i4 + this.mTempRect.left + this.mTempRect.right;
 | |
|         int i6 = this.mTouchSlop;
 | |
|         return f > ((float) i4) && f < ((float) (i5 + i6)) && f2 > ((float) i3) && f2 < ((float) (this.mSwitchBottom + i6));
 | |
|     }
 | |
| 
 | |
|     /* JADX WARN: Code restructure failed: missing block: B:7:0x0012, code lost:
 | |
|     
 | |
|         if (r0 != 3) goto L44;
 | |
|      */
 | |
|     @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.mVelocityTracker
 | |
|             r0.addMovement(r7)
 | |
|             int r0 = r7.getActionMasked()
 | |
|             r1 = 1
 | |
|             if (r0 == 0) goto L9f
 | |
|             r2 = 2
 | |
|             if (r0 == r1) goto L8b
 | |
|             if (r0 == r2) goto L16
 | |
|             r3 = 3
 | |
|             if (r0 == r3) goto L8b
 | |
|             goto Lb9
 | |
|         L16:
 | |
|             int r0 = r6.mTouchMode
 | |
|             if (r0 == r1) goto L57
 | |
|             if (r0 == r2) goto L1e
 | |
|             goto Lb9
 | |
|         L1e:
 | |
|             float r7 = r7.getX()
 | |
|             int r0 = r6.getThumbScrollRange()
 | |
|             float r2 = r6.mTouchX
 | |
|             float r2 = r7 - r2
 | |
|             r3 = 1065353216(0x3f800000, float:1.0)
 | |
|             r4 = 0
 | |
|             if (r0 == 0) goto L32
 | |
|             float r0 = (float) r0
 | |
|             float r2 = r2 / r0
 | |
|             goto L3d
 | |
|         L32:
 | |
|             int r0 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
 | |
|             if (r0 <= 0) goto L39
 | |
|             r2 = 1065353216(0x3f800000, float:1.0)
 | |
|             goto L3d
 | |
|         L39:
 | |
|             r0 = -1082130432(0xffffffffbf800000, float:-1.0)
 | |
|             r2 = -1082130432(0xffffffffbf800000, float:-1.0)
 | |
|         L3d:
 | |
|             boolean r0 = androidx.appcompat.widget.ViewUtils.isLayoutRtl(r6)
 | |
|             if (r0 == 0) goto L44
 | |
|             float r2 = -r2
 | |
|         L44:
 | |
|             float r0 = r6.mThumbPosition
 | |
|             float r0 = r0 + r2
 | |
|             float r0 = constrain(r0, r4, r3)
 | |
|             float r2 = r6.mThumbPosition
 | |
|             int r2 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
 | |
|             if (r2 == 0) goto L56
 | |
|             r6.mTouchX = r7
 | |
|             r6.setThumbPosition(r0)
 | |
|         L56:
 | |
|             return r1
 | |
|         L57:
 | |
|             float r0 = r7.getX()
 | |
|             float r3 = r7.getY()
 | |
|             float r4 = r6.mTouchX
 | |
|             float r4 = r0 - r4
 | |
|             float r4 = java.lang.Math.abs(r4)
 | |
|             int r5 = r6.mTouchSlop
 | |
|             float r5 = (float) r5
 | |
|             int r4 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1))
 | |
|             if (r4 > 0) goto L7d
 | |
|             float r4 = r6.mTouchY
 | |
|             float r4 = r3 - r4
 | |
|             float r4 = java.lang.Math.abs(r4)
 | |
|             int r5 = r6.mTouchSlop
 | |
|             float r5 = (float) r5
 | |
|             int r4 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1))
 | |
|             if (r4 <= 0) goto Lb9
 | |
|         L7d:
 | |
|             r6.mTouchMode = r2
 | |
|             android.view.ViewParent r7 = r6.getParent()
 | |
|             r7.requestDisallowInterceptTouchEvent(r1)
 | |
|             r6.mTouchX = r0
 | |
|             r6.mTouchY = r3
 | |
|             return r1
 | |
|         L8b:
 | |
|             int r0 = r6.mTouchMode
 | |
|             if (r0 != r2) goto L96
 | |
|             r6.stopDrag(r7)
 | |
|             super.onTouchEvent(r7)
 | |
|             return r1
 | |
|         L96:
 | |
|             r0 = 0
 | |
|             r6.mTouchMode = r0
 | |
|             android.view.VelocityTracker r0 = r6.mVelocityTracker
 | |
|             r0.clear()
 | |
|             goto Lb9
 | |
|         L9f:
 | |
|             float r0 = r7.getX()
 | |
|             float r2 = r7.getY()
 | |
|             boolean r3 = r6.isEnabled()
 | |
|             if (r3 == 0) goto Lb9
 | |
|             boolean r3 = r6.hitThumb(r0, r2)
 | |
|             if (r3 == 0) goto Lb9
 | |
|             r6.mTouchMode = r1
 | |
|             r6.mTouchX = r0
 | |
|             r6.mTouchY = r2
 | |
|         Lb9:
 | |
|             boolean r7 = super.onTouchEvent(r7)
 | |
|             return r7
 | |
|         */
 | |
|         throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.SwitchCompat.onTouchEvent(android.view.MotionEvent):boolean");
 | |
|     }
 | |
| 
 | |
|     private void cancelSuperTouch(MotionEvent motionEvent) {
 | |
|         MotionEvent obtain = MotionEvent.obtain(motionEvent);
 | |
|         obtain.setAction(3);
 | |
|         super.onTouchEvent(obtain);
 | |
|         obtain.recycle();
 | |
|     }
 | |
| 
 | |
|     private void stopDrag(MotionEvent motionEvent) {
 | |
|         this.mTouchMode = 0;
 | |
|         boolean z = true;
 | |
|         boolean z2 = motionEvent.getAction() == 1 && isEnabled();
 | |
|         boolean isChecked = isChecked();
 | |
|         if (z2) {
 | |
|             this.mVelocityTracker.computeCurrentVelocity(1000);
 | |
|             float xVelocity = this.mVelocityTracker.getXVelocity();
 | |
|             if (Math.abs(xVelocity) > this.mMinFlingVelocity) {
 | |
|                 if (!ViewUtils.isLayoutRtl(this) ? xVelocity <= 0.0f : xVelocity >= 0.0f) {
 | |
|                     z = false;
 | |
|                 }
 | |
|             } else {
 | |
|                 z = getTargetCheckedState();
 | |
|             }
 | |
|         } else {
 | |
|             z = isChecked;
 | |
|         }
 | |
|         if (z != isChecked) {
 | |
|             playSoundEffect(0);
 | |
|         }
 | |
|         setChecked(z);
 | |
|         cancelSuperTouch(motionEvent);
 | |
|     }
 | |
| 
 | |
|     private void animateThumbToCheckedState(boolean z) {
 | |
|         ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this, THUMB_POS, z ? 1.0f : 0.0f);
 | |
|         this.mPositionAnimator = ofFloat;
 | |
|         ofFloat.setDuration(250L);
 | |
|         Api18Impl.setAutoCancel(this.mPositionAnimator, true);
 | |
|         this.mPositionAnimator.start();
 | |
|     }
 | |
| 
 | |
|     private void cancelPositionAnimator() {
 | |
|         ObjectAnimator objectAnimator = this.mPositionAnimator;
 | |
|         if (objectAnimator != null) {
 | |
|             objectAnimator.cancel();
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     void setThumbPosition(float f) {
 | |
|         this.mThumbPosition = 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) {
 | |
|             setOnStateDescriptionOnRAndAbove();
 | |
|         } else {
 | |
|             setOffStateDescriptionOnRAndAbove();
 | |
|         }
 | |
|         if (getWindowToken() != null && ViewCompat.isLaidOut(this)) {
 | |
|             animateThumbToCheckedState(isChecked);
 | |
|         } else {
 | |
|             cancelPositionAnimator();
 | |
|             setThumbPosition(isChecked ? 1.0f : 0.0f);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @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;
 | |
|         super.onLayout(z, i, i2, i3, i4);
 | |
|         int i10 = 0;
 | |
|         if (this.mThumbDrawable != null) {
 | |
|             Rect rect = this.mTempRect;
 | |
|             Drawable drawable = this.mTrackDrawable;
 | |
|             if (drawable != null) {
 | |
|                 drawable.getPadding(rect);
 | |
|             } else {
 | |
|                 rect.setEmpty();
 | |
|             }
 | |
|             Rect opticalBounds = DrawableUtils.getOpticalBounds(this.mThumbDrawable);
 | |
|             i5 = Math.max(0, opticalBounds.left - rect.left);
 | |
|             i10 = Math.max(0, opticalBounds.right - rect.right);
 | |
|         } else {
 | |
|             i5 = 0;
 | |
|         }
 | |
|         if (ViewUtils.isLayoutRtl(this)) {
 | |
|             i6 = getPaddingLeft() + i5;
 | |
|             width = ((this.mSwitchWidth + i6) - i5) - i10;
 | |
|         } else {
 | |
|             width = (getWidth() - getPaddingRight()) - i10;
 | |
|             i6 = (width - this.mSwitchWidth) + i5 + i10;
 | |
|         }
 | |
|         int gravity = getGravity() & 112;
 | |
|         if (gravity == 16) {
 | |
|             int paddingTop = ((getPaddingTop() + getHeight()) - getPaddingBottom()) / 2;
 | |
|             i7 = this.mSwitchHeight;
 | |
|             i8 = paddingTop - (i7 / 2);
 | |
|         } else if (gravity != 80) {
 | |
|             i8 = getPaddingTop();
 | |
|             i7 = this.mSwitchHeight;
 | |
|         } else {
 | |
|             i9 = getHeight() - getPaddingBottom();
 | |
|             i8 = i9 - this.mSwitchHeight;
 | |
|             this.mSwitchLeft = i6;
 | |
|             this.mSwitchTop = i8;
 | |
|             this.mSwitchBottom = i9;
 | |
|             this.mSwitchRight = width;
 | |
|         }
 | |
|         i9 = i7 + i8;
 | |
|         this.mSwitchLeft = i6;
 | |
|         this.mSwitchTop = i8;
 | |
|         this.mSwitchBottom = i9;
 | |
|         this.mSwitchRight = width;
 | |
|     }
 | |
| 
 | |
|     @Override // android.view.View
 | |
|     public void draw(Canvas canvas) {
 | |
|         Rect rect;
 | |
|         int i;
 | |
|         int i2;
 | |
|         Rect rect2 = this.mTempRect;
 | |
|         int i3 = this.mSwitchLeft;
 | |
|         int i4 = this.mSwitchTop;
 | |
|         int i5 = this.mSwitchRight;
 | |
|         int i6 = this.mSwitchBottom;
 | |
|         int thumbOffset = getThumbOffset() + i3;
 | |
|         Drawable drawable = this.mThumbDrawable;
 | |
|         if (drawable != null) {
 | |
|             rect = DrawableUtils.getOpticalBounds(drawable);
 | |
|         } else {
 | |
|             rect = DrawableUtils.INSETS_NONE;
 | |
|         }
 | |
|         Drawable drawable2 = this.mTrackDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             drawable2.getPadding(rect2);
 | |
|             thumbOffset += 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.mTrackDrawable.setBounds(i3, i, i5, i2);
 | |
|                 }
 | |
|             } else {
 | |
|                 i = i4;
 | |
|             }
 | |
|             i2 = i6;
 | |
|             this.mTrackDrawable.setBounds(i3, i, i5, i2);
 | |
|         }
 | |
|         Drawable drawable3 = this.mThumbDrawable;
 | |
|         if (drawable3 != null) {
 | |
|             drawable3.getPadding(rect2);
 | |
|             int i7 = thumbOffset - rect2.left;
 | |
|             int i8 = thumbOffset + this.mThumbWidth + rect2.right;
 | |
|             this.mThumbDrawable.setBounds(i7, i4, i8, i6);
 | |
|             Drawable background = getBackground();
 | |
|             if (background != null) {
 | |
|                 DrawableCompat.setHotspotBounds(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.mTempRect;
 | |
|         Drawable drawable = this.mTrackDrawable;
 | |
|         if (drawable != null) {
 | |
|             drawable.getPadding(rect);
 | |
|         } else {
 | |
|             rect.setEmpty();
 | |
|         }
 | |
|         int i = this.mSwitchTop;
 | |
|         int i2 = this.mSwitchBottom;
 | |
|         int i3 = i + rect.top;
 | |
|         int i4 = i2 - rect.bottom;
 | |
|         Drawable drawable2 = this.mThumbDrawable;
 | |
|         if (drawable != null) {
 | |
|             if (this.mSplitTrack && drawable2 != null) {
 | |
|                 Rect opticalBounds = DrawableUtils.getOpticalBounds(drawable2);
 | |
|                 drawable2.copyBounds(rect);
 | |
|                 rect.left += opticalBounds.left;
 | |
|                 rect.right -= opticalBounds.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 = getTargetCheckedState() ? this.mOnLayout : this.mOffLayout;
 | |
|         if (layout != null) {
 | |
|             int[] drawableState = getDrawableState();
 | |
|             ColorStateList colorStateList = this.mTextColors;
 | |
|             if (colorStateList != null) {
 | |
|                 this.mTextPaint.setColor(colorStateList.getColorForState(drawableState, 0));
 | |
|             }
 | |
|             this.mTextPaint.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(save2);
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.CompoundButton, android.widget.TextView
 | |
|     public int getCompoundPaddingLeft() {
 | |
|         if (!ViewUtils.isLayoutRtl(this)) {
 | |
|             return super.getCompoundPaddingLeft();
 | |
|         }
 | |
|         int compoundPaddingLeft = super.getCompoundPaddingLeft() + this.mSwitchWidth;
 | |
|         return !TextUtils.isEmpty(getText()) ? compoundPaddingLeft + this.mSwitchPadding : compoundPaddingLeft;
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.CompoundButton, android.widget.TextView
 | |
|     public int getCompoundPaddingRight() {
 | |
|         if (ViewUtils.isLayoutRtl(this)) {
 | |
|             return super.getCompoundPaddingRight();
 | |
|         }
 | |
|         int compoundPaddingRight = super.getCompoundPaddingRight() + this.mSwitchWidth;
 | |
|         return !TextUtils.isEmpty(getText()) ? compoundPaddingRight + this.mSwitchPadding : compoundPaddingRight;
 | |
|     }
 | |
| 
 | |
|     private int getThumbOffset() {
 | |
|         return (int) (((ViewUtils.isLayoutRtl(this) ? 1.0f - this.mThumbPosition : this.mThumbPosition) * getThumbScrollRange()) + 0.5f);
 | |
|     }
 | |
| 
 | |
|     private int getThumbScrollRange() {
 | |
|         Rect rect;
 | |
|         Drawable drawable = this.mTrackDrawable;
 | |
|         if (drawable == null) {
 | |
|             return 0;
 | |
|         }
 | |
|         Rect rect2 = this.mTempRect;
 | |
|         drawable.getPadding(rect2);
 | |
|         Drawable drawable2 = this.mThumbDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             rect = DrawableUtils.getOpticalBounds(drawable2);
 | |
|         } else {
 | |
|             rect = DrawableUtils.INSETS_NONE;
 | |
|         }
 | |
|         return ((((this.mSwitchWidth - this.mThumbWidth) - 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, CHECKED_STATE_SET);
 | |
|         }
 | |
|         return onCreateDrawableState;
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
 | |
|     protected void drawableStateChanged() {
 | |
|         super.drawableStateChanged();
 | |
|         int[] drawableState = getDrawableState();
 | |
|         Drawable drawable = this.mThumbDrawable;
 | |
|         boolean state = (drawable == null || !drawable.isStateful()) ? false : drawable.setState(drawableState);
 | |
|         Drawable drawable2 = this.mTrackDrawable;
 | |
|         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.mThumbDrawable;
 | |
|         if (drawable != null) {
 | |
|             DrawableCompat.setHotspot(drawable, f, f2);
 | |
|         }
 | |
|         Drawable drawable2 = this.mTrackDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             DrawableCompat.setHotspot(drawable2, f, f2);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
 | |
|     protected boolean verifyDrawable(Drawable drawable) {
 | |
|         return super.verifyDrawable(drawable) || drawable == this.mThumbDrawable || drawable == this.mTrackDrawable;
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
 | |
|     public void jumpDrawablesToCurrentState() {
 | |
|         super.jumpDrawablesToCurrentState();
 | |
|         Drawable drawable = this.mThumbDrawable;
 | |
|         if (drawable != null) {
 | |
|             drawable.jumpToCurrentState();
 | |
|         }
 | |
|         Drawable drawable2 = this.mTrackDrawable;
 | |
|         if (drawable2 != null) {
 | |
|             drawable2.jumpToCurrentState();
 | |
|         }
 | |
|         ObjectAnimator objectAnimator = this.mPositionAnimator;
 | |
|         if (objectAnimator == null || !objectAnimator.isStarted()) {
 | |
|             return;
 | |
|         }
 | |
|         this.mPositionAnimator.end();
 | |
|         this.mPositionAnimator = null;
 | |
|     }
 | |
| 
 | |
|     @Override // android.view.View
 | |
|     public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
 | |
|         super.onInitializeAccessibilityEvent(accessibilityEvent);
 | |
|         accessibilityEvent.setClassName(ACCESSIBILITY_EVENT_CLASS_NAME);
 | |
|     }
 | |
| 
 | |
|     @Override // android.view.View
 | |
|     public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
 | |
|         super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
 | |
|         accessibilityNodeInfo.setClassName(ACCESSIBILITY_EVENT_CLASS_NAME);
 | |
|         if (Build.VERSION.SDK_INT < 30) {
 | |
|             CharSequence charSequence = isChecked() ? this.mTextOn : this.mTextOff;
 | |
|             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(TextViewCompat.wrapCustomSelectionActionModeCallback(this, callback));
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.TextView
 | |
|     public ActionMode.Callback getCustomSelectionActionModeCallback() {
 | |
|         return TextViewCompat.unwrapCustomSelectionActionModeCallback(super.getCustomSelectionActionModeCallback());
 | |
|     }
 | |
| 
 | |
|     protected final void setEnforceSwitchWidth(boolean z) {
 | |
|         this.mEnforceSwitchWidth = z;
 | |
|         invalidate();
 | |
|     }
 | |
| 
 | |
|     private void setOnStateDescriptionOnRAndAbove() {
 | |
|         if (Build.VERSION.SDK_INT >= 30) {
 | |
|             CharSequence charSequence = this.mTextOn;
 | |
|             if (charSequence == null) {
 | |
|                 charSequence = getResources().getString(androidx.appcompat.R.string.abc_capital_on);
 | |
|             }
 | |
|             ViewCompat.setStateDescription(this, charSequence);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void setOffStateDescriptionOnRAndAbove() {
 | |
|         if (Build.VERSION.SDK_INT >= 30) {
 | |
|             CharSequence charSequence = this.mTextOff;
 | |
|             if (charSequence == null) {
 | |
|                 charSequence = getResources().getString(androidx.appcompat.R.string.abc_capital_off);
 | |
|             }
 | |
|             ViewCompat.setStateDescription(this, charSequence);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.TextView
 | |
|     public void setAllCaps(boolean z) {
 | |
|         super.setAllCaps(z);
 | |
|         getEmojiTextViewHelper().setAllCaps(z);
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.TextView
 | |
|     public void setFilters(InputFilter[] inputFilterArr) {
 | |
|         super.setFilters(getEmojiTextViewHelper().getFilters(inputFilterArr));
 | |
|     }
 | |
| 
 | |
|     private AppCompatEmojiTextHelper getEmojiTextViewHelper() {
 | |
|         if (this.mAppCompatEmojiTextHelper == null) {
 | |
|             this.mAppCompatEmojiTextHelper = new AppCompatEmojiTextHelper(this);
 | |
|         }
 | |
|         return this.mAppCompatEmojiTextHelper;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.EmojiCompatConfigurationView
 | |
|     public void setEmojiCompatEnabled(boolean z) {
 | |
|         getEmojiTextViewHelper().setEnabled(z);
 | |
|         setTextOnInternal(this.mTextOn);
 | |
|         setTextOffInternal(this.mTextOff);
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.widget.EmojiCompatConfigurationView
 | |
|     public boolean isEmojiCompatEnabled() {
 | |
|         return getEmojiTextViewHelper().isEnabled();
 | |
|     }
 | |
| 
 | |
|     private void setupEmojiCompatLoadCallback() {
 | |
|         if (this.mEmojiCompatInitCallback == null && this.mAppCompatEmojiTextHelper.isEnabled() && EmojiCompat.isConfigured()) {
 | |
|             EmojiCompat emojiCompat = EmojiCompat.get();
 | |
|             int loadState = emojiCompat.getLoadState();
 | |
|             if (loadState == 3 || loadState == 0) {
 | |
|                 EmojiCompatInitCallback emojiCompatInitCallback = new EmojiCompatInitCallback(this);
 | |
|                 this.mEmojiCompatInitCallback = emojiCompatInitCallback;
 | |
|                 emojiCompat.registerInitCallback(emojiCompatInitCallback);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     void onEmojiCompatInitializedForSwitchText() {
 | |
|         setTextOnInternal(this.mTextOn);
 | |
|         setTextOffInternal(this.mTextOff);
 | |
|         requestLayout();
 | |
|     }
 | |
| 
 | |
|     static class EmojiCompatInitCallback extends EmojiCompat.InitCallback {
 | |
|         private final Reference<SwitchCompat> mOuterWeakRef;
 | |
| 
 | |
|         EmojiCompatInitCallback(SwitchCompat switchCompat) {
 | |
|             this.mOuterWeakRef = new WeakReference(switchCompat);
 | |
|         }
 | |
| 
 | |
|         @Override // androidx.emoji2.text.EmojiCompat.InitCallback
 | |
|         public void onInitialized() {
 | |
|             SwitchCompat switchCompat = this.mOuterWeakRef.get();
 | |
|             if (switchCompat != null) {
 | |
|                 switchCompat.onEmojiCompatInitializedForSwitchText();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         @Override // androidx.emoji2.text.EmojiCompat.InitCallback
 | |
|         public void onFailed(Throwable th) {
 | |
|             SwitchCompat switchCompat = this.mOuterWeakRef.get();
 | |
|             if (switchCompat != null) {
 | |
|                 switchCompat.onEmojiCompatInitializedForSwitchText();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     static class Api18Impl {
 | |
|         private Api18Impl() {
 | |
|         }
 | |
| 
 | |
|         static void setAutoCancel(ObjectAnimator objectAnimator, boolean z) {
 | |
|             objectAnimator.setAutoCancel(z);
 | |
|         }
 | |
|     }
 | |
| }
 |