Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package androidx.core.graphics.drawable;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
/* loaded from: classes.dex */
public final class BitmapDrawableKt {
public static final BitmapDrawable toDrawable(Bitmap bitmap, Resources resources) {
return new BitmapDrawable(resources, bitmap);
}
}

View File

@@ -0,0 +1,20 @@
package androidx.core.graphics.drawable;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import androidx.annotation.ColorInt;
import androidx.annotation.RequiresApi;
/* loaded from: classes.dex */
public final class ColorDrawableKt {
public static final ColorDrawable toDrawable(@ColorInt int i) {
return new ColorDrawable(i);
}
@RequiresApi(26)
@SuppressLint({"ClassVerificationFailure"})
public static final ColorDrawable toDrawable(Color color) {
return new ColorDrawable(color.toArgb());
}
}

View File

@@ -0,0 +1,168 @@
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.util.AttributeSet;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.ReplaceWith;
import androidx.annotation.RequiresApi;
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 final String TAG = "DrawableCompat";
private static Method sGetLayoutDirectionMethod;
private static boolean sGetLayoutDirectionMethodFetched;
private static Method sSetLayoutDirectionMethod;
private static boolean sSetLayoutDirectionMethodFetched;
@NonNull
public static Drawable wrap(@NonNull Drawable drawable) {
return drawable;
}
@ReplaceWith(expression = "drawable.jumpToCurrentState()")
@Deprecated
public static void jumpToCurrentState(@NonNull Drawable drawable) {
drawable.jumpToCurrentState();
}
@ReplaceWith(expression = "drawable.setAutoMirrored(mirrored)")
@Deprecated
public static void setAutoMirrored(@NonNull Drawable drawable, boolean z) {
drawable.setAutoMirrored(z);
}
@ReplaceWith(expression = "drawable.isAutoMirrored()")
@Deprecated
public static boolean isAutoMirrored(@NonNull Drawable drawable) {
return drawable.isAutoMirrored();
}
public static void setHotspot(@NonNull Drawable drawable, float f, float f2) {
Api21Impl.setHotspot(drawable, f, f2);
}
public static void setHotspotBounds(@NonNull Drawable drawable, int i, int i2, int i3, int i4) {
Api21Impl.setHotspotBounds(drawable, i, i2, i3, i4);
}
public static void setTint(@NonNull Drawable drawable, @ColorInt int i) {
Api21Impl.setTint(drawable, i);
}
public static void setTintList(@NonNull Drawable drawable, @Nullable ColorStateList colorStateList) {
Api21Impl.setTintList(drawable, colorStateList);
}
public static void setTintMode(@NonNull Drawable drawable, @Nullable PorterDuff.Mode mode) {
Api21Impl.setTintMode(drawable, mode);
}
@ReplaceWith(expression = "drawable.getAlpha()")
@Deprecated
public static int getAlpha(@NonNull Drawable drawable) {
return drawable.getAlpha();
}
public static void applyTheme(@NonNull Drawable drawable, @NonNull Resources.Theme theme) {
Api21Impl.applyTheme(drawable, theme);
}
public static boolean canApplyTheme(@NonNull Drawable drawable) {
return Api21Impl.canApplyTheme(drawable);
}
@Nullable
public static ColorFilter getColorFilter(@NonNull Drawable drawable) {
return Api21Impl.getColorFilter(drawable);
}
public static void clearColorFilter(@NonNull Drawable drawable) {
drawable.clearColorFilter();
}
public static void inflate(@NonNull Drawable drawable, @NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Resources.Theme theme) throws XmlPullParserException, IOException {
Api21Impl.inflate(drawable, resources, xmlPullParser, attributeSet, theme);
}
/* JADX WARN: Multi-variable type inference failed */
public static <T extends Drawable> T unwrap(@NonNull Drawable drawable) {
return drawable instanceof WrappedDrawable ? (T) ((WrappedDrawable) drawable).getWrappedDrawable() : drawable;
}
public static boolean setLayoutDirection(@NonNull Drawable drawable, int i) {
return Api23Impl.setLayoutDirection(drawable, i);
}
public static int getLayoutDirection(@NonNull Drawable drawable) {
return Api23Impl.getLayoutDirection(drawable);
}
private DrawableCompat() {
}
@RequiresApi(21)
public static class Api21Impl {
private Api21Impl() {
}
public static void setHotspot(Drawable drawable, float f, float f2) {
drawable.setHotspot(f, f2);
}
public static void setTint(Drawable drawable, int i) {
drawable.setTint(i);
}
public static void setTintList(Drawable drawable, ColorStateList colorStateList) {
drawable.setTintList(colorStateList);
}
public static void setTintMode(Drawable drawable, PorterDuff.Mode mode) {
drawable.setTintMode(mode);
}
public static void applyTheme(Drawable drawable, Resources.Theme theme) {
drawable.applyTheme(theme);
}
public static boolean canApplyTheme(Drawable drawable) {
return drawable.canApplyTheme();
}
public static ColorFilter getColorFilter(Drawable drawable) {
return drawable.getColorFilter();
}
public static void inflate(Drawable drawable, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
drawable.inflate(resources, xmlPullParser, attributeSet, theme);
}
public static void setHotspotBounds(Drawable drawable, int i, int i2, int i3, int i4) {
drawable.setHotspotBounds(i, i2, i3, i4);
}
}
@RequiresApi(23)
public static class Api23Impl {
private Api23Impl() {
}
public static boolean setLayoutDirection(Drawable drawable, int i) {
return drawable.setLayoutDirection(i);
}
public static int getLayoutDirection(Drawable drawable) {
return drawable.getLayoutDirection();
}
}
}

View File

@@ -0,0 +1,94 @@
package androidx.core.graphics.drawable;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import androidx.annotation.Px;
import kotlin.jvm.internal.SourceDebugExtension;
@SourceDebugExtension({"SMAP\nDrawable.kt\nKotlin\n*S Kotlin\n*F\n+ 1 Drawable.kt\nandroidx/core/graphics/drawable/DrawableKt\n+ 2 Rect.kt\nandroidx/core/graphics/RectKt\n*L\n1#1,118:1\n37#2,31:119\n*S KotlinDebug\n*F\n+ 1 Drawable.kt\nandroidx/core/graphics/drawable/DrawableKt\n*L\n66#1:119,31\n*E\n"})
/* loaded from: classes.dex */
public final class DrawableKt {
public static /* synthetic */ Bitmap toBitmap$default(Drawable drawable, int i, int i2, Bitmap.Config config, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = drawable.getIntrinsicWidth();
}
if ((i3 & 2) != 0) {
i2 = drawable.getIntrinsicHeight();
}
if ((i3 & 4) != 0) {
config = null;
}
return toBitmap(drawable, i, i2, config);
}
public static final Bitmap toBitmap(Drawable drawable, @Px int i, @Px int i2, Bitmap.Config config) {
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if (bitmapDrawable.getBitmap() == null) {
throw new IllegalArgumentException("bitmap is null");
}
if (config == null || bitmapDrawable.getBitmap().getConfig() == config) {
if (i == bitmapDrawable.getBitmap().getWidth() && i2 == bitmapDrawable.getBitmap().getHeight()) {
return bitmapDrawable.getBitmap();
}
return Bitmap.createScaledBitmap(bitmapDrawable.getBitmap(), i, i2, true);
}
}
Rect bounds = drawable.getBounds();
int i3 = bounds.left;
int i4 = bounds.top;
int i5 = bounds.right;
int i6 = bounds.bottom;
if (config == null) {
config = Bitmap.Config.ARGB_8888;
}
Bitmap createBitmap = Bitmap.createBitmap(i, i2, config);
drawable.setBounds(0, 0, i, i2);
drawable.draw(new Canvas(createBitmap));
drawable.setBounds(i3, i4, i5, i6);
return createBitmap;
}
public static /* synthetic */ Bitmap toBitmapOrNull$default(Drawable drawable, int i, int i2, Bitmap.Config config, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = drawable.getIntrinsicWidth();
}
if ((i3 & 2) != 0) {
i2 = drawable.getIntrinsicHeight();
}
if ((i3 & 4) != 0) {
config = null;
}
return toBitmapOrNull(drawable, i, i2, config);
}
public static final Bitmap toBitmapOrNull(Drawable drawable, @Px int i, @Px int i2, Bitmap.Config config) {
if ((drawable instanceof BitmapDrawable) && ((BitmapDrawable) drawable).getBitmap() == null) {
return null;
}
return toBitmap(drawable, i, i2, config);
}
public static /* synthetic */ void updateBounds$default(Drawable drawable, int i, int i2, int i3, int i4, int i5, Object obj) {
if ((i5 & 1) != 0) {
i = drawable.getBounds().left;
}
if ((i5 & 2) != 0) {
i2 = drawable.getBounds().top;
}
if ((i5 & 4) != 0) {
i3 = drawable.getBounds().right;
}
if ((i5 & 8) != 0) {
i4 = drawable.getBounds().bottom;
}
updateBounds(drawable, i, i2, i3, i4);
}
public static final void updateBounds(Drawable drawable, @Px int i, @Px int i2, @Px int i3, @Px int i4) {
drawable.setBounds(i, i2, i3, i4);
}
}

