183 lines
4.5 KiB
Smali
183 lines
4.5 KiB
Smali
.class public Lcom/miguelgaeta/media_picker/Encoder;
|
|
.super Ljava/lang/Object;
|
|
.source "Encoder.java"
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static getBase64EncodedString(Ljava/io/InputStream;)Ljava/lang/String;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x2
|
|
|
|
invoke-static {p0, v0}, Lcom/miguelgaeta/media_picker/Encoder;->getBase64EncodedString(Ljava/io/InputStream;I)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getBase64EncodedString(Ljava/io/InputStream;I)Ljava/lang/String;
|
|
.locals 4
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const/16 v0, 0x2000
|
|
|
|
new-array v0, v0, [B
|
|
|
|
new-instance v1, Ljava/io/ByteArrayOutputStream;
|
|
|
|
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
|
|
|
|
:goto_0
|
|
invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result v2
|
|
|
|
const/4 v3, -0x1
|
|
|
|
if-eq v2, v3, :cond_0
|
|
|
|
const/4 v3, 0x0
|
|
|
|
invoke-virtual {v1, v0, v3, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0, p1}, Landroid/util/Base64;->encodeToString([BI)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getDataUrl(Ljava/lang/String;Landroid/graphics/Bitmap;)Ljava/lang/String;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
invoke-virtual {p1}, Landroid/graphics/Bitmap;->getRowBytes()I
|
|
|
|
move-result v0
|
|
|
|
invoke-virtual {p1}, Landroid/graphics/Bitmap;->getHeight()I
|
|
|
|
move-result v1
|
|
|
|
mul-int v0, v0, v1
|
|
|
|
invoke-static {v0}, Ljava/nio/ByteBuffer;->allocate(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p1, v0}, Landroid/graphics/Bitmap;->copyPixelsToBuffer(Ljava/nio/Buffer;)V
|
|
|
|
invoke-virtual {v0}, Ljava/nio/ByteBuffer;->array()[B
|
|
|
|
move-result-object p1
|
|
|
|
new-instance v0, Ljava/io/ByteArrayInputStream;
|
|
|
|
invoke-direct {v0, p1}, Ljava/io/ByteArrayInputStream;-><init>([B)V
|
|
|
|
invoke-static {p0, v0}, Lcom/miguelgaeta/media_picker/Encoder;->getDataUrl(Ljava/lang/String;Ljava/io/InputStream;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getDataUrl(Ljava/lang/String;Ljava/io/File;)Ljava/lang/String;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Ljava/io/FileInputStream;
|
|
|
|
invoke-direct {v0, p1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
|
|
|
|
invoke-static {p0, v0}, Lcom/miguelgaeta/media_picker/Encoder;->getDataUrl(Ljava/lang/String;Ljava/io/InputStream;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getDataUrl(Ljava/lang/String;Ljava/io/InputStream;)Ljava/lang/String;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x2
|
|
|
|
new-array v0, v0, [Ljava/lang/Object;
|
|
|
|
const/4 v1, 0x0
|
|
|
|
aput-object p0, v0, v1
|
|
|
|
invoke-static {p1}, Lcom/miguelgaeta/media_picker/Encoder;->getBase64EncodedString(Ljava/io/InputStream;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
const/4 p1, 0x1
|
|
|
|
aput-object p0, v0, p1
|
|
|
|
const-string p0, "data:%s;base64,%s"
|
|
|
|
invoke-static {p0, v0}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getDataUrl(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Ljava/io/File;
|
|
|
|
invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-static {p0, v0}, Lcom/miguelgaeta/media_picker/Encoder;->getDataUrl(Ljava/lang/String;Ljava/io/File;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|