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

537 lines
12 KiB
Smali
Raw Normal View History

2019-02-04 20:08:30 +00:00
.class public Landroidx/appcompat/widget/DrawableUtils;
.super Ljava/lang/Object;
2019-02-04 20:29:01 +00:00
.source "DrawableUtils.java"
2019-02-04 20:08:30 +00:00
# annotations
.annotation build Landroidx/annotation/RestrictTo;
value = {
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP:Landroidx/annotation/RestrictTo$Scope;
}
.end annotation
# 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
2019-02-04 20:29:01 +00:00
return-void
2019-02-04 20:08:30 +00:00
: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
.param p0 # Landroid/graphics/drawable/Drawable;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
: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
.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
const-string v0, "android.graphics.drawable.VectorDrawable"
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/Class;->getName()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, 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
2019-02-04 20:29:01 +00:00
invoke-virtual {p0, v1}, Landroid/graphics/drawable/Drawable;->setState([I)Z
2019-02-04 20:08:30 +00:00
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
2019-02-04 20:29:01 +00:00
:goto_1
2019-02-04 20:08:30 +00:00
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 10
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 v9, -0x527265d5
if-eq v8, v9, :cond_3
const v9, 0x1c155
if-eq v8, v9, :cond_2
const v9, 0x32a007
if-eq v8, v9, :cond_1
const v9, 0x677c21c
if-eq v8, v9, :cond_0
goto :goto_1
:cond_0
const-string v8, "right"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
if-eqz v6, :cond_4
const/4 v6, 0x2
goto :goto_2
:cond_1
const-string v8, "left"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
if-eqz v6, :cond_4
const/4 v6, 0x0
goto :goto_2
:cond_2
const-string v8, "top"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
if-eqz v6, :cond_4
const/4 v6, 0x1
goto :goto_2
:cond_3
const-string v8, "bottom"
invoke-virtual {v6, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
if-eqz v6, :cond_4
const/4 v6, 0x3
goto :goto_2
:cond_4
:goto_1
const/4 v6, -0x1
:goto_2
packed-switch v6, :pswitch_data_0
goto :goto_3
:pswitch_0
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_3
:pswitch_1
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_3
:pswitch_2
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_3
:pswitch_3
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_3
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
:pswitch_data_0
.packed-switch 0x0
:pswitch_3
:pswitch_2
:pswitch_1
:pswitch_0
.end packed-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