View File

@@ -0,0 +1,972 @@
package androidx.core.graphics.drawable;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.util.ObjectsCompat;
import androidx.core.util.Preconditions;
import androidx.core.view.ViewCompat;
import androidx.versionedparcelable.CustomVersionedParcelable;
import com.facebook.internal.security.CertificateUtil;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.Charset;
/* loaded from: classes.dex */
public class IconCompat extends CustomVersionedParcelable {
private static final float ADAPTIVE_ICON_INSET_FACTOR = 0.25f;
private static final int AMBIENT_SHADOW_ALPHA = 30;
private static final float BLUR_FACTOR = 0.010416667f;
static final PorterDuff.Mode DEFAULT_TINT_MODE = PorterDuff.Mode.SRC_IN;
private static final float DEFAULT_VIEW_PORT_SCALE = 0.6666667f;
@VisibleForTesting
static final String EXTRA_INT1 = "int1";
@VisibleForTesting
static final String EXTRA_INT2 = "int2";
@VisibleForTesting
static final String EXTRA_OBJ = "obj";
@VisibleForTesting
static final String EXTRA_STRING1 = "string1";
@VisibleForTesting
static final String EXTRA_TINT_LIST = "tint_list";
@VisibleForTesting
static final String EXTRA_TINT_MODE = "tint_mode";
@VisibleForTesting
static final String EXTRA_TYPE = "type";
private static final float ICON_DIAMETER_FACTOR = 0.9166667f;
private static final int KEY_SHADOW_ALPHA = 61;
private static final float KEY_SHADOW_OFFSET_FACTOR = 0.020833334f;
private static final String TAG = "IconCompat";
public static final int TYPE_ADAPTIVE_BITMAP = 5;
public static final int TYPE_BITMAP = 1;
public static final int TYPE_DATA = 3;
public static final int TYPE_RESOURCE = 2;
public static final int TYPE_UNKNOWN = -1;
public static final int TYPE_URI = 4;
public static final int TYPE_URI_ADAPTIVE_BITMAP = 6;
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public byte[] mData;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int mInt1;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int mInt2;
Object mObj1;
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Parcelable mParcelable;
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public String mString1;
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public ColorStateList mTintList;
PorterDuff.Mode mTintMode;
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public String mTintModeStr;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public int mType;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface IconType {
}
private static String typeToString(int i) {
switch (i) {
case 1:
return "BITMAP";
case 2:
return "RESOURCE";
case 3:
return "DATA";
case 4:
return "URI";
case 5:
return "BITMAP_MASKABLE";
case 6:
return "URI_MASKABLE";
default:
return "UNKNOWN";
}
}
@NonNull
public IconCompat setTintList(@Nullable ColorStateList colorStateList) {
this.mTintList = colorStateList;
return this;
}
@NonNull
public IconCompat setTintMode(@Nullable PorterDuff.Mode mode) {
this.mTintMode = mode;
return this;
}
@NonNull
public static IconCompat createWithResource(@NonNull Context context, @DrawableRes int i) {
ObjectsCompat.requireNonNull(context);
return createWithResource(context.getResources(), context.getPackageName(), i);
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static IconCompat createWithResource(@Nullable Resources resources, @NonNull String str, @DrawableRes int i) {
ObjectsCompat.requireNonNull(str);
if (i == 0) {
throw new IllegalArgumentException("Drawable resource ID must not be 0");
}
IconCompat iconCompat = new IconCompat(2);
iconCompat.mInt1 = i;
if (resources != null) {
try {
iconCompat.mObj1 = resources.getResourceName(i);
} catch (Resources.NotFoundException unused) {
throw new IllegalArgumentException("Icon resource cannot be found");
}
} else {
iconCompat.mObj1 = str;
}
iconCompat.mString1 = str;
return iconCompat;
}
@NonNull
public static IconCompat createWithBitmap(@NonNull Bitmap bitmap) {
ObjectsCompat.requireNonNull(bitmap);
IconCompat iconCompat = new IconCompat(1);
iconCompat.mObj1 = bitmap;
return iconCompat;
}
@NonNull
public static IconCompat createWithAdaptiveBitmap(@NonNull Bitmap bitmap) {
ObjectsCompat.requireNonNull(bitmap);
IconCompat iconCompat = new IconCompat(5);
iconCompat.mObj1 = bitmap;
return iconCompat;
}
@NonNull
public static IconCompat createWithData(@NonNull byte[] bArr, int i, int i2) {
ObjectsCompat.requireNonNull(bArr);
IconCompat iconCompat = new IconCompat(3);
iconCompat.mObj1 = bArr;
iconCompat.mInt1 = i;
iconCompat.mInt2 = i2;
return iconCompat;
}
@NonNull
public static IconCompat createWithContentUri(@NonNull String str) {
ObjectsCompat.requireNonNull(str);
IconCompat iconCompat = new IconCompat(4);
iconCompat.mObj1 = str;
return iconCompat;
}
@NonNull
public static IconCompat createWithContentUri(@NonNull Uri uri) {
ObjectsCompat.requireNonNull(uri);
return createWithContentUri(uri.toString());
}
@NonNull
public static IconCompat createWithAdaptiveBitmapContentUri(@NonNull String str) {
ObjectsCompat.requireNonNull(str);
IconCompat iconCompat = new IconCompat(6);
iconCompat.mObj1 = str;
return iconCompat;
}
@NonNull
public static IconCompat createWithAdaptiveBitmapContentUri(@NonNull Uri uri) {
ObjectsCompat.requireNonNull(uri);
return createWithAdaptiveBitmapContentUri(uri.toString());
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public IconCompat() {
this.mType = -1;
this.mData = null;
this.mParcelable = null;
this.mInt1 = 0;
this.mInt2 = 0;
this.mTintList = null;
this.mTintMode = DEFAULT_TINT_MODE;
this.mTintModeStr = null;
}
public IconCompat(int i) {
this.mData = null;
this.mParcelable = null;
this.mInt1 = 0;
this.mInt2 = 0;
this.mTintList = null;
this.mTintMode = DEFAULT_TINT_MODE;
this.mTintModeStr = null;
this.mType = i;
}
public int getType() {
int i = this.mType;
return i == -1 ? Api23Impl.getType(this.mObj1) : i;
}
@NonNull
public String getResPackage() {
int i = this.mType;
if (i == -1) {
return Api23Impl.getResPackage(this.mObj1);
}
if (i == 2) {
String str = this.mString1;
return (str == null || TextUtils.isEmpty(str)) ? ((String) this.mObj1).split(CertificateUtil.DELIMITER, -1)[0] : this.mString1;
}
throw new IllegalStateException("called getResPackage() on " + this);
}
@DrawableRes
public int getResId() {
int i = this.mType;
if (i == -1) {
return Api23Impl.getResId(this.mObj1);
}
if (i == 2) {
return this.mInt1;
}
throw new IllegalStateException("called getResId() on " + this);
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Bitmap getBitmap() {
int i = this.mType;
if (i == -1) {
Object obj = this.mObj1;
if (obj instanceof Bitmap) {
return (Bitmap) obj;
}
return null;
}
if (i == 1) {
return (Bitmap) this.mObj1;
}
if (i == 5) {
return createLegacyIconFromAdaptiveIcon((Bitmap) this.mObj1, true);
}
throw new IllegalStateException("called getBitmap() on " + this);
}
@NonNull
public Uri getUri() {
int i = this.mType;
if (i == -1) {
return Api23Impl.getUri(this.mObj1);
}
if (i != 4 && i != 6) {
throw new IllegalStateException("called getUri() on " + this);
}
return Uri.parse((String) this.mObj1);
}
@NonNull
public IconCompat setTint(@ColorInt int i) {
return setTintList(ColorStateList.valueOf(i));
}
@NonNull
@RequiresApi(23)
@Deprecated
public Icon toIcon() {
return toIcon(null);
}
@NonNull
@RequiresApi(23)
public Icon toIcon(@Nullable Context context) {
return Api23Impl.toIcon(this, context);
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void checkResource(@NonNull Context context) {
Object obj;
if (this.mType != 2 || (obj = this.mObj1) == null) {
return;
}
String str = (String) obj;
if (str.contains(CertificateUtil.DELIMITER)) {
String str2 = str.split(CertificateUtil.DELIMITER, -1)[1];
String str3 = str2.split("/", -1)[0];
String str4 = str2.split("/", -1)[1];
String str5 = str.split(CertificateUtil.DELIMITER, -1)[0];
if ("0_resource_name_obfuscated".equals(str4)) {
return;
}
String resPackage = getResPackage();
int identifier = getResources(context, resPackage).getIdentifier(str4, str3, str5);
if (this.mInt1 != identifier) {
StringBuilder sb = new StringBuilder();
sb.append("Id has changed for ");
sb.append(resPackage);
sb.append(" ");
sb.append(str);
this.mInt1 = identifier;
}
}
}
@Nullable
public Drawable loadDrawable(@NonNull Context context) {
checkResource(context);
return Api23Impl.loadDrawable(toIcon(context), context);
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
private Drawable loadDrawableInner(Context context) {
switch (this.mType) {
case 1:
return new BitmapDrawable(context.getResources(), (Bitmap) this.mObj1);
case 2:
String resPackage = getResPackage();
if (TextUtils.isEmpty(resPackage)) {
resPackage = context.getPackageName();
}
try {
return ResourcesCompat.getDrawable(getResources(context, resPackage), this.mInt1, context.getTheme());
} catch (RuntimeException e) {
Log.e(TAG, String.format("Unable to load resource 0x%08x from pkg=%s", Integer.valueOf(this.mInt1), this.mObj1), e);
break;
}
case 3:
return new BitmapDrawable(context.getResources(), BitmapFactory.decodeByteArray((byte[]) this.mObj1, this.mInt1, this.mInt2));
case 4:
InputStream uriInputStream = getUriInputStream(context);
if (uriInputStream != null) {
return new BitmapDrawable(context.getResources(), BitmapFactory.decodeStream(uriInputStream));
}
return null;
case 5:
return new BitmapDrawable(context.getResources(), createLegacyIconFromAdaptiveIcon((Bitmap) this.mObj1, false));
case 6:
InputStream uriInputStream2 = getUriInputStream(context);
if (uriInputStream2 != null) {
return Api26Impl.createAdaptiveIconDrawable(null, new BitmapDrawable(context.getResources(), BitmapFactory.decodeStream(uriInputStream2)));
}
return null;
default:
return null;
}
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public InputStream getUriInputStream(@NonNull Context context) {
Uri uri = getUri();
String scheme = uri.getScheme();
if ("content".equals(scheme) || "file".equals(scheme)) {
try {
return context.getContentResolver().openInputStream(uri);
} catch (Exception e) {
Log.w(TAG, "Unable to load image from URI: " + uri, e);
return null;
}
}
try {
return new FileInputStream(new File((String) this.mObj1));
} catch (FileNotFoundException e2) {
Log.w(TAG, "Unable to load image from path: " + uri, e2);
return null;
}
}
public static Resources getResources(Context context, String str) {
if ("android".equals(str)) {
return Resources.getSystem();
}
PackageManager packageManager = context.getPackageManager();
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(str, 8192);
if (applicationInfo != null) {
return packageManager.getResourcesForApplication(applicationInfo);
}
return null;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, String.format("Unable to find pkg=%s for icon", str), e);
return null;
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void addToShortcutIntent(@NonNull Intent intent, @Nullable Drawable drawable, @NonNull Context context) {
Bitmap bitmap;
checkResource(context);
int i = this.mType;
if (i == 1) {
bitmap = (Bitmap) this.mObj1;
if (drawable != null) {
bitmap = bitmap.copy(bitmap.getConfig(), true);
}
} else if (i == 2) {
try {
Context createPackageContext = context.createPackageContext(getResPackage(), 0);
if (drawable == null) {
intent.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", Intent.ShortcutIconResource.fromContext(createPackageContext, this.mInt1));
return;
}
Drawable drawable2 = ContextCompat.getDrawable(createPackageContext, this.mInt1);
if (drawable2.getIntrinsicWidth() > 0 && drawable2.getIntrinsicHeight() > 0) {
bitmap = Bitmap.createBitmap(drawable2.getIntrinsicWidth(), drawable2.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
drawable2.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
drawable2.draw(new Canvas(bitmap));
}
int launcherLargeIconSize = ((ActivityManager) createPackageContext.getSystemService("activity")).getLauncherLargeIconSize();
bitmap = Bitmap.createBitmap(launcherLargeIconSize, launcherLargeIconSize, Bitmap.Config.ARGB_8888);
drawable2.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
drawable2.draw(new Canvas(bitmap));
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Can't find package " + this.mObj1, e);
}
} else if (i == 5) {
bitmap = createLegacyIconFromAdaptiveIcon((Bitmap) this.mObj1, true);
} else {
throw new IllegalArgumentException("Icon type not supported for intent shortcuts");
}
if (drawable != null) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
drawable.setBounds(width / 2, height / 2, width, height);
drawable.draw(new Canvas(bitmap));
}
intent.putExtra("android.intent.extra.shortcut.ICON", bitmap);
}
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
switch (this.mType) {
case -1:
bundle.putParcelable(EXTRA_OBJ, (Parcelable) this.mObj1);
break;
case 0:
default:
throw new IllegalArgumentException("Invalid icon");
case 1:
case 5:
bundle.putParcelable(EXTRA_OBJ, (Bitmap) this.mObj1);
break;
case 2:
case 4:
case 6:
bundle.putString(EXTRA_OBJ, (String) this.mObj1);
break;
case 3:
bundle.putByteArray(EXTRA_OBJ, (byte[]) this.mObj1);
break;
}
bundle.putInt("type", this.mType);
bundle.putInt(EXTRA_INT1, this.mInt1);
bundle.putInt(EXTRA_INT2, this.mInt2);
bundle.putString(EXTRA_STRING1, this.mString1);
ColorStateList colorStateList = this.mTintList;
if (colorStateList != null) {
bundle.putParcelable(EXTRA_TINT_LIST, colorStateList);
}
PorterDuff.Mode mode = this.mTintMode;
if (mode != DEFAULT_TINT_MODE) {
bundle.putString(EXTRA_TINT_MODE, mode.name());
}
return bundle;
}
@NonNull
public String toString() {
if (this.mType == -1) {
return String.valueOf(this.mObj1);
}
StringBuilder sb = new StringBuilder("Icon(typ=");
sb.append(typeToString(this.mType));
switch (this.mType) {
case 1:
case 5:
sb.append(" size=");
sb.append(((Bitmap) this.mObj1).getWidth());
sb.append("x");
sb.append(((Bitmap) this.mObj1).getHeight());
break;
case 2:
sb.append(" pkg=");
sb.append(this.mString1);
sb.append(" id=");
sb.append(String.format("0x%08x", Integer.valueOf(getResId())));
break;
case 3:
sb.append(" len=");
sb.append(this.mInt1);
if (this.mInt2 != 0) {
sb.append(" off=");
sb.append(this.mInt2);
break;
}
break;
case 4:
case 6:
sb.append(" uri=");
sb.append(this.mObj1);
break;
}
if (this.mTintList != null) {
sb.append(" tint=");
sb.append(this.mTintList);
}
if (this.mTintMode != DEFAULT_TINT_MODE) {
sb.append(" mode=");
sb.append(this.mTintMode);
}
sb.append(")");
return sb.toString();
}
@Override // androidx.versionedparcelable.CustomVersionedParcelable
public void onPreParceling(boolean z) {
this.mTintModeStr = this.mTintMode.name();
switch (this.mType) {
case -1:
if (z) {
throw new IllegalArgumentException("Can't serialize Icon created with IconCompat#createFromIcon");
}
this.mParcelable = (Parcelable) this.mObj1;
return;
case 0:
default:
return;
case 1:
case 5:
if (z) {
Bitmap bitmap = (Bitmap) this.mObj1;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, byteArrayOutputStream);
this.mData = byteArrayOutputStream.toByteArray();
return;
}
this.mParcelable = (Parcelable) this.mObj1;
return;
case 2:
this.mData = ((String) this.mObj1).getBytes(Charset.forName("UTF-16"));
return;
case 3:
this.mData = (byte[]) this.mObj1;
return;
case 4:
case 6:
this.mData = this.mObj1.toString().getBytes(Charset.forName("UTF-16"));
return;
}
}
@Override // androidx.versionedparcelable.CustomVersionedParcelable
public void onPostParceling() {
this.mTintMode = PorterDuff.Mode.valueOf(this.mTintModeStr);
switch (this.mType) {
case -1:
Parcelable parcelable = this.mParcelable;
if (parcelable == null) {
throw new IllegalArgumentException("Invalid icon");
}
this.mObj1 = parcelable;
return;
case 0:
default:
return;
case 1:
case 5:
Parcelable parcelable2 = this.mParcelable;
if (parcelable2 != null) {
this.mObj1 = parcelable2;
return;
}
byte[] bArr = this.mData;
this.mObj1 = bArr;
this.mType = 3;
this.mInt1 = 0;
this.mInt2 = bArr.length;
return;
case 2:
case 4:
case 6:
String str = new String(this.mData, Charset.forName("UTF-16"));
this.mObj1 = str;
if (this.mType == 2 && this.mString1 == null) {
this.mString1 = str.split(CertificateUtil.DELIMITER, -1)[0];
return;
}
return;
case 3:
this.mObj1 = this.mData;
return;
}
}
@Nullable
public static IconCompat createFromBundle(@NonNull Bundle bundle) {
int i = bundle.getInt("type");
IconCompat iconCompat = new IconCompat(i);
iconCompat.mInt1 = bundle.getInt(EXTRA_INT1);
iconCompat.mInt2 = bundle.getInt(EXTRA_INT2);
iconCompat.mString1 = bundle.getString(EXTRA_STRING1);
if (bundle.containsKey(EXTRA_TINT_LIST)) {
iconCompat.mTintList = (ColorStateList) bundle.getParcelable(EXTRA_TINT_LIST);
}
if (bundle.containsKey(EXTRA_TINT_MODE)) {
iconCompat.mTintMode = PorterDuff.Mode.valueOf(bundle.getString(EXTRA_TINT_MODE));
}
switch (i) {
case -1:
case 1:
case 5:
iconCompat.mObj1 = bundle.getParcelable(EXTRA_OBJ);
return iconCompat;
case 0:
default:
Log.w(TAG, "Unknown type " + i);
return null;
case 2:
case 4:
case 6:
iconCompat.mObj1 = bundle.getString(EXTRA_OBJ);
return iconCompat;
case 3:
iconCompat.mObj1 = bundle.getByteArray(EXTRA_OBJ);
return iconCompat;
}
}
@Nullable
@RequiresApi(23)
public static IconCompat createFromIcon(@NonNull Context context, @NonNull Icon icon) {
Preconditions.checkNotNull(icon);
return Api23Impl.createFromIcon(context, icon);
}
@Nullable
@RequiresApi(23)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static IconCompat createFromIcon(@NonNull Icon icon) {
return Api23Impl.createFromIconInner(icon);
}
@Nullable
@RequiresApi(23)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static IconCompat createFromIconOrNullIfZeroResId(@NonNull Icon icon) {
if (Api23Impl.getType(icon) == 2 && Api23Impl.getResId(icon) == 0) {
return null;
}
return Api23Impl.createFromIconInner(icon);
}
@VisibleForTesting
public static Bitmap createLegacyIconFromAdaptiveIcon(Bitmap bitmap, boolean z) {
int min = (int) (Math.min(bitmap.getWidth(), bitmap.getHeight()) * DEFAULT_VIEW_PORT_SCALE);
Bitmap createBitmap = Bitmap.createBitmap(min, min, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
Paint paint = new Paint(3);
float f = min;
float f2 = 0.5f * f;
float f3 = ICON_DIAMETER_FACTOR * f2;
if (z) {
float f4 = BLUR_FACTOR * f;
paint.setColor(0);
paint.setShadowLayer(f4, 0.0f, f * KEY_SHADOW_OFFSET_FACTOR, 1023410176);
canvas.drawCircle(f2, f2, f3, paint);
paint.setShadowLayer(f4, 0.0f, 0.0f, 503316480);
canvas.drawCircle(f2, f2, f3, paint);
paint.clearShadowLayer();
}
paint.setColor(ViewCompat.MEASURED_STATE_MASK);
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
BitmapShader bitmapShader = new BitmapShader(bitmap, tileMode, tileMode);
Matrix matrix = new Matrix();
matrix.setTranslate((-(bitmap.getWidth() - min)) / 2.0f, (-(bitmap.getHeight() - min)) / 2.0f);
bitmapShader.setLocalMatrix(matrix);
paint.setShader(bitmapShader);
canvas.drawCircle(f2, f2, f3, paint);
canvas.setBitmap(null);
return createBitmap;
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
public static String getResPackage(Object obj) {
return ((Icon) obj).getResPackage();
}
public static int getType(Object obj) {
return ((Icon) obj).getType();
}
public static int getResId(Object obj) {
return ((Icon) obj).getResId();
}
public static Uri getUri(Object obj) {
return ((Icon) obj).getUri();
}
}
@RequiresApi(26)
public static class Api26Impl {
private Api26Impl() {
}
public static Drawable createAdaptiveIconDrawable(Drawable drawable, Drawable drawable2) {
return new AdaptiveIconDrawable(drawable, drawable2);
}
public static Icon createWithAdaptiveBitmap(Bitmap bitmap) {
return Icon.createWithAdaptiveBitmap(bitmap);
}
}
@RequiresApi(30)
public static class Api30Impl {
private Api30Impl() {
}
public static Icon createWithAdaptiveBitmapContentUri(Uri uri) {
return Icon.createWithAdaptiveBitmapContentUri(uri);
}
}
@RequiresApi(23)
public static class Api23Impl {
private Api23Impl() {
}
@Nullable
public static IconCompat createFromIcon(@NonNull Context context, @NonNull Icon icon) {
int type = getType(icon);
if (type == 2) {
String resPackage = getResPackage(icon);
try {
return IconCompat.createWithResource(IconCompat.getResources(context, resPackage), resPackage, getResId(icon));
} catch (Resources.NotFoundException unused) {
throw new IllegalArgumentException("Icon resource cannot be found");
}
}
if (type == 4) {
return IconCompat.createWithContentUri(getUri(icon));
}
if (type == 6) {
return IconCompat.createWithAdaptiveBitmapContentUri(getUri(icon));
}
IconCompat iconCompat = new IconCompat(-1);
iconCompat.mObj1 = icon;
return iconCompat;
}
public static int getType(@NonNull Object obj) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getType(obj);
}
try {
return ((Integer) obj.getClass().getMethod("getType", new Class[0]).invoke(obj, new Object[0])).intValue();
} catch (IllegalAccessException e) {
Log.e(IconCompat.TAG, "Unable to get icon type " + obj, e);
return -1;
} catch (NoSuchMethodException e2) {
Log.e(IconCompat.TAG, "Unable to get icon type " + obj, e2);
return -1;
} catch (InvocationTargetException e3) {
Log.e(IconCompat.TAG, "Unable to get icon type " + obj, e3);
return -1;
}
}
@Nullable
public static String getResPackage(@NonNull Object obj) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getResPackage(obj);
}
try {
return (String) obj.getClass().getMethod("getResPackage", new Class[0]).invoke(obj, new Object[0]);
} catch (IllegalAccessException e) {
Log.e(IconCompat.TAG, "Unable to get icon package", e);
return null;
} catch (NoSuchMethodException e2) {
Log.e(IconCompat.TAG, "Unable to get icon package", e2);
return null;
} catch (InvocationTargetException e3) {
Log.e(IconCompat.TAG, "Unable to get icon package", e3);
return null;
}
}
public static IconCompat createFromIconInner(@NonNull Object obj) {
Preconditions.checkNotNull(obj);
int type = getType(obj);
if (type == 2) {
return IconCompat.createWithResource(null, getResPackage(obj), getResId(obj));
}
if (type == 4) {
return IconCompat.createWithContentUri(getUri(obj));
}
if (type == 6) {
return IconCompat.createWithAdaptiveBitmapContentUri(getUri(obj));
}
IconCompat iconCompat = new IconCompat(-1);
iconCompat.mObj1 = obj;
return iconCompat;
}
@DrawableRes
@IdRes
public static int getResId(@NonNull Object obj) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getResId(obj);
}
try {
return ((Integer) obj.getClass().getMethod("getResId", new Class[0]).invoke(obj, new Object[0])).intValue();
} catch (IllegalAccessException e) {
Log.e(IconCompat.TAG, "Unable to get icon resource", e);
return 0;
} catch (NoSuchMethodException e2) {
Log.e(IconCompat.TAG, "Unable to get icon resource", e2);
return 0;
} catch (InvocationTargetException e3) {
Log.e(IconCompat.TAG, "Unable to get icon resource", e3);
return 0;
}
}
@Nullable
public static Uri getUri(@NonNull Object obj) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getUri(obj);
}
try {
return (Uri) obj.getClass().getMethod("getUri", new Class[0]).invoke(obj, new Object[0]);
} catch (IllegalAccessException e) {
Log.e(IconCompat.TAG, "Unable to get icon uri", e);
return null;
} catch (NoSuchMethodException e2) {
Log.e(IconCompat.TAG, "Unable to get icon uri", e2);
return null;
} catch (InvocationTargetException e3) {
Log.e(IconCompat.TAG, "Unable to get icon uri", e3);
return null;
}
}
public static Icon toIcon(IconCompat iconCompat, Context context) {
Icon createWithBitmap;
switch (iconCompat.mType) {
case -1:
return (Icon) iconCompat.mObj1;
case 0:
default:
throw new IllegalArgumentException("Unknown type");
case 1:
createWithBitmap = Icon.createWithBitmap((Bitmap) iconCompat.mObj1);
break;
case 2:
createWithBitmap = Icon.createWithResource(iconCompat.getResPackage(), iconCompat.mInt1);
break;
case 3:
createWithBitmap = Icon.createWithData((byte[]) iconCompat.mObj1, iconCompat.mInt1, iconCompat.mInt2);
break;
case 4:
createWithBitmap = Icon.createWithContentUri((String) iconCompat.mObj1);
break;
case 5:
createWithBitmap = Api26Impl.createWithAdaptiveBitmap((Bitmap) iconCompat.mObj1);
break;
case 6:
if (Build.VERSION.SDK_INT >= 30) {
createWithBitmap = Api30Impl.createWithAdaptiveBitmapContentUri(iconCompat.getUri());
break;
} else {
if (context == null) {
throw new IllegalArgumentException("Context is required to resolve the file uri of the icon: " + iconCompat.getUri());
}
InputStream uriInputStream = iconCompat.getUriInputStream(context);
if (uriInputStream == null) {
throw new IllegalStateException("Cannot load adaptive icon from uri: " + iconCompat.getUri());
}
createWithBitmap = Api26Impl.createWithAdaptiveBitmap(BitmapFactory.decodeStream(uriInputStream));
break;
}
}
ColorStateList colorStateList = iconCompat.mTintList;
if (colorStateList != null) {
createWithBitmap.setTintList(colorStateList);
}
PorterDuff.Mode mode = iconCompat.mTintMode;
if (mode != IconCompat.DEFAULT_TINT_MODE) {
createWithBitmap.setTintMode(mode);
}
return createWithBitmap;
}
public static Drawable loadDrawable(Icon icon, Context context) {
return icon.loadDrawable(context);
}
}
}

