121 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			121 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.google.android.material.switchmaterial;
 | |
| 
 | |
| import android.content.Context;
 | |
| import android.content.res.ColorStateList;
 | |
| import android.util.AttributeSet;
 | |
| import androidx.appcompat.widget.SwitchCompat;
 | |
| import com.google.android.material.R;
 | |
| import com.google.android.material.color.MaterialColors;
 | |
| import com.google.android.material.elevation.ElevationOverlayProvider;
 | |
| import com.google.android.material.internal.ViewUtils;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| public class SwitchMaterial extends SwitchCompat {
 | |
|     private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_CompoundButton_Switch;
 | |
|     private static final int[][] ENABLED_CHECKED_STATES = {new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, -16842912}, new int[]{-16842910, android.R.attr.state_checked}, new int[]{-16842910, -16842912}};
 | |
|     private final ElevationOverlayProvider elevationOverlayProvider;
 | |
|     private ColorStateList materialThemeColorsThumbTintList;
 | |
|     private ColorStateList materialThemeColorsTrackTintList;
 | |
|     private boolean useMaterialThemeColors;
 | |
| 
 | |
|     public boolean isUseMaterialThemeColors() {
 | |
|         return this.useMaterialThemeColors;
 | |
|     }
 | |
| 
 | |
|     public SwitchMaterial(Context context) {
 | |
|         this(context, null);
 | |
|     }
 | |
| 
 | |
|     public SwitchMaterial(Context context, AttributeSet attributeSet) {
 | |
|         this(context, attributeSet, R.attr.switchStyle);
 | |
|     }
 | |
| 
 | |
|     /* JADX WARN: Illegal instructions before constructor call */
 | |
|     /*
 | |
|         Code decompiled incorrectly, please refer to instructions dump.
 | |
|         To view partially-correct add '--show-bad-code' argument
 | |
|     */
 | |
|     public SwitchMaterial(android.content.Context r7, android.util.AttributeSet r8, int r9) {
 | |
|         /*
 | |
|             r6 = this;
 | |
|             int r4 = com.google.android.material.switchmaterial.SwitchMaterial.DEF_STYLE_RES
 | |
|             android.content.Context r7 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r7, r8, r9, r4)
 | |
|             r6.<init>(r7, r8, r9)
 | |
|             android.content.Context r0 = r6.getContext()
 | |
|             com.google.android.material.elevation.ElevationOverlayProvider r7 = new com.google.android.material.elevation.ElevationOverlayProvider
 | |
|             r7.<init>(r0)
 | |
|             r6.elevationOverlayProvider = r7
 | |
|             int[] r2 = com.google.android.material.R.styleable.SwitchMaterial
 | |
|             r7 = 0
 | |
|             int[] r5 = new int[r7]
 | |
|             r1 = r8
 | |
|             r3 = r9
 | |
|             android.content.res.TypedArray r8 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
 | |
|             int r9 = com.google.android.material.R.styleable.SwitchMaterial_useMaterialThemeColors
 | |
|             boolean r7 = r8.getBoolean(r9, r7)
 | |
|             r6.useMaterialThemeColors = r7
 | |
|             r8.recycle()
 | |
|             return
 | |
|         */
 | |
|         throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.switchmaterial.SwitchMaterial.<init>(android.content.Context, android.util.AttributeSet, int):void");
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.TextView, android.view.View
 | |
|     protected void onAttachedToWindow() {
 | |
|         super.onAttachedToWindow();
 | |
|         if (this.useMaterialThemeColors && getThumbTintList() == null) {
 | |
|             setThumbTintList(getMaterialThemeColorsThumbTintList());
 | |
|         }
 | |
|         if (this.useMaterialThemeColors && getTrackTintList() == null) {
 | |
|             setTrackTintList(getMaterialThemeColorsTrackTintList());
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void setUseMaterialThemeColors(boolean z) {
 | |
|         this.useMaterialThemeColors = z;
 | |
|         if (z) {
 | |
|             setThumbTintList(getMaterialThemeColorsThumbTintList());
 | |
|             setTrackTintList(getMaterialThemeColorsTrackTintList());
 | |
|         } else {
 | |
|             setThumbTintList(null);
 | |
|             setTrackTintList(null);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private ColorStateList getMaterialThemeColorsThumbTintList() {
 | |
|         if (this.materialThemeColorsThumbTintList == null) {
 | |
|             int color = MaterialColors.getColor(this, R.attr.colorSurface);
 | |
|             int color2 = MaterialColors.getColor(this, R.attr.colorControlActivated);
 | |
|             float dimension = getResources().getDimension(R.dimen.mtrl_switch_thumb_elevation);
 | |
|             if (this.elevationOverlayProvider.isThemeElevationOverlayEnabled()) {
 | |
|                 dimension += ViewUtils.getParentAbsoluteElevation(this);
 | |
|             }
 | |
|             int compositeOverlayIfNeeded = this.elevationOverlayProvider.compositeOverlayIfNeeded(color, dimension);
 | |
|             int[][] iArr = ENABLED_CHECKED_STATES;
 | |
|             int[] iArr2 = new int[iArr.length];
 | |
|             iArr2[0] = MaterialColors.layer(color, color2, 1.0f);
 | |
|             iArr2[1] = compositeOverlayIfNeeded;
 | |
|             iArr2[2] = MaterialColors.layer(color, color2, 0.38f);
 | |
|             iArr2[3] = compositeOverlayIfNeeded;
 | |
|             this.materialThemeColorsThumbTintList = new ColorStateList(iArr, iArr2);
 | |
|         }
 | |
|         return this.materialThemeColorsThumbTintList;
 | |
|     }
 | |
| 
 | |
|     private ColorStateList getMaterialThemeColorsTrackTintList() {
 | |
|         if (this.materialThemeColorsTrackTintList == null) {
 | |
|             int[][] iArr = ENABLED_CHECKED_STATES;
 | |
|             int[] iArr2 = new int[iArr.length];
 | |
|             int color = MaterialColors.getColor(this, R.attr.colorSurface);
 | |
|             int color2 = MaterialColors.getColor(this, R.attr.colorControlActivated);
 | |
|             int color3 = MaterialColors.getColor(this, R.attr.colorOnSurface);
 | |
|             iArr2[0] = MaterialColors.layer(color, color2, 0.54f);
 | |
|             iArr2[1] = MaterialColors.layer(color, color3, 0.32f);
 | |
|             iArr2[2] = MaterialColors.layer(color, color2, 0.12f);
 | |
|             iArr2[3] = MaterialColors.layer(color, color3, 0.12f);
 | |
|             this.materialThemeColorsTrackTintList = new ColorStateList(iArr, iArr2);
 | |
|         }
 | |
|         return this.materialThemeColorsTrackTintList;
 | |
|     }
 | |
| }
 |