340 lines
8.9 KiB
Smali
340 lines
8.9 KiB
Smali
.class Lcom/google/android/material/textfield/CutoutDrawable;
|
|
.super Lcom/google/android/material/shape/MaterialShapeDrawable;
|
|
.source "CutoutDrawable.java"
|
|
|
|
|
|
# instance fields
|
|
.field private final cutoutBounds:Landroid/graphics/RectF;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end field
|
|
|
|
.field private final cutoutPaint:Landroid/graphics/Paint;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end field
|
|
|
|
.field private savedLayer:I
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>()V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
invoke-direct {p0, v0}, Lcom/google/android/material/textfield/CutoutDrawable;-><init>(Lcom/google/android/material/shape/ShapeAppearanceModel;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>(Lcom/google/android/material/shape/ShapeAppearanceModel;)V
|
|
.locals 1
|
|
.param p1 # Lcom/google/android/material/shape/ShapeAppearanceModel;
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
.end param
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
.line 2
|
|
:cond_0
|
|
new-instance p1, Lcom/google/android/material/shape/ShapeAppearanceModel;
|
|
|
|
invoke-direct {p1}, Lcom/google/android/material/shape/ShapeAppearanceModel;-><init>()V
|
|
|
|
:goto_0
|
|
invoke-direct {p0, p1}, Lcom/google/android/material/shape/MaterialShapeDrawable;-><init>(Lcom/google/android/material/shape/ShapeAppearanceModel;)V
|
|
|
|
.line 3
|
|
new-instance p1, Landroid/graphics/Paint;
|
|
|
|
const/4 v0, 0x1
|
|
|
|
invoke-direct {p1, v0}, Landroid/graphics/Paint;-><init>(I)V
|
|
|
|
iput-object p1, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutPaint:Landroid/graphics/Paint;
|
|
|
|
.line 4
|
|
invoke-direct {p0}, Lcom/google/android/material/textfield/CutoutDrawable;->setPaintStyles()V
|
|
|
|
.line 5
|
|
new-instance p1, Landroid/graphics/RectF;
|
|
|
|
invoke-direct {p1}, Landroid/graphics/RectF;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutBounds:Landroid/graphics/RectF;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private postDraw(Landroid/graphics/Canvas;)V
|
|
.locals 1
|
|
.param p1 # Landroid/graphics/Canvas;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
.line 1
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getCallback()Landroid/graphics/drawable/Drawable$Callback;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-direct {p0, v0}, Lcom/google/android/material/textfield/CutoutDrawable;->useHardwareLayer(Landroid/graphics/drawable/Drawable$Callback;)Z
|
|
|
|
move-result v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
.line 2
|
|
iget v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->savedLayer:I
|
|
|
|
invoke-virtual {p1, v0}, Landroid/graphics/Canvas;->restoreToCount(I)V
|
|
|
|
:cond_0
|
|
return-void
|
|
.end method
|
|
|
|
.method private preDraw(Landroid/graphics/Canvas;)V
|
|
.locals 2
|
|
.param p1 # Landroid/graphics/Canvas;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
.line 1
|
|
invoke-virtual {p0}, Landroid/graphics/drawable/Drawable;->getCallback()Landroid/graphics/drawable/Drawable$Callback;
|
|
|
|
move-result-object v0
|
|
|
|
.line 2
|
|
invoke-direct {p0, v0}, Lcom/google/android/material/textfield/CutoutDrawable;->useHardwareLayer(Landroid/graphics/drawable/Drawable$Callback;)Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
.line 3
|
|
check-cast v0, Landroid/view/View;
|
|
|
|
.line 4
|
|
invoke-virtual {v0}, Landroid/view/View;->getLayerType()I
|
|
|
|
move-result p1
|
|
|
|
const/4 v1, 0x2
|
|
|
|
if-eq p1, v1, :cond_1
|
|
|
|
const/4 p1, 0x0
|
|
|
|
.line 5
|
|
invoke-virtual {v0, v1, p1}, Landroid/view/View;->setLayerType(ILandroid/graphics/Paint;)V
|
|
|
|
goto :goto_0
|
|
|
|
.line 6
|
|
:cond_0
|
|
invoke-direct {p0, p1}, Lcom/google/android/material/textfield/CutoutDrawable;->saveCanvasLayer(Landroid/graphics/Canvas;)V
|
|
|
|
:cond_1
|
|
:goto_0
|
|
return-void
|
|
.end method
|
|
|
|
.method private saveCanvasLayer(Landroid/graphics/Canvas;)V
|
|
.locals 6
|
|
.param p1 # Landroid/graphics/Canvas;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
const/4 v1, 0x0
|
|
|
|
const/4 v2, 0x0
|
|
|
|
.line 1
|
|
invoke-virtual {p1}, Landroid/graphics/Canvas;->getWidth()I
|
|
|
|
move-result v0
|
|
|
|
int-to-float v3, v0
|
|
|
|
invoke-virtual {p1}, Landroid/graphics/Canvas;->getHeight()I
|
|
|
|
move-result v0
|
|
|
|
int-to-float v4, v0
|
|
|
|
const/4 v5, 0x0
|
|
|
|
move-object v0, p1
|
|
|
|
invoke-virtual/range {v0 .. v5}, Landroid/graphics/Canvas;->saveLayer(FFFFLandroid/graphics/Paint;)I
|
|
|
|
move-result p1
|
|
|
|
iput p1, p0, Lcom/google/android/material/textfield/CutoutDrawable;->savedLayer:I
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private setPaintStyles()V
|
|
.locals 3
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutPaint:Landroid/graphics/Paint;
|
|
|
|
sget-object v1, Landroid/graphics/Paint$Style;->FILL_AND_STROKE:Landroid/graphics/Paint$Style;
|
|
|
|
invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V
|
|
|
|
.line 2
|
|
iget-object v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutPaint:Landroid/graphics/Paint;
|
|
|
|
const/4 v1, -0x1
|
|
|
|
invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V
|
|
|
|
.line 3
|
|
iget-object v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutPaint:Landroid/graphics/Paint;
|
|
|
|
new-instance v1, Landroid/graphics/PorterDuffXfermode;
|
|
|
|
sget-object v2, Landroid/graphics/PorterDuff$Mode;->DST_OUT:Landroid/graphics/PorterDuff$Mode;
|
|
|
|
invoke-direct {v1, v2}, Landroid/graphics/PorterDuffXfermode;-><init>(Landroid/graphics/PorterDuff$Mode;)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setXfermode(Landroid/graphics/Xfermode;)Landroid/graphics/Xfermode;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private useHardwareLayer(Landroid/graphics/drawable/Drawable$Callback;)Z
|
|
.locals 0
|
|
|
|
.line 1
|
|
instance-of p1, p1, Landroid/view/View;
|
|
|
|
return p1
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public draw(Landroid/graphics/Canvas;)V
|
|
.locals 2
|
|
.param p1 # Landroid/graphics/Canvas;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
.line 1
|
|
invoke-direct {p0, p1}, Lcom/google/android/material/textfield/CutoutDrawable;->preDraw(Landroid/graphics/Canvas;)V
|
|
|
|
.line 2
|
|
invoke-super {p0, p1}, Lcom/google/android/material/shape/MaterialShapeDrawable;->draw(Landroid/graphics/Canvas;)V
|
|
|
|
.line 3
|
|
iget-object v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutBounds:Landroid/graphics/RectF;
|
|
|
|
iget-object v1, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutPaint:Landroid/graphics/Paint;
|
|
|
|
invoke-virtual {p1, v0, v1}, Landroid/graphics/Canvas;->drawRect(Landroid/graphics/RectF;Landroid/graphics/Paint;)V
|
|
|
|
.line 4
|
|
invoke-direct {p0, p1}, Lcom/google/android/material/textfield/CutoutDrawable;->postDraw(Landroid/graphics/Canvas;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public hasCutout()Z
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutBounds:Landroid/graphics/RectF;
|
|
|
|
invoke-virtual {v0}, Landroid/graphics/RectF;->isEmpty()Z
|
|
|
|
move-result v0
|
|
|
|
xor-int/lit8 v0, v0, 0x1
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public removeCutout()V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
invoke-virtual {p0, v0, v0, v0, v0}, Lcom/google/android/material/textfield/CutoutDrawable;->setCutout(FFFF)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public setCutout(FFFF)V
|
|
.locals 2
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/material/textfield/CutoutDrawable;->cutoutBounds:Landroid/graphics/RectF;
|
|
|
|
iget v1, v0, Landroid/graphics/RectF;->left:F
|
|
|
|
cmpl-float v1, p1, v1
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
iget v1, v0, Landroid/graphics/RectF;->top:F
|
|
|
|
cmpl-float v1, p2, v1
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
iget v1, v0, Landroid/graphics/RectF;->right:F
|
|
|
|
cmpl-float v1, p3, v1
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
iget v1, v0, Landroid/graphics/RectF;->bottom:F
|
|
|
|
cmpl-float v1, p4, v1
|
|
|
|
if-eqz v1, :cond_1
|
|
|
|
.line 2
|
|
:cond_0
|
|
invoke-virtual {v0, p1, p2, p3, p4}, Landroid/graphics/RectF;->set(FFFF)V
|
|
|
|
.line 3
|
|
invoke-virtual {p0}, Lcom/google/android/material/shape/MaterialShapeDrawable;->invalidateSelf()V
|
|
|
|
:cond_1
|
|
return-void
|
|
.end method
|
|
|
|
.method public setCutout(Landroid/graphics/RectF;)V
|
|
.locals 3
|
|
.param p1 # Landroid/graphics/RectF;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
.line 4
|
|
iget v0, p1, Landroid/graphics/RectF;->left:F
|
|
|
|
iget v1, p1, Landroid/graphics/RectF;->top:F
|
|
|
|
iget v2, p1, Landroid/graphics/RectF;->right:F
|
|
|
|
iget p1, p1, Landroid/graphics/RectF;->bottom:F
|
|
|
|
invoke-virtual {p0, v0, v1, v2, p1}, Lcom/google/android/material/textfield/CutoutDrawable;->setCutout(FFFF)V
|
|
|
|
return-void
|
|
.end method
|