View File

@@ -0,0 +1,61 @@
package androidx.core.graphics.drawable;
import android.content.res.ColorStateList;
import android.os.Parcelable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcel;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class IconCompatParcelizer {
public static IconCompat read(VersionedParcel versionedParcel) {
IconCompat iconCompat = new IconCompat();
iconCompat.mType = versionedParcel.readInt(iconCompat.mType, 1);
iconCompat.mData = versionedParcel.readByteArray(iconCompat.mData, 2);
iconCompat.mParcelable = versionedParcel.readParcelable(iconCompat.mParcelable, 3);
iconCompat.mInt1 = versionedParcel.readInt(iconCompat.mInt1, 4);
iconCompat.mInt2 = versionedParcel.readInt(iconCompat.mInt2, 5);
iconCompat.mTintList = (ColorStateList) versionedParcel.readParcelable(iconCompat.mTintList, 6);
iconCompat.mTintModeStr = versionedParcel.readString(iconCompat.mTintModeStr, 7);
iconCompat.mString1 = versionedParcel.readString(iconCompat.mString1, 8);
iconCompat.onPostParceling();
return iconCompat;
}
public static void write(IconCompat iconCompat, VersionedParcel versionedParcel) {
versionedParcel.setSerializationFlags(true, true);
iconCompat.onPreParceling(versionedParcel.isStream());
int i = iconCompat.mType;
if (-1 != i) {
versionedParcel.writeInt(i, 1);
}
byte[] bArr = iconCompat.mData;
if (bArr != null) {
versionedParcel.writeByteArray(bArr, 2);
}
Parcelable parcelable = iconCompat.mParcelable;
if (parcelable != null) {
versionedParcel.writeParcelable(parcelable, 3);
}
int i2 = iconCompat.mInt1;
if (i2 != 0) {
versionedParcel.writeInt(i2, 4);
}
int i3 = iconCompat.mInt2;
if (i3 != 0) {
versionedParcel.writeInt(i3, 5);
}
ColorStateList colorStateList = iconCompat.mTintList;
if (colorStateList != null) {
versionedParcel.writeParcelable(colorStateList, 6);
}
String str = iconCompat.mTintModeStr;
if (str != null) {
versionedParcel.writeString(str, 7);
}
String str2 = iconCompat.mString1;
if (str2 != null) {
versionedParcel.writeString(str2, 8);
}
}
}

