Initial commit
This commit is contained in:
211
sources/androidx/core/graphics/drawable/DrawableCompat.java
Normal file
211
sources/androidx/core/graphics/drawable/DrawableCompat.java
Normal file
@@ -0,0 +1,211 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.DrawableContainer;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DrawableCompat {
|
||||
private static Method a;
|
||||
private static boolean b;
|
||||
private static Method c;
|
||||
private static boolean d;
|
||||
|
||||
public static void a(Drawable drawable, boolean z) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
drawable.setAutoMirrored(z);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void b(Drawable drawable, int i) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setTint(i);
|
||||
} else if (drawable instanceof TintAwareDrawable) {
|
||||
((TintAwareDrawable) drawable).setTint(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static int c(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
return drawable.getAlpha();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ColorFilter d(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return drawable.getColorFilter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int e(Drawable drawable) {
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
if (i >= 23) {
|
||||
return drawable.getLayoutDirection();
|
||||
}
|
||||
if (i >= 17) {
|
||||
if (!d) {
|
||||
try {
|
||||
c = Drawable.class.getDeclaredMethod("getLayoutDirection", new Class[0]);
|
||||
c.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i("DrawableCompat", "Failed to retrieve getLayoutDirection() method", e);
|
||||
}
|
||||
d = true;
|
||||
}
|
||||
Method method = c;
|
||||
if (method != null) {
|
||||
try {
|
||||
return ((Integer) method.invoke(drawable, new Object[0])).intValue();
|
||||
} catch (Exception e2) {
|
||||
Log.i("DrawableCompat", "Failed to invoke getLayoutDirection() via reflection", e2);
|
||||
c = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean f(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
return drawable.isAutoMirrored();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void g(Drawable drawable) {
|
||||
drawable.jumpToCurrentState();
|
||||
}
|
||||
|
||||
public static Drawable h(Drawable drawable) {
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
return i >= 23 ? drawable : i >= 21 ? !(drawable instanceof TintAwareDrawable) ? new WrappedDrawableApi21(drawable) : drawable : !(drawable instanceof TintAwareDrawable) ? new WrappedDrawableApi14(drawable) : drawable;
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, float f, float f2) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setHotspot(f, f2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, int i, int i2, int i3, int i4) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setHotspotBounds(i, i2, i3, i4);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void b(Drawable drawable) {
|
||||
DrawableContainer.DrawableContainerState drawableContainerState;
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
if (i >= 23) {
|
||||
drawable.clearColorFilter();
|
||||
return;
|
||||
}
|
||||
if (i >= 21) {
|
||||
drawable.clearColorFilter();
|
||||
if (drawable instanceof InsetDrawable) {
|
||||
b(((InsetDrawable) drawable).getDrawable());
|
||||
return;
|
||||
}
|
||||
if (drawable instanceof WrappedDrawable) {
|
||||
b(((WrappedDrawable) drawable).a());
|
||||
return;
|
||||
}
|
||||
if (!(drawable instanceof DrawableContainer) || (drawableContainerState = (DrawableContainer.DrawableContainerState) ((DrawableContainer) drawable).getConstantState()) == null) {
|
||||
return;
|
||||
}
|
||||
int childCount = drawableContainerState.getChildCount();
|
||||
for (int i2 = 0; i2 < childCount; i2++) {
|
||||
Drawable child = drawableContainerState.getChild(i2);
|
||||
if (child != null) {
|
||||
b(child);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
drawable.clearColorFilter();
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void a(Drawable drawable, ColorStateList colorStateList) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setTintList(colorStateList);
|
||||
} else if (drawable instanceof TintAwareDrawable) {
|
||||
((TintAwareDrawable) drawable).setTintList(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public static void a(Drawable drawable, PorterDuff.Mode mode) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.setTintMode(mode);
|
||||
} else if (drawable instanceof TintAwareDrawable) {
|
||||
((TintAwareDrawable) drawable).setTintMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, Resources.Theme theme) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.applyTheme(theme);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(Drawable drawable) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return drawable.canApplyTheme();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void a(Drawable drawable, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawable.inflate(resources, xmlPullParser, attributeSet, theme);
|
||||
} else {
|
||||
drawable.inflate(resources, xmlPullParser, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(Drawable drawable, int i) {
|
||||
int i2 = Build.VERSION.SDK_INT;
|
||||
if (i2 >= 23) {
|
||||
return drawable.setLayoutDirection(i);
|
||||
}
|
||||
if (i2 >= 17) {
|
||||
if (!b) {
|
||||
try {
|
||||
a = Drawable.class.getDeclaredMethod("setLayoutDirection", Integer.TYPE);
|
||||
a.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i("DrawableCompat", "Failed to retrieve setLayoutDirection(int) method", e);
|
||||
}
|
||||
b = true;
|
||||
}
|
||||
Method method = a;
|
||||
if (method != null) {
|
||||
try {
|
||||
method.invoke(drawable, Integer.valueOf(i));
|
||||
return true;
|
||||
} catch (Exception e2) {
|
||||
Log.i("DrawableCompat", "Failed to invoke setLayoutDirection(int) via reflection", e2);
|
||||
a = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
268
sources/androidx/core/graphics/drawable/IconCompat.java
Normal file
268
sources/androidx/core/graphics/drawable/IconCompat.java
Normal file
@@ -0,0 +1,268 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import androidx.versionedparcelable.CustomVersionedParcelable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class IconCompat extends CustomVersionedParcelable {
|
||||
static final PorterDuff.Mode j = PorterDuff.Mode.SRC_IN;
|
||||
public int a;
|
||||
Object b;
|
||||
public byte[] c;
|
||||
public Parcelable d;
|
||||
public int e;
|
||||
public int f;
|
||||
public ColorStateList g = null;
|
||||
PorterDuff.Mode h = j;
|
||||
public String i;
|
||||
|
||||
private static String a(int i) {
|
||||
return i != 1 ? i != 2 ? i != 3 ? i != 4 ? i != 5 ? "UNKNOWN" : "BITMAP_MASKABLE" : "URI" : "DATA" : "RESOURCE" : "BITMAP";
|
||||
}
|
||||
|
||||
public int a() {
|
||||
if (this.a == -1 && Build.VERSION.SDK_INT >= 23) {
|
||||
return a((Icon) this.b);
|
||||
}
|
||||
if (this.a == 2) {
|
||||
return this.e;
|
||||
}
|
||||
throw new IllegalStateException("called getResId() on " + this);
|
||||
}
|
||||
|
||||
public String b() {
|
||||
if (this.a == -1 && Build.VERSION.SDK_INT >= 23) {
|
||||
return b((Icon) this.b);
|
||||
}
|
||||
if (this.a == 2) {
|
||||
return ((String) this.b).split(":", -1)[0];
|
||||
}
|
||||
throw new IllegalStateException("called getResPackage() on " + this);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.h = PorterDuff.Mode.valueOf(this.i);
|
||||
int i = this.a;
|
||||
if (i == -1) {
|
||||
Parcelable parcelable = this.d;
|
||||
if (parcelable == null) {
|
||||
throw new IllegalArgumentException("Invalid icon");
|
||||
}
|
||||
this.b = parcelable;
|
||||
return;
|
||||
}
|
||||
if (i != 1) {
|
||||
if (i != 2) {
|
||||
if (i == 3) {
|
||||
this.b = this.c;
|
||||
return;
|
||||
} else if (i != 4) {
|
||||
if (i != 5) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.b = new String(this.c, Charset.forName("UTF-16"));
|
||||
return;
|
||||
}
|
||||
Parcelable parcelable2 = this.d;
|
||||
if (parcelable2 != null) {
|
||||
this.b = parcelable2;
|
||||
return;
|
||||
}
|
||||
byte[] bArr = this.c;
|
||||
this.b = bArr;
|
||||
this.a = 3;
|
||||
this.e = 0;
|
||||
this.f = bArr.length;
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:15:0x002b, code lost:
|
||||
|
||||
if (r1 != 5) goto L23;
|
||||
*/
|
||||
/* JADX WARN: Removed duplicated region for block: B:18:0x009e */
|
||||
/* JADX WARN: Removed duplicated region for block: B:21:0x00ae */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public java.lang.String toString() {
|
||||
/*
|
||||
r4 = this;
|
||||
int r0 = r4.a
|
||||
r1 = -1
|
||||
if (r0 != r1) goto Lc
|
||||
java.lang.Object r0 = r4.b
|
||||
java.lang.String r0 = java.lang.String.valueOf(r0)
|
||||
return r0
|
||||
Lc:
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
||||
java.lang.String r1 = "Icon(typ="
|
||||
r0.<init>(r1)
|
||||
int r1 = r4.a
|
||||
java.lang.String r1 = a(r1)
|
||||
r0.append(r1)
|
||||
int r1 = r4.a
|
||||
r2 = 1
|
||||
if (r1 == r2) goto L7a
|
||||
r3 = 2
|
||||
if (r1 == r3) goto L52
|
||||
r2 = 3
|
||||
if (r1 == r2) goto L39
|
||||
r2 = 4
|
||||
if (r1 == r2) goto L2e
|
||||
r2 = 5
|
||||
if (r1 == r2) goto L7a
|
||||
goto L9a
|
||||
L2e:
|
||||
java.lang.String r1 = " uri="
|
||||
r0.append(r1)
|
||||
java.lang.Object r1 = r4.b
|
||||
r0.append(r1)
|
||||
goto L9a
|
||||
L39:
|
||||
java.lang.String r1 = " len="
|
||||
r0.append(r1)
|
||||
int r1 = r4.e
|
||||
r0.append(r1)
|
||||
int r1 = r4.f
|
||||
if (r1 == 0) goto L9a
|
||||
java.lang.String r1 = " off="
|
||||
r0.append(r1)
|
||||
int r1 = r4.f
|
||||
r0.append(r1)
|
||||
goto L9a
|
||||
L52:
|
||||
java.lang.String r1 = " pkg="
|
||||
r0.append(r1)
|
||||
java.lang.String r1 = r4.b()
|
||||
r0.append(r1)
|
||||
java.lang.String r1 = " id="
|
||||
r0.append(r1)
|
||||
java.lang.Object[] r1 = new java.lang.Object[r2]
|
||||
r2 = 0
|
||||
int r3 = r4.a()
|
||||
java.lang.Integer r3 = java.lang.Integer.valueOf(r3)
|
||||
r1[r2] = r3
|
||||
java.lang.String r2 = "0x%08x"
|
||||
java.lang.String r1 = java.lang.String.format(r2, r1)
|
||||
r0.append(r1)
|
||||
goto L9a
|
||||
L7a:
|
||||
java.lang.String r1 = " size="
|
||||
r0.append(r1)
|
||||
java.lang.Object r1 = r4.b
|
||||
android.graphics.Bitmap r1 = (android.graphics.Bitmap) r1
|
||||
int r1 = r1.getWidth()
|
||||
r0.append(r1)
|
||||
java.lang.String r1 = "x"
|
||||
r0.append(r1)
|
||||
java.lang.Object r1 = r4.b
|
||||
android.graphics.Bitmap r1 = (android.graphics.Bitmap) r1
|
||||
int r1 = r1.getHeight()
|
||||
r0.append(r1)
|
||||
L9a:
|
||||
android.content.res.ColorStateList r1 = r4.g
|
||||
if (r1 == 0) goto La8
|
||||
java.lang.String r1 = " tint="
|
||||
r0.append(r1)
|
||||
android.content.res.ColorStateList r1 = r4.g
|
||||
r0.append(r1)
|
||||
La8:
|
||||
android.graphics.PorterDuff$Mode r1 = r4.h
|
||||
android.graphics.PorterDuff$Mode r2 = androidx.core.graphics.drawable.IconCompat.j
|
||||
if (r1 == r2) goto Lb8
|
||||
java.lang.String r1 = " mode="
|
||||
r0.append(r1)
|
||||
android.graphics.PorterDuff$Mode r1 = r4.h
|
||||
r0.append(r1)
|
||||
Lb8:
|
||||
java.lang.String r1 = ")"
|
||||
r0.append(r1)
|
||||
java.lang.String r0 = r0.toString()
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: androidx.core.graphics.drawable.IconCompat.toString():java.lang.String");
|
||||
}
|
||||
|
||||
private static String b(Icon icon) {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return icon.getResPackage();
|
||||
}
|
||||
try {
|
||||
return (String) icon.getClass().getMethod("getResPackage", new Class[0]).invoke(icon, new Object[0]);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("IconCompat", "Unable to get icon package", e);
|
||||
return null;
|
||||
} catch (NoSuchMethodException e2) {
|
||||
Log.e("IconCompat", "Unable to get icon package", e2);
|
||||
return null;
|
||||
} catch (InvocationTargetException e3) {
|
||||
Log.e("IconCompat", "Unable to get icon package", e3);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.i = this.h.name();
|
||||
int i = this.a;
|
||||
if (i == -1) {
|
||||
if (!z) {
|
||||
this.d = (Parcelable) this.b;
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Can't serialize Icon created with IconCompat#createFromIcon");
|
||||
}
|
||||
if (i != 1) {
|
||||
if (i == 2) {
|
||||
this.c = ((String) this.b).getBytes(Charset.forName("UTF-16"));
|
||||
return;
|
||||
}
|
||||
if (i == 3) {
|
||||
this.c = (byte[]) this.b;
|
||||
return;
|
||||
} else if (i == 4) {
|
||||
this.c = this.b.toString().getBytes(Charset.forName("UTF-16"));
|
||||
return;
|
||||
} else if (i != 5) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
Bitmap bitmap = (Bitmap) this.b;
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 90, byteArrayOutputStream);
|
||||
this.c = byteArrayOutputStream.toByteArray();
|
||||
return;
|
||||
}
|
||||
this.d = (Parcelable) this.b;
|
||||
}
|
||||
|
||||
private static int a(Icon icon) {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return icon.getResId();
|
||||
}
|
||||
try {
|
||||
return ((Integer) icon.getClass().getMethod("getResId", new Class[0]).invoke(icon, new Object[0])).intValue();
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("IconCompat", "Unable to get icon resource", e);
|
||||
return 0;
|
||||
} catch (NoSuchMethodException e2) {
|
||||
Log.e("IconCompat", "Unable to get icon resource", e2);
|
||||
return 0;
|
||||
} catch (InvocationTargetException e3) {
|
||||
Log.e("IconCompat", "Unable to get icon resource", e3);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import androidx.versionedparcelable.VersionedParcel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class IconCompatParcelizer {
|
||||
public static IconCompat read(VersionedParcel versionedParcel) {
|
||||
IconCompat iconCompat = new IconCompat();
|
||||
iconCompat.a = versionedParcel.a(iconCompat.a, 1);
|
||||
iconCompat.c = versionedParcel.a(iconCompat.c, 2);
|
||||
iconCompat.d = versionedParcel.a((VersionedParcel) iconCompat.d, 3);
|
||||
iconCompat.e = versionedParcel.a(iconCompat.e, 4);
|
||||
iconCompat.f = versionedParcel.a(iconCompat.f, 5);
|
||||
iconCompat.g = (ColorStateList) versionedParcel.a((VersionedParcel) iconCompat.g, 6);
|
||||
iconCompat.i = versionedParcel.a(iconCompat.i, 7);
|
||||
iconCompat.c();
|
||||
return iconCompat;
|
||||
}
|
||||
|
||||
public static void write(IconCompat iconCompat, VersionedParcel versionedParcel) {
|
||||
versionedParcel.a(true, true);
|
||||
iconCompat.a(versionedParcel.c());
|
||||
versionedParcel.b(iconCompat.a, 1);
|
||||
versionedParcel.b(iconCompat.c, 2);
|
||||
versionedParcel.b(iconCompat.d, 3);
|
||||
versionedParcel.b(iconCompat.e, 4);
|
||||
versionedParcel.b(iconCompat.f, 5);
|
||||
versionedParcel.b(iconCompat.g, 6);
|
||||
versionedParcel.b(iconCompat.i, 7);
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface TintAwareDrawable {
|
||||
void setTint(int i);
|
||||
|
||||
void setTintList(ColorStateList colorStateList);
|
||||
|
||||
void setTintMode(PorterDuff.Mode mode);
|
||||
}
|
10
sources/androidx/core/graphics/drawable/WrappedDrawable.java
Normal file
10
sources/androidx/core/graphics/drawable/WrappedDrawable.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface WrappedDrawable {
|
||||
Drawable a();
|
||||
|
||||
void a(Drawable drawable);
|
||||
}
|
@@ -0,0 +1,332 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class WrappedDrawableApi14 extends Drawable implements Drawable.Callback, WrappedDrawable, TintAwareDrawable {
|
||||
static final PorterDuff.Mode g = PorterDuff.Mode.SRC_IN;
|
||||
private int a;
|
||||
private PorterDuff.Mode b;
|
||||
private boolean c;
|
||||
DrawableWrapperState d;
|
||||
private boolean e;
|
||||
Drawable f;
|
||||
|
||||
protected static abstract class DrawableWrapperState extends Drawable.ConstantState {
|
||||
int a;
|
||||
Drawable.ConstantState b;
|
||||
ColorStateList c;
|
||||
PorterDuff.Mode d;
|
||||
|
||||
DrawableWrapperState(DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
this.c = null;
|
||||
this.d = WrappedDrawableApi14.g;
|
||||
if (drawableWrapperState != null) {
|
||||
this.a = drawableWrapperState.a;
|
||||
this.b = drawableWrapperState.b;
|
||||
this.c = drawableWrapperState.c;
|
||||
this.d = drawableWrapperState.d;
|
||||
}
|
||||
}
|
||||
|
||||
boolean a() {
|
||||
return this.b != null;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.ConstantState
|
||||
public int getChangingConfigurations() {
|
||||
int i = this.a;
|
||||
Drawable.ConstantState constantState = this.b;
|
||||
return i | (constantState != null ? constantState.getChangingConfigurations() : 0);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable() {
|
||||
return newDrawable(null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.ConstantState
|
||||
public abstract Drawable newDrawable(Resources resources);
|
||||
}
|
||||
|
||||
private static class DrawableWrapperStateBase extends DrawableWrapperState {
|
||||
DrawableWrapperStateBase(DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
super(drawableWrapperState, resources);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14.DrawableWrapperState, android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable(Resources resources) {
|
||||
return new WrappedDrawableApi14(this, resources);
|
||||
}
|
||||
}
|
||||
|
||||
WrappedDrawableApi14(DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
this.d = drawableWrapperState;
|
||||
a(resources);
|
||||
}
|
||||
|
||||
private void a(Resources resources) {
|
||||
Drawable.ConstantState constantState;
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState == null || (constantState = drawableWrapperState.b) == null) {
|
||||
return;
|
||||
}
|
||||
a(constantState.newDrawable(resources));
|
||||
}
|
||||
|
||||
protected boolean b() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DrawableWrapperState c() {
|
||||
return new DrawableWrapperStateBase(this.d, null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void draw(Canvas canvas) {
|
||||
this.f.draw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getChangingConfigurations() {
|
||||
int changingConfigurations = super.getChangingConfigurations();
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
return changingConfigurations | (drawableWrapperState != null ? drawableWrapperState.getChangingConfigurations() : 0) | this.f.getChangingConfigurations();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Drawable.ConstantState getConstantState() {
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState == null || !drawableWrapperState.a()) {
|
||||
return null;
|
||||
}
|
||||
this.d.a = getChangingConfigurations();
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Drawable getCurrent() {
|
||||
return this.f.getCurrent();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicHeight() {
|
||||
return this.f.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getIntrinsicWidth() {
|
||||
return this.f.getIntrinsicWidth();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getMinimumHeight() {
|
||||
return this.f.getMinimumHeight();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getMinimumWidth() {
|
||||
return this.f.getMinimumWidth();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int getOpacity() {
|
||||
return this.f.getOpacity();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean getPadding(Rect rect) {
|
||||
return this.f.getPadding(rect);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public int[] getState() {
|
||||
return this.f.getState();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Region getTransparentRegion() {
|
||||
return this.f.getTransparentRegion();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.Callback
|
||||
public void invalidateDrawable(Drawable drawable) {
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isAutoMirrored() {
|
||||
return this.f.isAutoMirrored();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isStateful() {
|
||||
DrawableWrapperState drawableWrapperState;
|
||||
ColorStateList colorStateList = (!b() || (drawableWrapperState = this.d) == null) ? null : drawableWrapperState.c;
|
||||
return (colorStateList != null && colorStateList.isStateful()) || this.f.isStateful();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void jumpToCurrentState() {
|
||||
this.f.jumpToCurrentState();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Drawable mutate() {
|
||||
if (!this.e && super.mutate() == this) {
|
||||
this.d = c();
|
||||
Drawable drawable = this.f;
|
||||
if (drawable != null) {
|
||||
drawable.mutate();
|
||||
}
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState != null) {
|
||||
Drawable drawable2 = this.f;
|
||||
drawableWrapperState.b = drawable2 != null ? drawable2.getConstantState() : null;
|
||||
}
|
||||
this.e = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
protected void onBoundsChange(Rect rect) {
|
||||
Drawable drawable = this.f;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(rect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
protected boolean onLevelChange(int i) {
|
||||
return this.f.setLevel(i);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.Callback
|
||||
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
|
||||
scheduleSelf(runnable, j);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setAlpha(int i) {
|
||||
this.f.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setAutoMirrored(boolean z) {
|
||||
this.f.setAutoMirrored(z);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setChangingConfigurations(int i) {
|
||||
this.f.setChangingConfigurations(i);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
this.f.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setDither(boolean z) {
|
||||
this.f.setDither(z);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setFilterBitmap(boolean z) {
|
||||
this.f.setFilterBitmap(z);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean setState(int[] iArr) {
|
||||
return a(iArr) || this.f.setState(iArr);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTint(int i) {
|
||||
setTintList(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintList(ColorStateList colorStateList) {
|
||||
this.d.c = colorStateList;
|
||||
a(getState());
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintMode(PorterDuff.Mode mode) {
|
||||
this.d.d = mode;
|
||||
a(getState());
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean setVisible(boolean z, boolean z2) {
|
||||
return super.setVisible(z, z2) || this.f.setVisible(z, z2);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable.Callback
|
||||
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
|
||||
unscheduleSelf(runnable);
|
||||
}
|
||||
|
||||
private boolean a(int[] iArr) {
|
||||
if (!b()) {
|
||||
return false;
|
||||
}
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
ColorStateList colorStateList = drawableWrapperState.c;
|
||||
PorterDuff.Mode mode = drawableWrapperState.d;
|
||||
if (colorStateList != null && mode != null) {
|
||||
int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
|
||||
if (!this.c || colorForState != this.a || mode != this.b) {
|
||||
setColorFilter(colorForState, mode);
|
||||
this.a = colorForState;
|
||||
this.b = mode;
|
||||
this.c = true;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
this.c = false;
|
||||
clearColorFilter();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
WrappedDrawableApi14(Drawable drawable) {
|
||||
this.d = c();
|
||||
a(drawable);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawable
|
||||
public final Drawable a() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawable
|
||||
public final void a(Drawable drawable) {
|
||||
Drawable drawable2 = this.f;
|
||||
if (drawable2 != null) {
|
||||
drawable2.setCallback(null);
|
||||
}
|
||||
this.f = drawable;
|
||||
if (drawable != null) {
|
||||
drawable.setCallback(this);
|
||||
setVisible(drawable.isVisible(), true);
|
||||
setState(drawable.getState());
|
||||
setLevel(drawable.getLevel());
|
||||
setBounds(drawable.getBounds());
|
||||
DrawableWrapperState drawableWrapperState = this.d;
|
||||
if (drawableWrapperState != null) {
|
||||
drawableWrapperState.b = drawable.getConstantState();
|
||||
}
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
package androidx.core.graphics.drawable;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.DrawableContainer;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import androidx.core.graphics.drawable.WrappedDrawableApi14;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class WrappedDrawableApi21 extends WrappedDrawableApi14 {
|
||||
private static Method h;
|
||||
|
||||
private static class DrawableWrapperStateLollipop extends WrappedDrawableApi14.DrawableWrapperState {
|
||||
DrawableWrapperStateLollipop(WrappedDrawableApi14.DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
super(drawableWrapperState, resources);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14.DrawableWrapperState, android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable(Resources resources) {
|
||||
return new WrappedDrawableApi21(this, resources);
|
||||
}
|
||||
}
|
||||
|
||||
WrappedDrawableApi21(Drawable drawable) {
|
||||
super(drawable);
|
||||
d();
|
||||
}
|
||||
|
||||
private void d() {
|
||||
if (h == null) {
|
||||
try {
|
||||
h = Drawable.class.getDeclaredMethod("isProjected", new Class[0]);
|
||||
} catch (Exception e) {
|
||||
Log.w("WrappedDrawableApi21", "Failed to retrieve Drawable#isProjected() method", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14
|
||||
protected boolean b() {
|
||||
if (Build.VERSION.SDK_INT != 21) {
|
||||
return false;
|
||||
}
|
||||
Drawable drawable = this.f;
|
||||
return (drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable) || (drawable instanceof RippleDrawable);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14
|
||||
WrappedDrawableApi14.DrawableWrapperState c() {
|
||||
return new DrawableWrapperStateLollipop(this.d, null);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public Rect getDirtyBounds() {
|
||||
return this.f.getDirtyBounds();
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void getOutline(Outline outline) {
|
||||
this.f.getOutline(outline);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public boolean isProjected() {
|
||||
Method method;
|
||||
Drawable drawable = this.f;
|
||||
if (drawable != null && (method = h) != null) {
|
||||
try {
|
||||
return ((Boolean) method.invoke(drawable, new Object[0])).booleanValue();
|
||||
} catch (Exception e) {
|
||||
Log.w("WrappedDrawableApi21", "Error calling Drawable#isProjected() method", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setHotspot(float f, float f2) {
|
||||
this.f.setHotspot(f, f2);
|
||||
}
|
||||
|
||||
@Override // android.graphics.drawable.Drawable
|
||||
public void setHotspotBounds(int i, int i2, int i3, int i4) {
|
||||
this.f.setHotspotBounds(i, i2, i3, i4);
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable
|
||||
public boolean setState(int[] iArr) {
|
||||
if (!super.setState(iArr)) {
|
||||
return false;
|
||||
}
|
||||
invalidateSelf();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTint(int i) {
|
||||
if (b()) {
|
||||
super.setTint(i);
|
||||
} else {
|
||||
this.f.setTint(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintList(ColorStateList colorStateList) {
|
||||
if (b()) {
|
||||
super.setTintList(colorStateList);
|
||||
} else {
|
||||
this.f.setTintList(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
||||
public void setTintMode(PorterDuff.Mode mode) {
|
||||
if (b()) {
|
||||
super.setTintMode(mode);
|
||||
} else {
|
||||
this.f.setTintMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
WrappedDrawableApi21(WrappedDrawableApi14.DrawableWrapperState drawableWrapperState, Resources resources) {
|
||||
super(drawableWrapperState, resources);
|
||||
d();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user