apkfuckery/com.discord/smali/androidx/appcompat/widget/DrawableUtils.smali

560 lines
13 KiB
Smali
Raw Normal View History

2019-07-24 11:27:29 +00:00
.class public Landroidx/appcompat/widget/DrawableUtils;
.super Ljava/lang/Object;
.source "DrawableUtils.java"
2019-12-06 03:29:40 +00:00
# annotations
.annotation build Landroid/annotation/SuppressLint;
value = {
"RestrictedAPI"
}
.end annotation
.annotation build Landroidx/annotation/RestrictTo;
value = {
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP_PREFIX:Landroidx/annotation/RestrictTo$Scope;
}
.end annotation
2019-07-24 11:27:29 +00:00
# static fields
2019-12-06 03:29:40 +00:00
.field public static final CHECKED_STATE_SET:[I
2019-11-15 02:21:15 +00:00
2019-12-06 03:29:40 +00:00
.field public static final EMPTY_STATE_SET:[I
2019-11-15 02:21:15 +00:00
2019-07-24 11:27:29 +00:00
.field public static final INSETS_NONE:Landroid/graphics/Rect;
2019-12-06 03:29:40 +00:00
.field public static final TAG:Ljava/lang/String; = "DrawableUtils"
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
.field public static final VECTOR_DRAWABLE_CLAZZ_NAME:Ljava/lang/String; = "android.graphics.drawable.VectorDrawable"
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
.field public static sInsetsClazz:Ljava/lang/Class;
2019-07-24 11:27:29 +00:00
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/Class<",
"*>;"
}
.end annotation
.end field
# direct methods
2019-12-06 03:29:40 +00:00
.method public static constructor <clinit>()V
2019-11-15 02:21:15 +00:00
.locals 3
const/4 v0, 0x1
new-array v0, v0, [I
const/4 v1, 0x0
const v2, 0x10100a0
aput v2, v0, v1
sput-object v0, Landroidx/appcompat/widget/DrawableUtils;->CHECKED_STATE_SET:[I
new-array v0, v1, [I
sput-object v0, Landroidx/appcompat/widget/DrawableUtils;->EMPTY_STATE_SET:[I
2019-07-24 11:27:29 +00:00
new-instance v0, Landroid/graphics/Rect;
invoke-direct {v0}, Landroid/graphics/Rect;-><init>()V
sput-object v0, Landroidx/appcompat/widget/DrawableUtils;->INSETS_NONE:Landroid/graphics/Rect;
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const-string v0, "android.graphics.Insets"
2019-12-06 03:29:40 +00:00
:try_start_0
2019-07-24 11:27:29 +00:00
invoke-static {v0}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object v0
sput-object v0, Landroidx/appcompat/widget/DrawableUtils;->sInsetsClazz:Ljava/lang/Class;
:try_end_0
.catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
:catch_0
return-void
.end method
2019-12-06 03:29:40 +00:00
.method public constructor <init>()V
2019-07-24 11:27:29 +00:00
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
.locals 4
2019-12-06 03:29:40 +00:00
.param p0 # Landroid/graphics/drawable/Drawable;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
2019-07-24 11:27:29 +00:00
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
instance-of v0, p0, Landroid/graphics/drawable/DrawableContainer;
2019-12-06 03:29:40 +00:00
if-eqz v0, :cond_1
2019-07-24 11:27:29 +00:00
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getConstantState()Landroid/graphics/drawable/Drawable$ConstantState;
move-result-object p0
instance-of v0, p0, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;
2019-12-06 03:29:40 +00:00
if-eqz v0, :cond_4
2019-07-24 11:27:29 +00:00
check-cast p0, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;
invoke-virtual {p0}, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;->getChildren()[Landroid/graphics/drawable/Drawable;
move-result-object p0
array-length v0, p0
const/4 v1, 0x0
2019-12-06 03:29:40 +00:00
const/4 v2, 0x0
:goto_0
if-ge v2, v0, :cond_4
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
aget-object v3, p0, v2
2019-07-24 11:27:29 +00:00
invoke-static {v3}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
move-result v3
2019-12-06 03:29:40 +00:00
if-nez v3, :cond_0
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
return v1
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
:cond_0
add-int/lit8 v2, v2, 0x1
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
goto :goto_0
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
:cond_1
2019-07-24 11:27:29 +00:00
instance-of v0, p0, Landroidx/core/graphics/drawable/WrappedDrawable;
2019-12-06 03:29:40 +00:00
if-eqz v0, :cond_2
2019-07-24 11:27:29 +00:00
check-cast p0, Landroidx/core/graphics/drawable/WrappedDrawable;
invoke-interface {p0}, Landroidx/core/graphics/drawable/WrappedDrawable;->getWrappedDrawable()Landroid/graphics/drawable/Drawable;
move-result-object p0
2019-12-06 03:29:40 +00:00
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
move-result p0
return p0
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
:cond_2
2019-07-24 11:27:29 +00:00
instance-of v0, p0, Landroidx/appcompat/graphics/drawable/DrawableWrapper;
2019-12-06 03:29:40 +00:00
if-eqz v0, :cond_3
2019-07-24 11:27:29 +00:00
check-cast p0, Landroidx/appcompat/graphics/drawable/DrawableWrapper;
invoke-virtual {p0}, Landroidx/appcompat/graphics/drawable/DrawableWrapper;->getWrappedDrawable()Landroid/graphics/drawable/Drawable;
move-result-object p0
2019-12-06 03:29:40 +00:00
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
move-result p0
return p0
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
:cond_3
2019-07-24 11:27:29 +00:00
instance-of v0, p0, Landroid/graphics/drawable/ScaleDrawable;
2019-12-06 03:29:40 +00:00
if-eqz v0, :cond_4
2019-07-24 11:27:29 +00:00
check-cast p0, Landroid/graphics/drawable/ScaleDrawable;
invoke-virtual {p0}, Landroid/graphics/drawable/ScaleDrawable;->getDrawable()Landroid/graphics/drawable/Drawable;
move-result-object p0
2019-12-06 03:29:40 +00:00
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
2019-07-24 11:27:29 +00:00
2019-12-06 03:29:40 +00:00
move-result p0
return p0
:cond_4
2019-07-24 11:27:29 +00:00
const/4 p0, 0x1
return p0
.end method
2019-12-06 03:29:40 +00:00
.method public static fixDrawable(Landroid/graphics/drawable/Drawable;)V
2019-07-24 11:27:29 +00:00
.locals 2
2019-12-06 03:29:40 +00:00
.param p0 # Landroid/graphics/drawable/Drawable;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
2019-07-24 11:27:29 +00:00
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x15
if-ne v0, v1, :cond_0
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
move-result-object v0
const-string v1, "android.graphics.drawable.VectorDrawable"
invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_0
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->fixVectorDrawableTinting(Landroid/graphics/drawable/Drawable;)V
:cond_0
return-void
.end method
2019-12-06 03:29:40 +00:00
.method public static fixVectorDrawableTinting(Landroid/graphics/drawable/Drawable;)V
2019-07-24 11:27:29 +00:00
.locals 2
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getState()[I
move-result-object v0
if-eqz v0, :cond_1
array-length v1, v0
if-nez v1, :cond_0
goto :goto_0
:cond_0
2019-11-15 02:21:15 +00:00
sget-object v1, Landroidx/appcompat/widget/DrawableUtils;->EMPTY_STATE_SET:[I
2019-07-24 11:27:29 +00:00
invoke-virtual {p0, v1}, Landroid/graphics/drawable/Drawable;->setState([I)Z
goto :goto_1
:cond_1
:goto_0
2019-11-15 02:21:15 +00:00
sget-object v1, Landroidx/appcompat/widget/DrawableUtils;->CHECKED_STATE_SET:[I
2019-07-24 11:27:29 +00:00
invoke-virtual {p0, v1}, Landroid/graphics/drawable/Drawable;->setState([I)Z
:goto_1
invoke-virtual {p0, v0}, Landroid/graphics/drawable/Drawable;->setState([I)Z
return-void
.end method
.method public static getOpticalBounds(Landroid/graphics/drawable/Drawable;)Landroid/graphics/Rect;
.locals 12
2019-11-15 02:21:15 +00:00
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x1d
if-lt v0, v1, :cond_0
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets;
move-result-object p0
new-instance v0, Landroid/graphics/Rect;
invoke-direct {v0}, Landroid/graphics/Rect;-><init>()V
iget v1, p0, Landroid/graphics/Insets;->left:I
iput v1, v0, Landroid/graphics/Rect;->left:I
iget v1, p0, Landroid/graphics/Insets;->right:I
iput v1, v0, Landroid/graphics/Rect;->right:I
iget v1, p0, Landroid/graphics/Insets;->top:I
iput v1, v0, Landroid/graphics/Rect;->top:I
iget p0, p0, Landroid/graphics/Insets;->bottom:I
iput p0, v0, Landroid/graphics/Rect;->bottom:I
return-object v0
:cond_0
2019-07-24 11:27:29 +00:00
sget-object v0, Landroidx/appcompat/widget/DrawableUtils;->sInsetsClazz:Ljava/lang/Class;
2019-11-15 02:21:15 +00:00
if-eqz v0, :cond_7
2019-07-24 11:27:29 +00:00
:try_start_0
invoke-static {p0}, Landroidx/core/graphics/drawable/DrawableCompat;->unwrap(Landroid/graphics/drawable/Drawable;)Landroid/graphics/drawable/Drawable;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v0
const-string v1, "getOpticalInsets"
const/4 v2, 0x0
new-array v3, v2, [Ljava/lang/Class;
invoke-virtual {v0, v1, v3}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
move-result-object v0
new-array v1, v2, [Ljava/lang/Object;
invoke-virtual {v0, p0, v1}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
2019-11-15 02:21:15 +00:00
if-eqz p0, :cond_7
2019-07-24 11:27:29 +00:00
new-instance v0, Landroid/graphics/Rect;
invoke-direct {v0}, Landroid/graphics/Rect;-><init>()V
sget-object v1, Landroidx/appcompat/widget/DrawableUtils;->sInsetsClazz:Ljava/lang/Class;
invoke-virtual {v1}, Ljava/lang/Class;->getFields()[Ljava/lang/reflect/Field;
move-result-object v1
array-length v3, v1
const/4 v4, 0x0
:goto_0
2019-11-15 02:21:15 +00:00
if-ge v4, v3, :cond_6
2019-07-24 11:27:29 +00:00
aget-object v5, v1, v4
invoke-virtual {v5}, Ljava/lang/reflect/Field;->getName()Ljava/lang/String;
move-result-object v6
const/4 v7, -0x1
invoke-virtual {v6}, Ljava/lang/String;->hashCode()I
move-result v8
const/4 v9, 0x3
const/4 v10, 0x2
const/4 v11, 0x1
sparse-switch v8, :sswitch_data_0
goto :goto_1
:sswitch_0
const-string v8, "right"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
2019-11-15 02:21:15 +00:00
if-eqz v6, :cond_1
2019-07-24 11:27:29 +00:00
const/4 v7, 0x2
goto :goto_1
:sswitch_1
const-string v8, "left"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
2019-11-15 02:21:15 +00:00
if-eqz v6, :cond_1
2019-07-24 11:27:29 +00:00
const/4 v7, 0x0
goto :goto_1
:sswitch_2
const-string v8, "top"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
2019-11-15 02:21:15 +00:00
if-eqz v6, :cond_1
2019-07-24 11:27:29 +00:00
const/4 v7, 0x1
goto :goto_1
:sswitch_3
const-string v8, "bottom"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
2019-11-15 02:21:15 +00:00
if-eqz v6, :cond_1
2019-07-24 11:27:29 +00:00
const/4 v7, 0x3
2019-11-15 02:21:15 +00:00
:cond_1
2019-07-24 11:27:29 +00:00
:goto_1
2019-11-15 02:21:15 +00:00
if-eqz v7, :cond_5
2019-07-24 11:27:29 +00:00
2019-11-15 02:21:15 +00:00
if-eq v7, v11, :cond_4
2019-07-24 11:27:29 +00:00
2019-11-15 02:21:15 +00:00
if-eq v7, v10, :cond_3
2019-07-24 11:27:29 +00:00
2019-11-15 02:21:15 +00:00
if-eq v7, v9, :cond_2
2019-07-24 11:27:29 +00:00
goto :goto_2
2019-11-15 02:21:15 +00:00
:cond_2
2019-07-24 11:27:29 +00:00
invoke-virtual {v5, p0}, Ljava/lang/reflect/Field;->getInt(Ljava/lang/Object;)I
move-result v5
iput v5, v0, Landroid/graphics/Rect;->bottom:I
goto :goto_2
2019-11-15 02:21:15 +00:00
:cond_3
2019-07-24 11:27:29 +00:00
invoke-virtual {v5, p0}, Ljava/lang/reflect/Field;->getInt(Ljava/lang/Object;)I
move-result v5
iput v5, v0, Landroid/graphics/Rect;->right:I
goto :goto_2
2019-11-15 02:21:15 +00:00
:cond_4
2019-07-24 11:27:29 +00:00
invoke-virtual {v5, p0}, Ljava/lang/reflect/Field;->getInt(Ljava/lang/Object;)I
move-result v5
iput v5, v0, Landroid/graphics/Rect;->top:I
goto :goto_2
2019-11-15 02:21:15 +00:00
:cond_5
2019-07-24 11:27:29 +00:00
invoke-virtual {v5, p0}, Ljava/lang/reflect/Field;->getInt(Ljava/lang/Object;)I
move-result v5
iput v5, v0, Landroid/graphics/Rect;->left:I
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
:goto_2
add-int/lit8 v4, v4, 0x1
goto :goto_0
2019-11-15 02:21:15 +00:00
:cond_6
2019-07-24 11:27:29 +00:00
return-object v0
:catch_0
const-string p0, "DrawableUtils"
const-string v0, "Couldn\'t obtain the optical insets. Ignoring."
invoke-static {p0, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
2019-11-15 02:21:15 +00:00
:cond_7
2019-07-24 11:27:29 +00:00
sget-object p0, Landroidx/appcompat/widget/DrawableUtils;->INSETS_NONE:Landroid/graphics/Rect;
return-object p0
nop
:sswitch_data_0
.sparse-switch
-0x527265d5 -> :sswitch_3
0x1c155 -> :sswitch_2
0x32a007 -> :sswitch_1
0x677c21c -> :sswitch_0
.end sparse-switch
.end method
.method public static parseTintMode(ILandroid/graphics/PorterDuff$Mode;)Landroid/graphics/PorterDuff$Mode;
.locals 1
const/4 v0, 0x3
if-eq p0, v0, :cond_2
const/4 v0, 0x5
if-eq p0, v0, :cond_1
const/16 v0, 0x9
if-eq p0, v0, :cond_0
packed-switch p0, :pswitch_data_0
return-object p1
:pswitch_0
sget-object p0, Landroid/graphics/PorterDuff$Mode;->ADD:Landroid/graphics/PorterDuff$Mode;
return-object p0
:pswitch_1
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SCREEN:Landroid/graphics/PorterDuff$Mode;
return-object p0
:pswitch_2
sget-object p0, Landroid/graphics/PorterDuff$Mode;->MULTIPLY:Landroid/graphics/PorterDuff$Mode;
return-object p0
:cond_0
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SRC_ATOP:Landroid/graphics/PorterDuff$Mode;
return-object p0
:cond_1
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SRC_IN:Landroid/graphics/PorterDuff$Mode;
return-object p0
:cond_2
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SRC_OVER:Landroid/graphics/PorterDuff$Mode;
return-object p0
:pswitch_data_0
.packed-switch 0xe
:pswitch_2
:pswitch_1
:pswitch_0
.end packed-switch
.end method