mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-04 11:38:54 +01:00
97 lines
4 KiB
Java
97 lines
4 KiB
Java
package com.google.android.material.ripple;
|
|
|
|
import android.R;
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.graphics.Color;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.graphics.drawable.GradientDrawable;
|
|
import android.graphics.drawable.InsetDrawable;
|
|
import android.graphics.drawable.RippleDrawable;
|
|
import android.util.StateSet;
|
|
import androidx.annotation.ColorInt;
|
|
import androidx.annotation.DoNotInline;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Px;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.core.graphics.ColorUtils;
|
|
import com.google.android.material.color.MaterialColors;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
/* loaded from: classes7.dex */
|
|
public class RippleUtils {
|
|
|
|
@VisibleForTesting
|
|
static final String TRANSPARENT_DEFAULT_COLOR_WARNING = "Use a non-transparent color for the default color as it will be used to finish ripple animations.";
|
|
|
|
@Deprecated
|
|
public static final boolean USE_FRAMEWORK_RIPPLE = true;
|
|
private static final int[] PRESSED_STATE_SET = {R.attr.state_pressed};
|
|
private static final int[] FOCUSED_STATE_SET = {R.attr.state_focused};
|
|
private static final int[] SELECTED_PRESSED_STATE_SET = {R.attr.state_selected, R.attr.state_pressed};
|
|
private static final int[] SELECTED_STATE_SET = {R.attr.state_selected};
|
|
private static final int[] ENABLED_PRESSED_STATE_SET = {R.attr.state_enabled, R.attr.state_pressed};
|
|
|
|
@VisibleForTesting
|
|
static final String LOG_TAG = "RippleUtils";
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class RippleUtilsLollipop {
|
|
private RippleUtilsLollipop() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
@DoNotInline
|
|
public static Drawable createOvalRipple(@NonNull Context context, @Px int i) {
|
|
GradientDrawable gradientDrawable = new GradientDrawable();
|
|
gradientDrawable.setColor(-1);
|
|
gradientDrawable.setShape(1);
|
|
return new RippleDrawable(MaterialColors.getColorStateList(context, androidx.appcompat.R.attr.colorControlHighlight, ColorStateList.valueOf(0)), null, new InsetDrawable((Drawable) gradientDrawable, i, i, i, i));
|
|
}
|
|
}
|
|
|
|
private RippleUtils() {
|
|
}
|
|
|
|
@NonNull
|
|
public static ColorStateList convertToRippleDrawableColor(@Nullable ColorStateList colorStateList) {
|
|
int[] iArr = FOCUSED_STATE_SET;
|
|
return new ColorStateList(new int[][]{SELECTED_STATE_SET, iArr, StateSet.NOTHING}, new int[]{getColorForState(colorStateList, SELECTED_PRESSED_STATE_SET), getColorForState(colorStateList, iArr), getColorForState(colorStateList, PRESSED_STATE_SET)});
|
|
}
|
|
|
|
@NonNull
|
|
public static Drawable createOvalRippleLollipop(@NonNull Context context, @Px int i) {
|
|
return RippleUtilsLollipop.createOvalRipple(context, i);
|
|
}
|
|
|
|
@ColorInt
|
|
private static int doubleAlpha(@ColorInt int i) {
|
|
return ColorUtils.setAlphaComponent(i, Math.min(Color.alpha(i) * 2, 255));
|
|
}
|
|
|
|
@ColorInt
|
|
private static int getColorForState(@Nullable ColorStateList colorStateList, int[] iArr) {
|
|
return doubleAlpha(colorStateList != null ? colorStateList.getColorForState(iArr, colorStateList.getDefaultColor()) : 0);
|
|
}
|
|
|
|
@NonNull
|
|
public static ColorStateList sanitizeRippleDrawableColor(@Nullable ColorStateList colorStateList) {
|
|
return colorStateList != null ? colorStateList : ColorStateList.valueOf(0);
|
|
}
|
|
|
|
public static boolean shouldDrawRippleCompat(@NonNull int[] iArr) {
|
|
boolean z = false;
|
|
boolean z2 = false;
|
|
for (int i : iArr) {
|
|
if (i == 16842910) {
|
|
z = true;
|
|
} else if (i == 16842908 || i == 16842919 || i == 16843623) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
return z && z2;
|
|
}
|
|
}
|