513 lines
11 KiB
Smali
513 lines
11 KiB
Smali
.class public Landroidx/appcompat/widget/DrawableUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "DrawableUtils.java"
|
|
|
|
|
|
# static fields
|
|
.field public static final INSETS_NONE:Landroid/graphics/Rect;
|
|
|
|
.field private static final TAG:Ljava/lang/String; = "DrawableUtils"
|
|
|
|
.field private static final VECTOR_DRAWABLE_CLAZZ_NAME:Ljava/lang/String; = "android.graphics.drawable.VectorDrawable"
|
|
|
|
.field private static sInsetsClazz:Ljava/lang/Class;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/lang/Class<",
|
|
"*>;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# direct methods
|
|
.method static constructor <clinit>()V
|
|
.locals 2
|
|
|
|
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/16 v1, 0x12
|
|
|
|
if-lt v0, v1, :cond_0
|
|
|
|
:try_start_0
|
|
const-string v0, "android.graphics.Insets"
|
|
|
|
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
|
|
:cond_0
|
|
return-void
|
|
.end method
|
|
|
|
.method private constructor <init>()V
|
|
.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
|
|
|
|
:goto_0
|
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v1, 0xf
|
|
|
|
const/4 v2, 0x0
|
|
|
|
if-ge v0, v1, :cond_0
|
|
|
|
instance-of v0, p0, Landroid/graphics/drawable/InsetDrawable;
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
return v2
|
|
|
|
:cond_0
|
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
if-ge v0, v1, :cond_1
|
|
|
|
instance-of v0, p0, Landroid/graphics/drawable/GradientDrawable;
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
return v2
|
|
|
|
:cond_1
|
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v1, 0x11
|
|
|
|
if-ge v0, v1, :cond_2
|
|
|
|
instance-of v0, p0, Landroid/graphics/drawable/LayerDrawable;
|
|
|
|
if-eqz v0, :cond_2
|
|
|
|
return v2
|
|
|
|
:cond_2
|
|
instance-of v0, p0, Landroid/graphics/drawable/DrawableContainer;
|
|
|
|
if-eqz v0, :cond_4
|
|
|
|
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;
|
|
|
|
if-eqz v0, :cond_7
|
|
|
|
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
|
|
|
|
:goto_1
|
|
if-ge v1, v0, :cond_7
|
|
|
|
aget-object v3, p0, v1
|
|
|
|
invoke-static {v3}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
|
|
|
|
move-result v3
|
|
|
|
if-nez v3, :cond_3
|
|
|
|
return v2
|
|
|
|
:cond_3
|
|
add-int/lit8 v1, v1, 0x1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_4
|
|
instance-of v0, p0, Landroidx/core/graphics/drawable/WrappedDrawable;
|
|
|
|
if-eqz v0, :cond_5
|
|
|
|
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
|
|
|
|
goto :goto_0
|
|
|
|
:cond_5
|
|
instance-of v0, p0, Landroidx/appcompat/graphics/drawable/DrawableWrapper;
|
|
|
|
if-eqz v0, :cond_6
|
|
|
|
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
|
|
|
|
goto :goto_0
|
|
|
|
:cond_6
|
|
instance-of v0, p0, Landroid/graphics/drawable/ScaleDrawable;
|
|
|
|
if-eqz v0, :cond_7
|
|
|
|
check-cast p0, Landroid/graphics/drawable/ScaleDrawable;
|
|
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/ScaleDrawable;->getDrawable()Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_7
|
|
const/4 p0, 0x1
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method static fixDrawable(Landroid/graphics/drawable/Drawable;)V
|
|
.locals 2
|
|
|
|
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
|
|
|
|
.method private static fixVectorDrawableTinting(Landroid/graphics/drawable/Drawable;)V
|
|
.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
|
|
sget-object v1, Landroidx/appcompat/widget/ThemeUtils;->EMPTY_STATE_SET:[I
|
|
|
|
invoke-virtual {p0, v1}, Landroid/graphics/drawable/Drawable;->setState([I)Z
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
:goto_0
|
|
sget-object v1, Landroidx/appcompat/widget/ThemeUtils;->CHECKED_STATE_SET:[I
|
|
|
|
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
|
|
|
|
sget-object v0, Landroidx/appcompat/widget/DrawableUtils;->sInsetsClazz:Ljava/lang/Class;
|
|
|
|
if-eqz v0, :cond_6
|
|
|
|
: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
|
|
|
|
if-eqz p0, :cond_6
|
|
|
|
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
|
|
if-ge v4, v3, :cond_5
|
|
|
|
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
|
|
|
|
if-eqz v6, :cond_0
|
|
|
|
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
|
|
|
|
if-eqz v6, :cond_0
|
|
|
|
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
|
|
|
|
if-eqz v6, :cond_0
|
|
|
|
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
|
|
|
|
if-eqz v6, :cond_0
|
|
|
|
const/4 v7, 0x3
|
|
|
|
:cond_0
|
|
:goto_1
|
|
if-eqz v7, :cond_4
|
|
|
|
if-eq v7, v11, :cond_3
|
|
|
|
if-eq v7, v10, :cond_2
|
|
|
|
if-eq v7, v9, :cond_1
|
|
|
|
goto :goto_2
|
|
|
|
:cond_1
|
|
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
|
|
|
|
:cond_2
|
|
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
|
|
|
|
:cond_3
|
|
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
|
|
|
|
:cond_4
|
|
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
|
|
|
|
:cond_5
|
|
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
|
|
|
|
:cond_6
|
|
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
|