View File

@@ -0,0 +1,31 @@
package androidx.core.graphics.drawable;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.net.Uri;
import androidx.annotation.RequiresApi;
@SuppressLint({"ClassVerificationFailure"})
/* loaded from: classes.dex */
public final class IconKt {
@RequiresApi(26)
public static final Icon toAdaptiveIcon(Bitmap bitmap) {
return Icon.createWithAdaptiveBitmap(bitmap);
}
@RequiresApi(26)
public static final Icon toIcon(Bitmap bitmap) {
return Icon.createWithBitmap(bitmap);
}
@RequiresApi(26)
public static final Icon toIcon(Uri uri) {
return Icon.createWithContentUri(uri);
}
@RequiresApi(26)
public static final Icon toIcon(byte[] bArr) {
return Icon.createWithData(bArr, 0, bArr.length);
}
}

View File

@@ -0,0 +1,263 @@
package androidx.core.graphics.drawable;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
public abstract class RoundedBitmapDrawable extends Drawable {
private static final int DEFAULT_PAINT_FLAGS = 3;
final Bitmap mBitmap;
private int mBitmapHeight;
private final BitmapShader mBitmapShader;
private int mBitmapWidth;
private float mCornerRadius;
private boolean mIsCircular;
private int mTargetDensity;
private int mGravity = 119;
private final Paint mPaint = new Paint(3);
private final Matrix mShaderMatrix = new Matrix();
final Rect mDstRect = new Rect();
private final RectF mDstRectF = new RectF();
private boolean mApplyGravity = true;
private static boolean isGreaterThanZero(float f) {
return f > 0.05f;
}
@Nullable
public final Bitmap getBitmap() {
return this.mBitmap;
}
public float getCornerRadius() {
return this.mCornerRadius;
}
public int getGravity() {
return this.mGravity;
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
return this.mBitmapHeight;
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
return this.mBitmapWidth;
}
@NonNull
public final Paint getPaint() {
return this.mPaint;
}
public boolean isCircular() {
return this.mIsCircular;
}
private void computeBitmapSize() {
this.mBitmapWidth = this.mBitmap.getScaledWidth(this.mTargetDensity);
this.mBitmapHeight = this.mBitmap.getScaledHeight(this.mTargetDensity);
}
public void setTargetDensity(@NonNull Canvas canvas) {
setTargetDensity(canvas.getDensity());
}
public void setTargetDensity(@NonNull DisplayMetrics displayMetrics) {
setTargetDensity(displayMetrics.densityDpi);
}
public void setTargetDensity(int i) {
if (this.mTargetDensity != i) {
if (i == 0) {
i = 160;
}
this.mTargetDensity = i;
if (this.mBitmap != null) {
computeBitmapSize();
}
invalidateSelf();
}
}
public void setGravity(int i) {
if (this.mGravity != i) {
this.mGravity = i;
this.mApplyGravity = true;
invalidateSelf();
}
}
public void setMipMap(boolean z) {
throw new UnsupportedOperationException();
}
public boolean hasMipMap() {
throw new UnsupportedOperationException();
}
public void setAntiAlias(boolean z) {
this.mPaint.setAntiAlias(z);
invalidateSelf();
}
public boolean hasAntiAlias() {
return this.mPaint.isAntiAlias();
}
@Override // android.graphics.drawable.Drawable
public void setFilterBitmap(boolean z) {
this.mPaint.setFilterBitmap(z);
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable
public void setDither(boolean z) {
this.mPaint.setDither(z);
invalidateSelf();
}
public void gravityCompatApply(int i, int i2, int i3, Rect rect, Rect rect2) {
throw new UnsupportedOperationException();
}
public void updateDstRect() {
if (this.mApplyGravity) {
if (this.mIsCircular) {
int min = Math.min(this.mBitmapWidth, this.mBitmapHeight);
gravityCompatApply(this.mGravity, min, min, getBounds(), this.mDstRect);
int min2 = Math.min(this.mDstRect.width(), this.mDstRect.height());
this.mDstRect.inset(Math.max(0, (this.mDstRect.width() - min2) / 2), Math.max(0, (this.mDstRect.height() - min2) / 2));
this.mCornerRadius = min2 * 0.5f;
} else {
gravityCompatApply(this.mGravity, this.mBitmapWidth, this.mBitmapHeight, getBounds(), this.mDstRect);
}
this.mDstRectF.set(this.mDstRect);
if (this.mBitmapShader != null) {
Matrix matrix = this.mShaderMatrix;
RectF rectF = this.mDstRectF;
matrix.setTranslate(rectF.left, rectF.top);
this.mShaderMatrix.preScale(this.mDstRectF.width() / this.mBitmap.getWidth(), this.mDstRectF.height() / this.mBitmap.getHeight());
this.mBitmapShader.setLocalMatrix(this.mShaderMatrix);
this.mPaint.setShader(this.mBitmapShader);
}
this.mApplyGravity = false;
}
}
@Override // android.graphics.drawable.Drawable
public void draw(@NonNull Canvas canvas) {
Bitmap bitmap = this.mBitmap;
if (bitmap == null) {
return;
}
updateDstRect();
if (this.mPaint.getShader() == null) {
canvas.drawBitmap(bitmap, (Rect) null, this.mDstRect, this.mPaint);
return;
}
RectF rectF = this.mDstRectF;
float f = this.mCornerRadius;
canvas.drawRoundRect(rectF, f, f, this.mPaint);
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
if (i != this.mPaint.getAlpha()) {
this.mPaint.setAlpha(i);
invalidateSelf();
}
}
@Override // android.graphics.drawable.Drawable
public int getAlpha() {
return this.mPaint.getAlpha();
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
this.mPaint.setColorFilter(colorFilter);
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable
public ColorFilter getColorFilter() {
return this.mPaint.getColorFilter();
}
public void setCircular(boolean z) {
this.mIsCircular = z;
this.mApplyGravity = true;
if (z) {
updateCircularCornerRadius();
this.mPaint.setShader(this.mBitmapShader);
invalidateSelf();
return;
}
setCornerRadius(0.0f);
}
private void updateCircularCornerRadius() {
this.mCornerRadius = Math.min(this.mBitmapHeight, this.mBitmapWidth) / 2;
}
public void setCornerRadius(float f) {
if (this.mCornerRadius == f) {
return;
}
this.mIsCircular = false;
if (isGreaterThanZero(f)) {
this.mPaint.setShader(this.mBitmapShader);
} else {
this.mPaint.setShader(null);
}
this.mCornerRadius = f;
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable
public void onBoundsChange(@NonNull Rect rect) {
super.onBoundsChange(rect);
if (this.mIsCircular) {
updateCircularCornerRadius();
}
this.mApplyGravity = true;
}
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
Bitmap bitmap;
return (this.mGravity != 119 || this.mIsCircular || (bitmap = this.mBitmap) == null || bitmap.hasAlpha() || this.mPaint.getAlpha() < 255 || isGreaterThanZero(this.mCornerRadius)) ? -3 : -1;
}
public RoundedBitmapDrawable(Resources resources, Bitmap bitmap) {
this.mTargetDensity = 160;
if (resources != null) {
this.mTargetDensity = resources.getDisplayMetrics().densityDpi;
}
this.mBitmap = bitmap;
if (bitmap != null) {
computeBitmapSize();
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
this.mBitmapShader = new BitmapShader(bitmap, tileMode, tileMode);
} else {
this.mBitmapHeight = -1;
this.mBitmapWidth = -1;
this.mBitmapShader = null;
}
}
}

View File

@@ -0,0 +1,43 @@
package androidx.core.graphics.drawable;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Outline;
import android.graphics.Rect;
import android.view.Gravity;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
@RequiresApi(21)
/* loaded from: classes.dex */
class RoundedBitmapDrawable21 extends RoundedBitmapDrawable {
public RoundedBitmapDrawable21(Resources resources, Bitmap bitmap) {
super(resources, bitmap);
}
@Override // android.graphics.drawable.Drawable
public void getOutline(@NonNull Outline outline) {
updateDstRect();
outline.setRoundRect(this.mDstRect, getCornerRadius());
}
@Override // androidx.core.graphics.drawable.RoundedBitmapDrawable
public void setMipMap(boolean z) {
Bitmap bitmap = this.mBitmap;
if (bitmap != null) {
bitmap.setHasMipMap(z);
invalidateSelf();
}
}
@Override // androidx.core.graphics.drawable.RoundedBitmapDrawable
public boolean hasMipMap() {
Bitmap bitmap = this.mBitmap;
return bitmap != null && bitmap.hasMipMap();
}
@Override // androidx.core.graphics.drawable.RoundedBitmapDrawable
public void gravityCompatApply(int i, int i2, int i3, Rect rect, Rect rect2) {
Gravity.apply(i, i2, i3, rect, rect2, 0);
}
}

View File

@@ -0,0 +1,69 @@
package androidx.core.graphics.drawable;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.BitmapCompat;
import androidx.core.view.GravityCompat;
import java.io.InputStream;
/* loaded from: classes.dex */
public final class RoundedBitmapDrawableFactory {
private static final String TAG = "RoundedBitmapDrawableFa";
public static class DefaultRoundedBitmapDrawable extends RoundedBitmapDrawable {
public DefaultRoundedBitmapDrawable(Resources resources, Bitmap bitmap) {
super(resources, bitmap);
}
@Override // androidx.core.graphics.drawable.RoundedBitmapDrawable
public void setMipMap(boolean z) {
Bitmap bitmap = this.mBitmap;
if (bitmap != null) {
BitmapCompat.setHasMipMap(bitmap, z);
invalidateSelf();
}
}
@Override // androidx.core.graphics.drawable.RoundedBitmapDrawable
public boolean hasMipMap() {
Bitmap bitmap = this.mBitmap;
return bitmap != null && BitmapCompat.hasMipMap(bitmap);
}
@Override // androidx.core.graphics.drawable.RoundedBitmapDrawable
public void gravityCompatApply(int i, int i2, int i3, Rect rect, Rect rect2) {
GravityCompat.apply(i, i2, i3, rect, rect2, 0);
}
}
@NonNull
public static RoundedBitmapDrawable create(@NonNull Resources resources, @Nullable Bitmap bitmap) {
return new RoundedBitmapDrawable21(resources, bitmap);
}
@NonNull
public static RoundedBitmapDrawable create(@NonNull Resources resources, @NonNull String str) {
RoundedBitmapDrawable create = create(resources, BitmapFactory.decodeFile(str));
if (create.getBitmap() == null) {
Log.w(TAG, "RoundedBitmapDrawable cannot decode " + str);
}
return create;
}
@NonNull
public static RoundedBitmapDrawable create(@NonNull Resources resources, @NonNull InputStream inputStream) {
RoundedBitmapDrawable create = create(resources, BitmapFactory.decodeStream(inputStream));
if (create.getBitmap() == null) {
Log.w(TAG, "RoundedBitmapDrawable cannot decode " + inputStream);
}
return create;
}
private RoundedBitmapDrawableFactory() {
}
}

View File

@@ -0,0 +1,16 @@
package androidx.core.graphics.drawable;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import androidx.annotation.ColorInt;
import androidx.annotation.RestrictTo;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
/* loaded from: classes.dex */
public interface TintAwareDrawable {
void setTint(@ColorInt int i);
void setTintList(ColorStateList colorStateList);
void setTintMode(PorterDuff.Mode mode);
}

View File

@@ -0,0 +1,12 @@
package androidx.core.graphics.drawable;
import android.graphics.drawable.Drawable;
import androidx.annotation.RestrictTo;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
/* loaded from: classes.dex */
public interface WrappedDrawable {
Drawable getWrappedDrawable();
void setWrappedDrawable(Drawable drawable);
}

View File

@@ -0,0 +1,304 @@
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;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
/* loaded from: classes.dex */
class WrappedDrawableApi14 extends Drawable implements Drawable.Callback, WrappedDrawable, TintAwareDrawable {
static final PorterDuff.Mode DEFAULT_TINT_MODE = PorterDuff.Mode.SRC_IN;
private boolean mColorFilterSet;
private int mCurrentColor;
private PorterDuff.Mode mCurrentMode;
Drawable mDrawable;
private boolean mMutated;
WrappedDrawableState mState;
@Override // androidx.core.graphics.drawable.WrappedDrawable
public final Drawable getWrappedDrawable() {
return this.mDrawable;
}
public boolean isCompatTintEnabled() {
return true;
}
public WrappedDrawableApi14(@NonNull WrappedDrawableState wrappedDrawableState, @Nullable Resources resources) {
this.mState = wrappedDrawableState;
updateLocalState(resources);
}
public WrappedDrawableApi14(@Nullable Drawable drawable) {
this.mState = mutateConstantState();
setWrappedDrawable(drawable);
}
private void updateLocalState(@Nullable Resources resources) {
Drawable.ConstantState constantState;
WrappedDrawableState wrappedDrawableState = this.mState;
if (wrappedDrawableState == null || (constantState = wrappedDrawableState.mDrawableState) == null) {
return;
}
setWrappedDrawable(constantState.newDrawable(resources));
}
@Override // android.graphics.drawable.Drawable
public void jumpToCurrentState() {
this.mDrawable.jumpToCurrentState();
}
@Override // android.graphics.drawable.Drawable
public void draw(@NonNull Canvas canvas) {
this.mDrawable.draw(canvas);
}
@Override // android.graphics.drawable.Drawable
public void onBoundsChange(Rect rect) {
Drawable drawable = this.mDrawable;
if (drawable != null) {
drawable.setBounds(rect);
}
}
@Override // android.graphics.drawable.Drawable
public void setChangingConfigurations(int i) {
this.mDrawable.setChangingConfigurations(i);
}
@Override // android.graphics.drawable.Drawable
public int getChangingConfigurations() {
int changingConfigurations = super.getChangingConfigurations();
WrappedDrawableState wrappedDrawableState = this.mState;
return changingConfigurations | (wrappedDrawableState != null ? wrappedDrawableState.getChangingConfigurations() : 0) | this.mDrawable.getChangingConfigurations();
}
@Override // android.graphics.drawable.Drawable
public void setDither(boolean z) {
this.mDrawable.setDither(z);
}
@Override // android.graphics.drawable.Drawable
public void setFilterBitmap(boolean z) {
this.mDrawable.setFilterBitmap(z);
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
this.mDrawable.setAlpha(i);
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
this.mDrawable.setColorFilter(colorFilter);
}
@Override // android.graphics.drawable.Drawable
public boolean isStateful() {
WrappedDrawableState wrappedDrawableState;
ColorStateList colorStateList = (!isCompatTintEnabled() || (wrappedDrawableState = this.mState) == null) ? null : wrappedDrawableState.mTint;
return (colorStateList != null && colorStateList.isStateful()) || this.mDrawable.isStateful();
}
@Override // android.graphics.drawable.Drawable
public boolean setState(@NonNull int[] iArr) {
return updateTint(iArr) || this.mDrawable.setState(iArr);
}
@Override // android.graphics.drawable.Drawable
@NonNull
public int[] getState() {
return this.mDrawable.getState();
}
@Override // android.graphics.drawable.Drawable
@NonNull
public Drawable getCurrent() {
return this.mDrawable.getCurrent();
}
@Override // android.graphics.drawable.Drawable
public boolean setVisible(boolean z, boolean z2) {
return super.setVisible(z, z2) || this.mDrawable.setVisible(z, z2);
}
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
return this.mDrawable.getOpacity();
}
@Override // android.graphics.drawable.Drawable
public Region getTransparentRegion() {
return this.mDrawable.getTransparentRegion();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
return this.mDrawable.getIntrinsicWidth();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
return this.mDrawable.getIntrinsicHeight();
}
@Override // android.graphics.drawable.Drawable
public int getMinimumWidth() {
return this.mDrawable.getMinimumWidth();
}
@Override // android.graphics.drawable.Drawable
public int getMinimumHeight() {
return this.mDrawable.getMinimumHeight();
}
@Override // android.graphics.drawable.Drawable
public boolean getPadding(@NonNull Rect rect) {
return this.mDrawable.getPadding(rect);
}
@Override // android.graphics.drawable.Drawable
public void setAutoMirrored(boolean z) {
DrawableCompat.setAutoMirrored(this.mDrawable, z);
}
@Override // android.graphics.drawable.Drawable
public boolean isAutoMirrored() {
return DrawableCompat.isAutoMirrored(this.mDrawable);
}
@Override // android.graphics.drawable.Drawable
@RequiresApi(23)
public boolean onLayoutDirectionChanged(int i) {
return DrawableCompat.setLayoutDirection(this.mDrawable, i);
}
@Override // android.graphics.drawable.Drawable
@RequiresApi(23)
public int getLayoutDirection() {
return DrawableCompat.getLayoutDirection(this.mDrawable);
}
@Override // android.graphics.drawable.Drawable
@Nullable
public Drawable.ConstantState getConstantState() {
WrappedDrawableState wrappedDrawableState = this.mState;
if (wrappedDrawableState == null || !wrappedDrawableState.canConstantState()) {
return null;
}
this.mState.mChangingConfigurations = getChangingConfigurations();
return this.mState;
}
@Override // android.graphics.drawable.Drawable
@NonNull
public Drawable mutate() {
if (!this.mMutated && super.mutate() == this) {
this.mState = mutateConstantState();
Drawable drawable = this.mDrawable;
if (drawable != null) {
drawable.mutate();
}
WrappedDrawableState wrappedDrawableState = this.mState;
if (wrappedDrawableState != null) {
Drawable drawable2 = this.mDrawable;
wrappedDrawableState.mDrawableState = drawable2 != null ? drawable2.getConstantState() : null;
}
this.mMutated = true;
}
return this;
}
@NonNull
private WrappedDrawableState mutateConstantState() {
return new WrappedDrawableState(this.mState);
}
@Override // android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(@NonNull Drawable drawable) {
invalidateSelf();
}
@Override // android.graphics.drawable.Drawable.Callback
public void scheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable, long j) {
scheduleSelf(runnable, j);
}
@Override // android.graphics.drawable.Drawable.Callback
public void unscheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable) {
unscheduleSelf(runnable);
}
@Override // android.graphics.drawable.Drawable
public boolean onLevelChange(int i) {
return this.mDrawable.setLevel(i);
}
@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.mState.mTint = colorStateList;
updateTint(getState());
}
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
public void setTintMode(@NonNull PorterDuff.Mode mode) {
this.mState.mTintMode = mode;
updateTint(getState());
}
private boolean updateTint(int[] iArr) {
if (!isCompatTintEnabled()) {
return false;
}
WrappedDrawableState wrappedDrawableState = this.mState;
ColorStateList colorStateList = wrappedDrawableState.mTint;
PorterDuff.Mode mode = wrappedDrawableState.mTintMode;
if (colorStateList != null && mode != null) {
int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
if (!this.mColorFilterSet || colorForState != this.mCurrentColor || mode != this.mCurrentMode) {
setColorFilter(colorForState, mode);
this.mCurrentColor = colorForState;
this.mCurrentMode = mode;
this.mColorFilterSet = true;
return true;
}
} else {
this.mColorFilterSet = false;
clearColorFilter();
}
return false;
}
@Override // androidx.core.graphics.drawable.WrappedDrawable
public final void setWrappedDrawable(Drawable drawable) {
Drawable drawable2 = this.mDrawable;
if (drawable2 != null) {
drawable2.setCallback(null);
}
this.mDrawable = drawable;
if (drawable != null) {
drawable.setCallback(this);
setVisible(drawable.isVisible(), true);
setState(drawable.getState());
setLevel(drawable.getLevel());
setBounds(drawable.getBounds());
WrappedDrawableState wrappedDrawableState = this.mState;
if (wrappedDrawableState != null) {
wrappedDrawableState.mDrawableState = drawable.getConstantState();
}
}
invalidateSelf();
}
}

