638 lines
14 KiB
Smali
638 lines
14 KiB
Smali
.class public Landroidx/appcompat/widget/DrawableUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "DrawableUtils.java"
|
|
|
|
|
|
# static fields
|
|
.field private static final CHECKED_STATE_SET:[I
|
|
|
|
.field private static final EMPTY_STATE_SET:[I
|
|
|
|
.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 3
|
|
|
|
const/4 v0, 0x1
|
|
|
|
new-array v0, v0, [I
|
|
|
|
const v1, 0x10100a0
|
|
|
|
const/4 v2, 0x0
|
|
|
|
aput v1, v0, v2
|
|
|
|
.line 45
|
|
sput-object v0, Landroidx/appcompat/widget/DrawableUtils;->CHECKED_STATE_SET:[I
|
|
|
|
new-array v0, v2, [I
|
|
|
|
.line 46
|
|
sput-object v0, Landroidx/appcompat/widget/DrawableUtils;->EMPTY_STATE_SET:[I
|
|
|
|
.line 50
|
|
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;
|
|
|
|
.line 57
|
|
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"
|
|
|
|
.line 59
|
|
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
|
|
|
|
.line 66
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
|
|
.locals 4
|
|
|
|
.line 142
|
|
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
|
|
|
|
.line 144
|
|
: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
|
|
|
|
.line 148
|
|
: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
|
|
|
|
.line 152
|
|
:cond_2
|
|
instance-of v0, p0, Landroid/graphics/drawable/DrawableContainer;
|
|
|
|
if-eqz v0, :cond_4
|
|
|
|
.line 154
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getConstantState()Landroid/graphics/drawable/Drawable$ConstantState;
|
|
|
|
move-result-object p0
|
|
|
|
.line 155
|
|
instance-of v0, p0, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;
|
|
|
|
if-eqz v0, :cond_7
|
|
|
|
.line 156
|
|
check-cast p0, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;
|
|
|
|
.line 158
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;->getChildren()[Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
array-length v0, p0
|
|
|
|
move v1, v2
|
|
|
|
:goto_0
|
|
if-ge v1, v0, :cond_7
|
|
|
|
aget-object v3, p0, v1
|
|
|
|
.line 159
|
|
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_0
|
|
|
|
.line 164
|
|
:cond_4
|
|
instance-of v0, p0, Landroidx/core/graphics/drawable/WrappedDrawable;
|
|
|
|
if-eqz v0, :cond_5
|
|
|
|
.line 165
|
|
check-cast p0, Landroidx/core/graphics/drawable/WrappedDrawable;
|
|
|
|
.line 167
|
|
invoke-interface {p0}, Landroidx/core/graphics/drawable/WrappedDrawable;->getWrappedDrawable()Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
.line 165
|
|
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
|
|
.line 168
|
|
:cond_5
|
|
instance-of v0, p0, Landroidx/appcompat/graphics/drawable/DrawableWrapper;
|
|
|
|
if-eqz v0, :cond_6
|
|
|
|
.line 169
|
|
check-cast p0, Landroidx/appcompat/graphics/drawable/DrawableWrapper;
|
|
|
|
.line 171
|
|
invoke-virtual {p0}, Landroidx/appcompat/graphics/drawable/DrawableWrapper;->getWrappedDrawable()Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
.line 169
|
|
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
|
|
.line 172
|
|
:cond_6
|
|
instance-of v0, p0, Landroid/graphics/drawable/ScaleDrawable;
|
|
|
|
if-eqz v0, :cond_7
|
|
|
|
.line 173
|
|
check-cast p0, Landroid/graphics/drawable/ScaleDrawable;
|
|
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/ScaleDrawable;->getDrawable()Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
|
|
:cond_7
|
|
const/4 p0, 0x1
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method static fixDrawable(Landroid/graphics/drawable/Drawable;)V
|
|
.locals 2
|
|
|
|
.line 131
|
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v1, 0x15
|
|
|
|
if-ne v0, v1, :cond_0
|
|
|
|
.line 132
|
|
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
|
|
|
|
.line 133
|
|
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
|
|
|
|
.line 184
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getState()[I
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
.line 185
|
|
array-length v1, v0
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
.line 190
|
|
:cond_0
|
|
sget-object v1, Landroidx/appcompat/widget/DrawableUtils;->EMPTY_STATE_SET:[I
|
|
|
|
invoke-virtual {p0, v1}, Landroid/graphics/drawable/Drawable;->setState([I)Z
|
|
|
|
goto :goto_1
|
|
|
|
.line 187
|
|
:cond_1
|
|
:goto_0
|
|
sget-object v1, Landroidx/appcompat/widget/DrawableUtils;->CHECKED_STATE_SET:[I
|
|
|
|
invoke-virtual {p0, v1}, Landroid/graphics/drawable/Drawable;->setState([I)Z
|
|
|
|
.line 193
|
|
: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
|
|
|
|
.line 73
|
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v1, 0x1d
|
|
|
|
if-lt v0, v1, :cond_0
|
|
|
|
.line 74
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets;
|
|
|
|
move-result-object p0
|
|
|
|
.line 75
|
|
new-instance v0, Landroid/graphics/Rect;
|
|
|
|
invoke-direct {v0}, Landroid/graphics/Rect;-><init>()V
|
|
|
|
.line 76
|
|
iget v1, p0, Landroid/graphics/Insets;->left:I
|
|
|
|
iput v1, v0, Landroid/graphics/Rect;->left:I
|
|
|
|
.line 77
|
|
iget v1, p0, Landroid/graphics/Insets;->right:I
|
|
|
|
iput v1, v0, Landroid/graphics/Rect;->right:I
|
|
|
|
.line 78
|
|
iget v1, p0, Landroid/graphics/Insets;->top:I
|
|
|
|
iput v1, v0, Landroid/graphics/Rect;->top:I
|
|
|
|
.line 79
|
|
iget p0, p0, Landroid/graphics/Insets;->bottom:I
|
|
|
|
iput p0, v0, Landroid/graphics/Rect;->bottom:I
|
|
|
|
return-object v0
|
|
|
|
.line 82
|
|
:cond_0
|
|
sget-object v0, Landroidx/appcompat/widget/DrawableUtils;->sInsetsClazz:Ljava/lang/Class;
|
|
|
|
if-eqz v0, :cond_7
|
|
|
|
.line 86
|
|
:try_start_0
|
|
invoke-static {p0}, Landroidx/core/graphics/drawable/DrawableCompat;->unwrap(Landroid/graphics/drawable/Drawable;)Landroid/graphics/drawable/Drawable;
|
|
|
|
move-result-object p0
|
|
|
|
.line 88
|
|
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;
|
|
|
|
.line 89
|
|
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;
|
|
|
|
.line 90
|
|
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_7
|
|
|
|
.line 94
|
|
new-instance v0, Landroid/graphics/Rect;
|
|
|
|
invoke-direct {v0}, Landroid/graphics/Rect;-><init>()V
|
|
|
|
.line 96
|
|
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
|
|
|
|
move v4, v2
|
|
|
|
:goto_0
|
|
if-ge v4, v3, :cond_6
|
|
|
|
aget-object v5, v1, v4
|
|
|
|
.line 97
|
|
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_1
|
|
|
|
move v7, v10
|
|
|
|
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_1
|
|
|
|
move v7, v2
|
|
|
|
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_1
|
|
|
|
move v7, v11
|
|
|
|
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_1
|
|
|
|
move v7, v9
|
|
|
|
:cond_1
|
|
:goto_1
|
|
if-eqz v7, :cond_5
|
|
|
|
if-eq v7, v11, :cond_4
|
|
|
|
if-eq v7, v10, :cond_3
|
|
|
|
if-eq v7, v9, :cond_2
|
|
|
|
goto :goto_2
|
|
|
|
.line 108
|
|
:cond_2
|
|
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
|
|
|
|
.line 105
|
|
:cond_3
|
|
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
|
|
|
|
.line 102
|
|
:cond_4
|
|
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
|
|
|
|
.line 99
|
|
:cond_5
|
|
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_6
|
|
return-object v0
|
|
|
|
:catch_0
|
|
const-string p0, "DrawableUtils"
|
|
|
|
const-string v0, "Couldn\'t obtain the optical insets. Ignoring."
|
|
|
|
.line 116
|
|
invoke-static {p0, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
|
|
|
|
.line 122
|
|
:cond_7
|
|
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
|
|
|
|
.line 206
|
|
:pswitch_0
|
|
sget-object p0, Landroid/graphics/PorterDuff$Mode;->ADD:Landroid/graphics/PorterDuff$Mode;
|
|
|
|
return-object p0
|
|
|
|
.line 205
|
|
:pswitch_1
|
|
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SCREEN:Landroid/graphics/PorterDuff$Mode;
|
|
|
|
return-object p0
|
|
|
|
.line 204
|
|
:pswitch_2
|
|
sget-object p0, Landroid/graphics/PorterDuff$Mode;->MULTIPLY:Landroid/graphics/PorterDuff$Mode;
|
|
|
|
return-object p0
|
|
|
|
.line 203
|
|
:cond_0
|
|
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SRC_ATOP:Landroid/graphics/PorterDuff$Mode;
|
|
|
|
return-object p0
|
|
|
|
.line 202
|
|
:cond_1
|
|
sget-object p0, Landroid/graphics/PorterDuff$Mode;->SRC_IN:Landroid/graphics/PorterDuff$Mode;
|
|
|
|
return-object p0
|
|
|
|
.line 201
|
|
: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
|