apkfuckery/com.discord/smali/androidx/appcompat/widget/DrawableUtils.smali
2019-12-06 04:29:40 +01:00

559 lines
13 KiB
Smali

.class public Landroidx/appcompat/widget/DrawableUtils;
.super Ljava/lang/Object;
.source "DrawableUtils.java"
# 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
# static fields
.field public static final CHECKED_STATE_SET:[I
.field public static final EMPTY_STATE_SET:[I
.field public static final INSETS_NONE:Landroid/graphics/Rect;
.field public static final TAG:Ljava/lang/String; = "DrawableUtils"
.field public static final VECTOR_DRAWABLE_CLAZZ_NAME:Ljava/lang/String; = "android.graphics.drawable.VectorDrawable"
.field public static sInsetsClazz:Ljava/lang/Class;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/Class<",
"*>;"
}
.end annotation
.end field
# direct methods
.method public static constructor <clinit>()V
.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
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"
:try_start_0
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
.method public 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
.param p0 # Landroid/graphics/drawable/Drawable;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
instance-of v0, p0, Landroid/graphics/drawable/DrawableContainer;
if-eqz v0, :cond_1
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_4
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
const/4 v2, 0x0
:goto_0
if-ge v2, v0, :cond_4
aget-object v3, p0, v2
invoke-static {v3}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
move-result v3
if-nez v3, :cond_0
return v1
:cond_0
add-int/lit8 v2, v2, 0x1
goto :goto_0
:cond_1
instance-of v0, p0, Landroidx/core/graphics/drawable/WrappedDrawable;
if-eqz v0, :cond_2
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
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
move-result p0
return p0
:cond_2
instance-of v0, p0, Landroidx/appcompat/graphics/drawable/DrawableWrapper;
if-eqz v0, :cond_3
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
invoke-static {p0}, Landroidx/appcompat/widget/DrawableUtils;->canSafelyMutateDrawable(Landroid/graphics/drawable/Drawable;)Z
move-result p0
return p0
:cond_3
instance-of v0, p0, Landroid/graphics/drawable/ScaleDrawable;
if-eqz v0, :cond_4
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_4
const/4 p0, 0x1
return p0
.end method
.method public static fixDrawable(Landroid/graphics/drawable/Drawable;)V
.locals 2
.param p0 # Landroid/graphics/drawable/Drawable;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
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 public 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/DrawableUtils;->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/DrawableUtils;->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 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
sget-object v0, Landroidx/appcompat/widget/DrawableUtils;->sInsetsClazz:Ljava/lang/Class;
if-eqz v0, :cond_7
: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_7
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_6
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_1
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_1
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_1
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_1
const/4 v7, 0x3
: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
: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
: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
: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
: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."
invoke-static {p0, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
: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
: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