709 lines
14 KiB
Smali
709 lines
14 KiB
Smali
.class public Lcom/moji/crop/CropUtil;
|
|
.super Ljava/lang/Object;
|
|
.source "CropUtil.java"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lcom/moji/crop/CropUtil$BackgroundJob;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
.line 47
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static a(Ljava/io/File;)I
|
|
.locals 2
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-nez p0, :cond_0
|
|
|
|
return v0
|
|
|
|
.line 64
|
|
:cond_0
|
|
:try_start_0
|
|
new-instance v1, Landroid/media/ExifInterface;
|
|
|
|
invoke-virtual {p0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-direct {v1, p0}, Landroid/media/ExifInterface;-><init>(Ljava/lang/String;)V
|
|
|
|
const-string p0, "Orientation"
|
|
|
|
.line 66
|
|
invoke-virtual {v1, p0, v0}, Landroid/media/ExifInterface;->getAttributeInt(Ljava/lang/String;I)I
|
|
|
|
move-result p0
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
const/4 v1, 0x3
|
|
|
|
if-eq p0, v1, :cond_3
|
|
|
|
const/4 v1, 0x6
|
|
|
|
if-eq p0, v1, :cond_2
|
|
|
|
const/16 v1, 0x8
|
|
|
|
if-eq p0, v1, :cond_1
|
|
|
|
return v0
|
|
|
|
:cond_1
|
|
const/16 p0, 0x10e
|
|
|
|
return p0
|
|
|
|
:cond_2
|
|
const/16 p0, 0x5a
|
|
|
|
return p0
|
|
|
|
:cond_3
|
|
const/16 p0, 0xb4
|
|
|
|
return p0
|
|
|
|
:catch_0
|
|
return v0
|
|
.end method
|
|
|
|
.method public static a(Landroid/graphics/Bitmap;I)Landroid/graphics/Bitmap;
|
|
.locals 7
|
|
|
|
if-nez p0, :cond_0
|
|
|
|
const/4 p0, 0x0
|
|
|
|
return-object p0
|
|
|
|
.line 98
|
|
:cond_0
|
|
new-instance v0, Landroid/graphics/Matrix;
|
|
|
|
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
|
|
|
|
int-to-float v1, p1
|
|
|
|
.line 99
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I
|
|
|
|
move-result v2
|
|
|
|
int-to-float v2, v2
|
|
|
|
const/high16 v3, 0x40000000 # 2.0f
|
|
|
|
div-float/2addr v2, v3
|
|
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result v4
|
|
|
|
int-to-float v4, v4
|
|
|
|
div-float/2addr v4, v3
|
|
|
|
invoke-virtual {v0, v1, v2, v4}, Landroid/graphics/Matrix;->setRotate(FFF)V
|
|
|
|
.line 101
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I
|
|
|
|
move-result v1
|
|
|
|
.line 102
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result v2
|
|
|
|
const/16 v3, 0x5a
|
|
|
|
const/4 v4, 0x0
|
|
|
|
if-ne p1, v3, :cond_2
|
|
|
|
.line 104
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result p1
|
|
|
|
int-to-float p1, p1
|
|
|
|
.line 106
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result v1
|
|
|
|
.line 107
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I
|
|
|
|
move-result v2
|
|
|
|
move v4, p1
|
|
|
|
:cond_1
|
|
const/4 p1, 0x0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_2
|
|
const/16 v3, 0xb4
|
|
|
|
if-ne p1, v3, :cond_3
|
|
|
|
.line 109
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I
|
|
|
|
move-result p1
|
|
|
|
int-to-float v4, p1
|
|
|
|
.line 110
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result p1
|
|
|
|
int-to-float p1, p1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_3
|
|
const/16 v3, 0x10e
|
|
|
|
if-ne p1, v3, :cond_1
|
|
|
|
.line 113
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I
|
|
|
|
move-result p1
|
|
|
|
int-to-float p1, p1
|
|
|
|
.line 114
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result v1
|
|
|
|
.line 115
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I
|
|
|
|
move-result v2
|
|
|
|
:goto_0
|
|
const/16 v3, 0x9
|
|
|
|
.line 121
|
|
new-array v3, v3, [F
|
|
|
|
.line 122
|
|
invoke-virtual {v0, v3}, Landroid/graphics/Matrix;->getValues([F)V
|
|
|
|
const/4 v5, 0x2
|
|
|
|
.line 124
|
|
aget v5, v3, v5
|
|
|
|
const/4 v6, 0x5
|
|
|
|
.line 125
|
|
aget v3, v3, v6
|
|
|
|
sub-float/2addr v4, v5
|
|
|
|
sub-float/2addr p1, v3
|
|
|
|
.line 127
|
|
invoke-virtual {v0, v4, p1}, Landroid/graphics/Matrix;->postTranslate(FF)Z
|
|
|
|
.line 128
|
|
sget-object p1, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;
|
|
|
|
invoke-static {v1, v2, p1}, Landroid/graphics/Bitmap;->createBitmap(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;
|
|
|
|
move-result-object p1
|
|
|
|
.line 130
|
|
new-instance v1, Landroid/graphics/Paint;
|
|
|
|
invoke-direct {v1}, Landroid/graphics/Paint;-><init>()V
|
|
|
|
.line 131
|
|
new-instance v2, Landroid/graphics/Canvas;
|
|
|
|
invoke-direct {v2, p1}, Landroid/graphics/Canvas;-><init>(Landroid/graphics/Bitmap;)V
|
|
|
|
.line 132
|
|
invoke-virtual {v2, p0, v0, v1}, Landroid/graphics/Canvas;->drawBitmap(Landroid/graphics/Bitmap;Landroid/graphics/Matrix;Landroid/graphics/Paint;)V
|
|
|
|
.line 133
|
|
invoke-virtual {p0}, Landroid/graphics/Bitmap;->recycle()V
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public static a(Landroid/content/Context;Landroid/content/ContentResolver;Landroid/net/Uri;)Ljava/io/File;
|
|
.locals 8
|
|
.annotation build Landroid/support/annotation/Nullable;
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-nez p2, :cond_0
|
|
|
|
return-object v0
|
|
|
|
.line 140
|
|
:cond_0
|
|
invoke-virtual {p2}, Landroid/net/Uri;->getScheme()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
if-nez v1, :cond_1
|
|
|
|
.line 142
|
|
new-instance p0, Ljava/io/File;
|
|
|
|
invoke-virtual {p2}, Landroid/net/Uri;->getPath()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {p0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_1
|
|
const-string v2, "file"
|
|
|
|
.line 143
|
|
invoke-virtual {v2, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_2
|
|
|
|
.line 144
|
|
new-instance p0, Ljava/io/File;
|
|
|
|
invoke-virtual {p2}, Landroid/net/Uri;->getPath()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {p0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_2
|
|
const-string v2, "content"
|
|
|
|
.line 145
|
|
invoke-virtual {v2, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_8
|
|
|
|
const/4 v1, 0x2
|
|
|
|
.line 146
|
|
new-array v4, v1, [Ljava/lang/String;
|
|
|
|
const/4 v1, 0x0
|
|
|
|
const-string v2, "_data"
|
|
|
|
aput-object v2, v4, v1
|
|
|
|
const/4 v1, 0x1
|
|
|
|
const-string v2, "_display_name"
|
|
|
|
aput-object v2, v4, v1
|
|
|
|
const/4 v5, 0x0
|
|
|
|
const/4 v6, 0x0
|
|
|
|
const/4 v7, 0x0
|
|
|
|
move-object v2, p1
|
|
|
|
move-object v3, p2
|
|
|
|
.line 149
|
|
:try_start_0
|
|
invoke-virtual/range {v2 .. v7}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
|
|
|
|
move-result-object v1
|
|
:try_end_0
|
|
.catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_3
|
|
.catch Ljava/lang/SecurityException; {:try_start_0 .. :try_end_0} :catch_2
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
if-eqz v1, :cond_5
|
|
|
|
.line 150
|
|
:try_start_1
|
|
invoke-interface {v1}, Landroid/database/Cursor;->moveToFirst()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_5
|
|
|
|
.line 151
|
|
invoke-virtual {p2}, Landroid/net/Uri;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
const-string v3, "content://com.google.android.gallery3d"
|
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_3
|
|
|
|
const-string v2, "_display_name"
|
|
|
|
.line 152
|
|
invoke-interface {v1, v2}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I
|
|
|
|
move-result v2
|
|
|
|
goto :goto_0
|
|
|
|
:cond_3
|
|
const-string v2, "_data"
|
|
|
|
.line 153
|
|
invoke-interface {v1, v2}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I
|
|
|
|
move-result v2
|
|
|
|
:goto_0
|
|
const/4 v3, -0x1
|
|
|
|
if-eq v2, v3, :cond_5
|
|
|
|
.line 156
|
|
invoke-interface {v1, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
.line 157
|
|
invoke-static {v2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
|
|
|
|
move-result v3
|
|
|
|
if-nez v3, :cond_5
|
|
|
|
.line 158
|
|
new-instance v3, Ljava/io/File;
|
|
|
|
invoke-direct {v3, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
:try_end_1
|
|
.catch Ljava/lang/IllegalArgumentException; {:try_start_1 .. :try_end_1} :catch_1
|
|
.catch Ljava/lang/SecurityException; {:try_start_1 .. :try_end_1} :catch_0
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
if-eqz v1, :cond_4
|
|
|
|
.line 168
|
|
invoke-interface {v1}, Landroid/database/Cursor;->close()V
|
|
|
|
:cond_4
|
|
return-object v3
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
goto :goto_4
|
|
|
|
:catch_0
|
|
nop
|
|
|
|
goto :goto_1
|
|
|
|
:catch_1
|
|
move-object v0, v1
|
|
|
|
goto :goto_3
|
|
|
|
:cond_5
|
|
if-eqz v1, :cond_8
|
|
|
|
goto :goto_2
|
|
|
|
:catchall_1
|
|
move-exception p0
|
|
|
|
move-object v1, v0
|
|
|
|
goto :goto_4
|
|
|
|
:catch_2
|
|
move-object v1, v0
|
|
|
|
:goto_1
|
|
if-eqz v1, :cond_8
|
|
|
|
:goto_2
|
|
invoke-interface {v1}, Landroid/database/Cursor;->close()V
|
|
|
|
goto :goto_5
|
|
|
|
.line 164
|
|
:catch_3
|
|
:goto_3
|
|
:try_start_2
|
|
invoke-static {p0, p1, p2}, Lcom/moji/crop/CropUtil;->b(Landroid/content/Context;Landroid/content/ContentResolver;Landroid/net/Uri;)Ljava/io/File;
|
|
|
|
move-result-object p0
|
|
:try_end_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_1
|
|
|
|
if-eqz v0, :cond_6
|
|
|
|
.line 168
|
|
invoke-interface {v0}, Landroid/database/Cursor;->close()V
|
|
|
|
:cond_6
|
|
return-object p0
|
|
|
|
:goto_4
|
|
if-eqz v1, :cond_7
|
|
|
|
invoke-interface {v1}, Landroid/database/Cursor;->close()V
|
|
|
|
.line 169
|
|
:cond_7
|
|
throw p0
|
|
|
|
:cond_8
|
|
:goto_5
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private static a(Landroid/content/Context;)Ljava/lang/String;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
.line 175
|
|
invoke-virtual {p0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;
|
|
|
|
move-result-object p0
|
|
|
|
const-string v0, "image"
|
|
|
|
const-string v1, "tmp"
|
|
|
|
.line 176
|
|
invoke-static {v0, v1, p0}, Ljava/io/File;->createTempFile(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
|
|
|
|
move-result-object p0
|
|
|
|
.line 177
|
|
invoke-virtual {p0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static a(Lcom/moji/crop/MonitoredActivity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Runnable;Landroid/os/Handler;)V
|
|
.locals 2
|
|
|
|
const/4 v0, 0x1
|
|
|
|
const/4 v1, 0x0
|
|
|
|
.line 213
|
|
invoke-static {p0, p1, p2, v0, v1}, Landroid/app/ProgressDialog;->show(Landroid/content/Context;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZZ)Landroid/app/ProgressDialog;
|
|
|
|
move-result-object p1
|
|
|
|
.line 215
|
|
new-instance p2, Lcom/moji/crop/CropUtil$BackgroundJob;
|
|
|
|
invoke-direct {p2, p0, p3, p1, p4}, Lcom/moji/crop/CropUtil$BackgroundJob;-><init>(Lcom/moji/crop/MonitoredActivity;Ljava/lang/Runnable;Landroid/app/ProgressDialog;Landroid/os/Handler;)V
|
|
|
|
invoke-static {p2}, Lcom/moji/tool/thread/MJPools;->a(Ljava/lang/Runnable;)I
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static a(Ljava/io/Closeable;)V
|
|
.locals 0
|
|
.param p0 # Ljava/io/Closeable;
|
|
.annotation build Landroid/support/annotation/Nullable;
|
|
.end annotation
|
|
.end param
|
|
|
|
if-nez p0, :cond_0
|
|
|
|
return-void
|
|
|
|
.line 55
|
|
:cond_0
|
|
:try_start_0
|
|
invoke-interface {p0}, Ljava/io/Closeable;->close()V
|
|
:try_end_0
|
|
.catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
:catch_0
|
|
return-void
|
|
.end method
|
|
|
|
.method private static b(Landroid/content/Context;Landroid/content/ContentResolver;Landroid/net/Uri;)Ljava/io/File;
|
|
.locals 4
|
|
.annotation build Landroid/support/annotation/Nullable;
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-nez p2, :cond_0
|
|
|
|
return-object v0
|
|
|
|
:cond_0
|
|
:try_start_0
|
|
const-string v1, "r"
|
|
|
|
.line 187
|
|
invoke-virtual {p1, p2, v1}, Landroid/content/ContentResolver;->openFileDescriptor(Landroid/net/Uri;Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;
|
|
|
|
move-result-object p1
|
|
|
|
.line 188
|
|
invoke-virtual {p1}, Landroid/os/ParcelFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;
|
|
|
|
move-result-object p1
|
|
|
|
.line 189
|
|
new-instance p2, Ljava/io/FileInputStream;
|
|
|
|
invoke-direct {p2, p1}, Ljava/io/FileInputStream;-><init>(Ljava/io/FileDescriptor;)V
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_2
|
|
|
|
.line 191
|
|
:try_start_1
|
|
invoke-static {p0}, Lcom/moji/crop/CropUtil;->a(Landroid/content/Context;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
.line 192
|
|
new-instance p1, Ljava/io/FileOutputStream;
|
|
|
|
invoke-direct {p1, p0}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V
|
|
:try_end_1
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_1
|
|
|
|
const/16 v1, 0x1000
|
|
|
|
.line 195
|
|
:try_start_2
|
|
new-array v1, v1, [B
|
|
|
|
.line 196
|
|
:goto_0
|
|
invoke-virtual {p2, v1}, Ljava/io/FileInputStream;->read([B)I
|
|
|
|
move-result v2
|
|
|
|
const/4 v3, -0x1
|
|
|
|
if-eq v2, v3, :cond_1
|
|
|
|
const/4 v3, 0x0
|
|
|
|
.line 197
|
|
invoke-virtual {p1, v1, v3, v2}, Ljava/io/FileOutputStream;->write([BII)V
|
|
|
|
goto :goto_0
|
|
|
|
.line 199
|
|
:cond_1
|
|
new-instance v1, Ljava/io/File;
|
|
|
|
invoke-direct {v1, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
:try_end_2
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
|
|
|
.line 203
|
|
invoke-static {p2}, Lcom/moji/crop/CropUtil;->a(Ljava/io/Closeable;)V
|
|
|
|
.line 204
|
|
invoke-static {p1}, Lcom/moji/crop/CropUtil;->a(Ljava/io/Closeable;)V
|
|
|
|
return-object v1
|
|
|
|
:catchall_0
|
|
move-exception p0
|
|
|
|
move-object v0, p1
|
|
|
|
goto :goto_1
|
|
|
|
:catchall_1
|
|
move-exception p0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-object p1, v0
|
|
|
|
goto :goto_2
|
|
|
|
:catchall_2
|
|
move-exception p0
|
|
|
|
move-object p2, v0
|
|
|
|
.line 203
|
|
:goto_1
|
|
invoke-static {p2}, Lcom/moji/crop/CropUtil;->a(Ljava/io/Closeable;)V
|
|
|
|
.line 204
|
|
invoke-static {v0}, Lcom/moji/crop/CropUtil;->a(Ljava/io/Closeable;)V
|
|
|
|
.line 205
|
|
throw p0
|
|
|
|
:catch_1
|
|
move-object p1, v0
|
|
|
|
move-object p2, p1
|
|
|
|
.line 203
|
|
:catch_2
|
|
:goto_2
|
|
invoke-static {p2}, Lcom/moji/crop/CropUtil;->a(Ljava/io/Closeable;)V
|
|
|
|
.line 204
|
|
invoke-static {p1}, Lcom/moji/crop/CropUtil;->a(Ljava/io/Closeable;)V
|
|
|
|
return-object v0
|
|
.end method
|