View File

@@ -0,0 +1,115 @@
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.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import java.lang.reflect.Method;
@RequiresApi(21)
/* loaded from: classes.dex */
class WrappedDrawableApi21 extends WrappedDrawableApi14 {
private static final String TAG = "WrappedDrawableApi21";
private static Method sIsProjectedDrawableMethod;
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14
public boolean isCompatTintEnabled() {
return false;
}
public WrappedDrawableApi21(Drawable drawable) {
super(drawable);
findAndCacheIsProjectedDrawableMethod();
}
public WrappedDrawableApi21(WrappedDrawableState wrappedDrawableState, Resources resources) {
super(wrappedDrawableState, resources);
findAndCacheIsProjectedDrawableMethod();
}
@Override // android.graphics.drawable.Drawable
public void setHotspot(float f, float f2) {
this.mDrawable.setHotspot(f, f2);
}
@Override // android.graphics.drawable.Drawable
public void setHotspotBounds(int i, int i2, int i3, int i4) {
this.mDrawable.setHotspotBounds(i, i2, i3, i4);
}
@Override // android.graphics.drawable.Drawable
public void getOutline(@NonNull Outline outline) {
this.mDrawable.getOutline(outline);
}
@Override // android.graphics.drawable.Drawable
@NonNull
public Rect getDirtyBounds() {
return this.mDrawable.getDirtyBounds();
}
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
public void setTintList(ColorStateList colorStateList) {
if (isCompatTintEnabled()) {
super.setTintList(colorStateList);
} else {
this.mDrawable.setTintList(colorStateList);
}
}
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
public void setTint(int i) {
if (isCompatTintEnabled()) {
super.setTint(i);
} else {
this.mDrawable.setTint(i);
}
}
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
public void setTintMode(@NonNull PorterDuff.Mode mode) {
if (isCompatTintEnabled()) {
super.setTintMode(mode);
} else {
this.mDrawable.setTintMode(mode);
}
}
@Override // androidx.core.graphics.drawable.WrappedDrawableApi14, android.graphics.drawable.Drawable
public boolean setState(@NonNull int[] iArr) {
if (!super.setState(iArr)) {
return false;
}
invalidateSelf();
return true;
}
@Override // android.graphics.drawable.Drawable
public boolean isProjected() {
Method method;
Drawable drawable = this.mDrawable;
if (drawable != null && (method = sIsProjectedDrawableMethod) != null) {
try {
return ((Boolean) method.invoke(drawable, new Object[0])).booleanValue();
} catch (Exception e) {
Log.w(TAG, "Error calling Drawable#isProjected() method", e);
}
}
return false;
}
private void findAndCacheIsProjectedDrawableMethod() {
if (sIsProjectedDrawableMethod == null) {
try {
sIsProjectedDrawableMethod = Drawable.class.getDeclaredMethod("isProjected", new Class[0]);
} catch (Exception e) {
Log.w(TAG, "Failed to retrieve Drawable#isProjected() method", e);
}
}
}
}

