- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
217 lines
8.0 KiB
Java
217 lines
8.0 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.R;
|
|
import android.graphics.Insets;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Build;
|
|
import androidx.annotation.DoNotInline;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
/* loaded from: classes.dex */
|
|
public class DrawableUtils {
|
|
private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
|
|
private static final int[] EMPTY_STATE_SET = new int[0];
|
|
public static final Rect INSETS_NONE = new Rect();
|
|
|
|
@Deprecated
|
|
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
|
|
return true;
|
|
}
|
|
|
|
private DrawableUtils() {
|
|
}
|
|
|
|
@NonNull
|
|
public static Rect getOpticalBounds(@NonNull Drawable drawable) {
|
|
int i;
|
|
int i2;
|
|
int i3;
|
|
int i4;
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
Insets opticalInsets = Api29Impl.getOpticalInsets(drawable);
|
|
i = opticalInsets.left;
|
|
i2 = opticalInsets.top;
|
|
i3 = opticalInsets.right;
|
|
i4 = opticalInsets.bottom;
|
|
return new Rect(i, i2, i3, i4);
|
|
}
|
|
return Api18Impl.getOpticalInsets(DrawableCompat.unwrap(drawable));
|
|
}
|
|
|
|
public static void fixDrawable(@NonNull Drawable drawable) {
|
|
String name = drawable.getClass().getName();
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i < 29 || i >= 31 || !"android.graphics.drawable.ColorStateListDrawable".equals(name)) {
|
|
return;
|
|
}
|
|
forceDrawableStateChange(drawable);
|
|
}
|
|
|
|
private static void forceDrawableStateChange(Drawable drawable) {
|
|
int[] state = drawable.getState();
|
|
if (state == null || state.length == 0) {
|
|
drawable.setState(CHECKED_STATE_SET);
|
|
} else {
|
|
drawable.setState(EMPTY_STATE_SET);
|
|
}
|
|
drawable.setState(state);
|
|
}
|
|
|
|
public static PorterDuff.Mode parseTintMode(int i, PorterDuff.Mode mode) {
|
|
if (i == 3) {
|
|
return PorterDuff.Mode.SRC_OVER;
|
|
}
|
|
if (i == 5) {
|
|
return PorterDuff.Mode.SRC_IN;
|
|
}
|
|
if (i == 9) {
|
|
return PorterDuff.Mode.SRC_ATOP;
|
|
}
|
|
switch (i) {
|
|
case 14:
|
|
return PorterDuff.Mode.MULTIPLY;
|
|
case 15:
|
|
return PorterDuff.Mode.SCREEN;
|
|
case 16:
|
|
return PorterDuff.Mode.ADD;
|
|
default:
|
|
return mode;
|
|
}
|
|
}
|
|
|
|
public static class Api18Impl {
|
|
private static final Field sBottom;
|
|
private static final Method sGetOpticalInsets;
|
|
private static final Field sLeft;
|
|
private static final boolean sReflectionSuccessful;
|
|
private static final Field sRight;
|
|
private static final Field sTop;
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:16:0x004c */
|
|
/* JADX WARN: Removed duplicated region for block: B:19:0x0059 */
|
|
static {
|
|
/*
|
|
r0 = 1
|
|
r1 = 0
|
|
r2 = 0
|
|
java.lang.String r3 = "android.graphics.Insets"
|
|
java.lang.Class r3 = java.lang.Class.forName(r3) // Catch: java.lang.NoSuchFieldException -> L3f java.lang.ClassNotFoundException -> L42 java.lang.NoSuchMethodException -> L45
|
|
java.lang.Class<android.graphics.drawable.Drawable> r4 = android.graphics.drawable.Drawable.class
|
|
java.lang.String r5 = "getOpticalInsets"
|
|
java.lang.Class[] r6 = new java.lang.Class[r2] // Catch: java.lang.NoSuchFieldException -> L3f java.lang.ClassNotFoundException -> L42 java.lang.NoSuchMethodException -> L45
|
|
java.lang.reflect.Method r4 = r4.getMethod(r5, r6) // Catch: java.lang.NoSuchFieldException -> L3f java.lang.ClassNotFoundException -> L42 java.lang.NoSuchMethodException -> L45
|
|
java.lang.String r5 = "left"
|
|
java.lang.reflect.Field r5 = r3.getField(r5) // Catch: java.lang.NoSuchFieldException -> L36 java.lang.ClassNotFoundException -> L39 java.lang.NoSuchMethodException -> L3c
|
|
java.lang.String r6 = "top"
|
|
java.lang.reflect.Field r6 = r3.getField(r6) // Catch: java.lang.NoSuchFieldException -> L2f java.lang.ClassNotFoundException -> L32 java.lang.NoSuchMethodException -> L34
|
|
java.lang.String r7 = "right"
|
|
java.lang.reflect.Field r7 = r3.getField(r7) // Catch: java.lang.Throwable -> L2d
|
|
java.lang.String r8 = "bottom"
|
|
java.lang.reflect.Field r3 = r3.getField(r8) // Catch: java.lang.Throwable -> L48
|
|
r8 = r0
|
|
goto L4a
|
|
L2d:
|
|
r7 = r1
|
|
goto L48
|
|
L2f:
|
|
r6 = r1
|
|
L30:
|
|
r7 = r6
|
|
goto L48
|
|
L32:
|
|
r6 = r1
|
|
goto L30
|
|
L34:
|
|
r6 = r1
|
|
goto L30
|
|
L36:
|
|
r5 = r1
|
|
L37:
|
|
r6 = r5
|
|
goto L30
|
|
L39:
|
|
r5 = r1
|
|
L3a:
|
|
r6 = r5
|
|
goto L30
|
|
L3c:
|
|
r5 = r1
|
|
L3d:
|
|
r6 = r5
|
|
goto L30
|
|
L3f:
|
|
r4 = r1
|
|
r5 = r4
|
|
goto L37
|
|
L42:
|
|
r4 = r1
|
|
r5 = r4
|
|
goto L3a
|
|
L45:
|
|
r4 = r1
|
|
r5 = r4
|
|
goto L3d
|
|
L48:
|
|
r3 = r1
|
|
r8 = r2
|
|
L4a:
|
|
if (r8 == 0) goto L59
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sGetOpticalInsets = r4
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sLeft = r5
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sTop = r6
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sRight = r7
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sBottom = r3
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sReflectionSuccessful = r0
|
|
goto L65
|
|
L59:
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sGetOpticalInsets = r1
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sLeft = r1
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sTop = r1
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sRight = r1
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sBottom = r1
|
|
androidx.appcompat.widget.DrawableUtils.Api18Impl.sReflectionSuccessful = r2
|
|
L65:
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.DrawableUtils.Api18Impl.<clinit>():void");
|
|
}
|
|
|
|
private Api18Impl() {
|
|
}
|
|
|
|
@NonNull
|
|
public static Rect getOpticalInsets(@NonNull Drawable drawable) {
|
|
if (Build.VERSION.SDK_INT < 29 && sReflectionSuccessful) {
|
|
try {
|
|
Object invoke = sGetOpticalInsets.invoke(drawable, new Object[0]);
|
|
if (invoke != null) {
|
|
return new Rect(sLeft.getInt(invoke), sTop.getInt(invoke), sRight.getInt(invoke), sBottom.getInt(invoke));
|
|
}
|
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
|
}
|
|
}
|
|
return DrawableUtils.INSETS_NONE;
|
|
}
|
|
}
|
|
|
|
@RequiresApi(29)
|
|
public static class Api29Impl {
|
|
private Api29Impl() {
|
|
}
|
|
|
|
@DoNotInline
|
|
public static Insets getOpticalInsets(Drawable drawable) {
|
|
return drawable.getOpticalInsets();
|
|
}
|
|
}
|
|
}
|