IdenticonDrawable.smali

.class public Lim/tpelyyftgw/ui/components/IdenticonDrawable;
.super Landroid/graphics/drawable/Drawable;
.source "IdenticonDrawable.java"


# instance fields
.field private colors:[I

.field private data:[B

.field private paint:Landroid/graphics/Paint;


# direct methods
.method static constructor <clinit>()V
    .registers 1

    return-void
.end method

.method public constructor <init>()V
    .registers 2

    .line 13
    invoke-direct {p0}, Landroid/graphics/drawable/Drawable;-><init>()V

    .line 16
    new-instance v0, Landroid/graphics/Paint;

    invoke-direct {v0}, Landroid/graphics/Paint;-><init>()V

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->paint:Landroid/graphics/Paint;

    .line 17
    const/4 v0, 0x4

    new-array v0, v0, [I

    fill-array-data v0, :array_14

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->colors:[I

    return-void

    nop

    :array_14
    .array-data 4
        -0x1
        -0x2a190d
        -0xd2a88b
        -0xd06637
    .end array-data
.end method

.method private getBits(I)I
    .registers 4
    .param p1, "bitOffset"    # I

    .line 25
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->data:[B

    div-int/lit8 v1, p1, 0x8

    aget-byte v0, v0, v1

    rem-int/lit8 v1, p1, 0x8

    shr-int/2addr v0, v1

    and-int/lit8 v0, v0, 0x3

    return v0
.end method


# virtual methods
.method public draw(Landroid/graphics/Canvas;)V
    .registers 19
    .param p1, "canvas"    # Landroid/graphics/Canvas;

    .line 46
    move-object/from16 v0, p0

    iget-object v1, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->data:[B

    if-nez v1, :cond_7

    .line 47
    return-void

    .line 50
    :cond_7
    array-length v1, v1

    const/16 v2, 0x10

    const/high16 v3, 0x40000000    # 2.0f

    const/4 v4, 0x0

    if-ne v1, v2, :cond_94

    .line 51
    const/4 v1, 0x0

    .line 52
    .local v1, "bitPointer":I
    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v2

    invoke-virtual {v2}, Landroid/graphics/Rect;->width()I

    move-result v2

    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v5

    invoke-virtual {v5}, Landroid/graphics/Rect;->height()I

    move-result v5

    invoke-static {v2, v5}, Ljava/lang/Math;->min(II)I

    move-result v2

    int-to-float v2, v2

    const/high16 v5, 0x41000000    # 8.0f

    div-float/2addr v2, v5

    float-to-double v6, v2

    invoke-static {v6, v7}, Ljava/lang/Math;->floor(D)D

    move-result-wide v6

    double-to-float v2, v6

    .line 53
    .local v2, "rectSize":F
    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v6

    invoke-virtual {v6}, Landroid/graphics/Rect;->width()I

    move-result v6

    int-to-float v6, v6

    mul-float v7, v2, v5

    sub-float/2addr v6, v7

    div-float/2addr v6, v3

    invoke-static {v4, v6}, Ljava/lang/Math;->max(FF)F

    move-result v6

    .line 54
    .local v6, "xOffset":F
    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v7

    invoke-virtual {v7}, Landroid/graphics/Rect;->height()I

    move-result v7

    int-to-float v7, v7

    mul-float v5, v5, v2

    sub-float/2addr v7, v5

    div-float/2addr v7, v3

    invoke-static {v4, v7}, Ljava/lang/Math;->max(FF)F

    move-result v3

    .line 55
    .local v3, "yOffset":F
    const/4 v4, 0x0

    .local v4, "iy":I
    :goto_51
    const/16 v5, 0x8

    if-ge v4, v5, :cond_92

    .line 56
    const/4 v7, 0x0

    .local v7, "ix":I
    :goto_56
    if-ge v7, v5, :cond_8f

    .line 57
    invoke-direct {v0, v1}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBits(I)I

    move-result v8

    .line 58
    .local v8, "byteValue":I
    add-int/lit8 v1, v1, 0x2

    .line 59
    invoke-static {v8}, Ljava/lang/Math;->abs(I)I

    move-result v9

    rem-int/lit8 v9, v9, 0x4

    .line 60
    .local v9, "colorIndex":I
    iget-object v10, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->paint:Landroid/graphics/Paint;

    iget-object v11, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->colors:[I

    aget v11, v11, v9

    invoke-virtual {v10, v11}, Landroid/graphics/Paint;->setColor(I)V

    .line 61
    int-to-float v10, v7

    mul-float v10, v10, v2

    add-float v12, v6, v10

    int-to-float v10, v4

    mul-float v10, v10, v2

    add-float v13, v10, v3

    int-to-float v10, v7

    mul-float v10, v10, v2

    add-float/2addr v10, v6

    add-float v14, v10, v2

    int-to-float v10, v4

    mul-float v10, v10, v2

    add-float/2addr v10, v2

    add-float v15, v10, v3

    iget-object v10, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->paint:Landroid/graphics/Paint;

    move-object/from16 v11, p1

    move-object/from16 v16, v10

    invoke-virtual/range {v11 .. v16}, Landroid/graphics/Canvas;->drawRect(FFFFLandroid/graphics/Paint;)V

    .line 56
    .end local v8    # "byteValue":I
    .end local v9    # "colorIndex":I
    add-int/lit8 v7, v7, 0x1

    goto :goto_56

    .line 55
    .end local v7    # "ix":I
    :cond_8f
    add-int/lit8 v4, v4, 0x1

    goto :goto_51

    .line 64
    .end local v1    # "bitPointer":I
    .end local v2    # "rectSize":F
    .end local v3    # "yOffset":F
    .end local v4    # "iy":I
    .end local v6    # "xOffset":F
    :cond_92
    goto/16 :goto_118

    .line 65
    :cond_94
    const/4 v1, 0x0

    .line 66
    .restart local v1    # "bitPointer":I
    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v2

    invoke-virtual {v2}, Landroid/graphics/Rect;->width()I

    move-result v2

    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v5

    invoke-virtual {v5}, Landroid/graphics/Rect;->height()I

    move-result v5

    invoke-static {v2, v5}, Ljava/lang/Math;->min(II)I

    move-result v2

    int-to-float v2, v2

    const/high16 v5, 0x41400000    # 12.0f

    div-float/2addr v2, v5

    float-to-double v6, v2

    invoke-static {v6, v7}, Ljava/lang/Math;->floor(D)D

    move-result-wide v6

    double-to-float v2, v6

    .line 67
    .restart local v2    # "rectSize":F
    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v6

    invoke-virtual {v6}, Landroid/graphics/Rect;->width()I

    move-result v6

    int-to-float v6, v6

    mul-float v7, v2, v5

    sub-float/2addr v6, v7

    div-float/2addr v6, v3

    invoke-static {v4, v6}, Ljava/lang/Math;->max(FF)F

    move-result v6

    .line 68
    .restart local v6    # "xOffset":F
    invoke-virtual/range {p0 .. p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v7

    invoke-virtual {v7}, Landroid/graphics/Rect;->height()I

    move-result v7

    int-to-float v7, v7

    mul-float v5, v5, v2

    sub-float/2addr v7, v5

    div-float/2addr v7, v3

    invoke-static {v4, v7}, Ljava/lang/Math;->max(FF)F

    move-result v3

    .line 69
    .restart local v3    # "yOffset":F
    const/4 v4, 0x0

    .restart local v4    # "iy":I
    :goto_d6
    const/16 v5, 0xc

    if-ge v4, v5, :cond_118

    .line 70
    const/4 v7, 0x0

    .restart local v7    # "ix":I
    :goto_db
    if-ge v7, v5, :cond_115

    .line 71
    invoke-direct {v0, v1}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->getBits(I)I

    move-result v8

    .line 72
    .restart local v8    # "byteValue":I
    invoke-static {v8}, Ljava/lang/Math;->abs(I)I

    move-result v9

    rem-int/lit8 v9, v9, 0x4

    .line 73
    .restart local v9    # "colorIndex":I
    iget-object v10, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->paint:Landroid/graphics/Paint;

    iget-object v11, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->colors:[I

    aget v11, v11, v9

    invoke-virtual {v10, v11}, Landroid/graphics/Paint;->setColor(I)V

    .line 74
    int-to-float v10, v7

    mul-float v10, v10, v2

    add-float v12, v6, v10

    int-to-float v10, v4

    mul-float v10, v10, v2

    add-float v13, v10, v3

    int-to-float v10, v7

    mul-float v10, v10, v2

    add-float/2addr v10, v6

    add-float v14, v10, v2

    int-to-float v10, v4

    mul-float v10, v10, v2

    add-float/2addr v10, v2

    add-float v15, v10, v3

    iget-object v10, v0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->paint:Landroid/graphics/Paint;

    move-object/from16 v11, p1

    move-object/from16 v16, v10

    invoke-virtual/range {v11 .. v16}, Landroid/graphics/Canvas;->drawRect(FFFFLandroid/graphics/Paint;)V

    .line 75
    nop

    .end local v8    # "byteValue":I
    .end local v9    # "colorIndex":I
    add-int/lit8 v1, v1, 0x2

    .line 70
    add-int/lit8 v7, v7, 0x1

    goto :goto_db

    .line 69
    .end local v7    # "ix":I
    :cond_115
    add-int/lit8 v4, v4, 0x1

    goto :goto_d6

    .line 79
    .end local v1    # "bitPointer":I
    .end local v2    # "rectSize":F
    .end local v3    # "yOffset":F
    .end local v4    # "iy":I
    .end local v6    # "xOffset":F
    :cond_118
    :goto_118
    return-void
.end method

.method public getIntrinsicHeight()I
    .registers 2

    .line 103
    const/high16 v0, 0x42000000    # 32.0f

    invoke-static {v0}, Lim/tpelyyftgw/messenger/AndroidUtilities;->dp(F)I

    move-result v0

    return v0
.end method

.method public getIntrinsicWidth()I
    .registers 2

    .line 98
    const/high16 v0, 0x42000000    # 32.0f

    invoke-static {v0}, Lim/tpelyyftgw/messenger/AndroidUtilities;->dp(F)I

    move-result v0

    return v0
.end method

.method public getOpacity()I
    .registers 2

    .line 93
    const/4 v0, 0x0

    return v0
.end method

.method public setAlpha(I)V
    .registers 2
    .param p1, "alpha"    # I

    .line 84
    return-void
.end method

.method public setColorFilter(Landroid/graphics/ColorFilter;)V
    .registers 2
    .param p1, "cf"    # Landroid/graphics/ColorFilter;

    .line 89
    return-void
.end method

.method public setColors([I)V
    .registers 4
    .param p1, "value"    # [I

    .line 37
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->colors:[I

    array-length v0, v0

    const/4 v1, 0x4

    if-ne v0, v1, :cond_c

    .line 40
    iput-object p1, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->colors:[I

    .line 41
    invoke-virtual {p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->invalidateSelf()V

    .line 42
    return-void

    .line 38
    :cond_c
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "colors must have length of 4"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method public setEncryptedChat(Lim/tpelyyftgw/tgnet/TLRPC$EncryptedChat;)V
    .registers 3
    .param p1, "encryptedChat"    # Lim/tpelyyftgw/tgnet/TLRPC$EncryptedChat;

    .line 29
    iget-object v0, p1, Lim/tpelyyftgw/tgnet/TLRPC$EncryptedChat;->key_hash:[B

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->data:[B

    .line 30
    if-nez v0, :cond_10

    .line 31
    iget-object v0, p1, Lim/tpelyyftgw/tgnet/TLRPC$EncryptedChat;->auth_key:[B

    invoke-static {v0}, Lim/tpelyyftgw/messenger/AndroidUtilities;->calcAuthKeyHash([B)[B

    move-result-object v0

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->data:[B

    iput-object v0, p1, Lim/tpelyyftgw/tgnet/TLRPC$EncryptedChat;->key_hash:[B

    .line 33
    :cond_10
    invoke-virtual {p0}, Lim/tpelyyftgw/ui/components/IdenticonDrawable;->invalidateSelf()V

    .line 34
    return-void
.end method