View File

@@ -0,0 +1,50 @@
package androidx.core.graphics.drawable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
final class WrappedDrawableState extends Drawable.ConstantState {
int mChangingConfigurations;
Drawable.ConstantState mDrawableState;
ColorStateList mTint;
PorterDuff.Mode mTintMode;
public boolean canConstantState() {
return this.mDrawableState != null;
}
public WrappedDrawableState(@Nullable WrappedDrawableState wrappedDrawableState) {
this.mTint = null;
this.mTintMode = WrappedDrawableApi14.DEFAULT_TINT_MODE;
if (wrappedDrawableState != null) {
this.mChangingConfigurations = wrappedDrawableState.mChangingConfigurations;
this.mDrawableState = wrappedDrawableState.mDrawableState;
this.mTint = wrappedDrawableState.mTint;
this.mTintMode = wrappedDrawableState.mTintMode;
}
}
@Override // android.graphics.drawable.Drawable.ConstantState
@NonNull
public Drawable newDrawable() {
return newDrawable(null);
}
@Override // android.graphics.drawable.Drawable.ConstantState
@NonNull
public Drawable newDrawable(@Nullable Resources resources) {
return new WrappedDrawableApi21(this, resources);
}
@Override // android.graphics.drawable.Drawable.ConstantState
public int getChangingConfigurations() {
int i = this.mChangingConfigurations;
Drawable.ConstantState constantState = this.mDrawableState;
return i | (constantState != null ? constantState.getChangingConfigurations() : 0);
}
}