306 lines
9.8 KiB
Smali
306 lines
9.8 KiB
Smali
.class public Lcom/miguelgaeta/media_picker/MediaPickerChooser;
|
|
.super Ljava/lang/Object;
|
|
.source "MediaPickerChooser.java"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static getIntentActivities(Ljava/util/Map;Landroid/content/pm/PackageManager;Landroid/content/Intent;Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;)V
|
|
.locals 4
|
|
.param p0 # Ljava/util/Map;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p1 # Landroid/content/pm/PackageManager;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p2 # Landroid/content/Intent;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p3 # Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
.end param
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/String;",
|
|
"Landroid/content/Intent;",
|
|
">;",
|
|
"Landroid/content/pm/PackageManager;",
|
|
"Landroid/content/Intent;",
|
|
"Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;",
|
|
")V"
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
invoke-virtual {p1, p2, v0}, Landroid/content/pm/PackageManager;->queryIntentActivities(Landroid/content/Intent;I)Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, Landroid/content/pm/ResolveInfo;
|
|
|
|
new-instance v1, Landroid/content/ComponentName;
|
|
|
|
iget-object v2, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;
|
|
|
|
iget-object v2, v2, Landroid/content/pm/ActivityInfo;->packageName:Ljava/lang/String;
|
|
|
|
iget-object v3, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;
|
|
|
|
iget-object v3, v3, Landroid/content/pm/ActivityInfo;->name:Ljava/lang/String;
|
|
|
|
invoke-direct {v1, v2, v3}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
new-instance v2, Landroid/content/Intent;
|
|
|
|
invoke-direct {v2, p2}, Landroid/content/Intent;-><init>(Landroid/content/Intent;)V
|
|
|
|
invoke-virtual {v2, v1}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;
|
|
|
|
iget-object v1, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;
|
|
|
|
iget-object v1, v1, Landroid/content/pm/ActivityInfo;->packageName:Ljava/lang/String;
|
|
|
|
invoke-virtual {v2, v1}, Landroid/content/Intent;->setPackage(Ljava/lang/String;)Landroid/content/Intent;
|
|
|
|
if-eqz p3, :cond_0
|
|
|
|
invoke-interface {p3, v2}, Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;->onFoundIntent(Landroid/content/Intent;)V
|
|
|
|
:cond_0
|
|
iget-object v0, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;
|
|
|
|
iget-object v0, v0, Landroid/content/pm/ActivityInfo;->packageName:Ljava/lang/String;
|
|
|
|
invoke-interface {p0, v0, v2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
return-void
|
|
.end method
|
|
|
|
.method public static getMediaActivityIntents(Landroid/content/pm/PackageManager;Landroid/net/Uri;Ljava/lang/String;)Ljava/util/Collection;
|
|
.locals 4
|
|
.param p0 # Landroid/content/pm/PackageManager;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p1 # Landroid/net/Uri;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p2 # Ljava/lang/String;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroid/content/pm/PackageManager;",
|
|
"Landroid/net/Uri;",
|
|
"Ljava/lang/String;",
|
|
")",
|
|
"Ljava/util/Collection<",
|
|
"Landroid/content/Intent;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Landroid/content/Intent;
|
|
|
|
const-string v1, "android.media.action.IMAGE_CAPTURE"
|
|
|
|
invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
|
|
|
|
const-string v1, "output"
|
|
|
|
invoke-virtual {v0, v1, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, 0x2
|
|
|
|
invoke-virtual {v0, v1}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, 0x1
|
|
|
|
invoke-virtual {v0, v1}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "android.intent.action.PICK"
|
|
|
|
invoke-static {v1, p2}, Lcom/miguelgaeta/media_picker/MediaPicker;->getIntent(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "android.intent.action.GET_CONTENT"
|
|
|
|
invoke-static {v2, p2}, Lcom/miguelgaeta/media_picker/MediaPicker;->getIntent(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
|
|
|
|
move-result-object p2
|
|
|
|
new-instance v2, Ljava/util/LinkedHashMap;
|
|
|
|
invoke-direct {v2}, Ljava/util/LinkedHashMap;-><init>()V
|
|
|
|
const/4 v3, 0x0
|
|
|
|
invoke-static {v2, p0, p2, v3}, Lcom/miguelgaeta/media_picker/MediaPickerChooser;->getIntentActivities(Ljava/util/Map;Landroid/content/pm/PackageManager;Landroid/content/Intent;Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;)V
|
|
|
|
invoke-static {v2, p0, v1, v3}, Lcom/miguelgaeta/media_picker/MediaPickerChooser;->getIntentActivities(Ljava/util/Map;Landroid/content/pm/PackageManager;Landroid/content/Intent;Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;)V
|
|
|
|
new-instance p2, Lcom/miguelgaeta/media_picker/MediaPickerChooser$1;
|
|
|
|
invoke-direct {p2, p1}, Lcom/miguelgaeta/media_picker/MediaPickerChooser$1;-><init>(Landroid/net/Uri;)V
|
|
|
|
invoke-static {v2, p0, v0, p2}, Lcom/miguelgaeta/media_picker/MediaPickerChooser;->getIntentActivities(Ljava/util/Map;Landroid/content/pm/PackageManager;Landroid/content/Intent;Lcom/miguelgaeta/media_picker/MediaPickerChooser$IntentModifier;)V
|
|
|
|
invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getMediaChooserIntent(Landroid/content/pm/PackageManager;Ljava/lang/String;Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;
|
|
.locals 1
|
|
.param p0 # Landroid/content/pm/PackageManager;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p1 # Ljava/lang/String;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p2 # Landroid/net/Uri;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.param p3 # Ljava/lang/String;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
invoke-static {p0, p2, p3}, Lcom/miguelgaeta/media_picker/MediaPickerChooser;->getMediaActivityIntents(Landroid/content/pm/PackageManager;Landroid/net/Uri;Ljava/lang/String;)Ljava/util/Collection;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-interface {p0}, Ljava/util/Collection;->isEmpty()Z
|
|
|
|
move-result p2
|
|
|
|
if-nez p2, :cond_2
|
|
|
|
invoke-interface {p0}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-interface {p0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object p2
|
|
|
|
check-cast p2, Landroid/content/Intent;
|
|
|
|
new-instance p3, Ljava/util/ArrayList;
|
|
|
|
invoke-direct {p3}, Ljava/util/ArrayList;-><init>()V
|
|
|
|
:goto_0
|
|
invoke-interface {p0}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-interface {p0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {p3, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-static {p2, p1}, Landroid/content/Intent;->createChooser(Landroid/content/Intent;Ljava/lang/CharSequence;)Landroid/content/Intent;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-interface {p3}, Ljava/util/List;->isEmpty()Z
|
|
|
|
move-result p1
|
|
|
|
if-nez p1, :cond_1
|
|
|
|
invoke-interface {p3}, Ljava/util/List;->size()I
|
|
|
|
move-result p1
|
|
|
|
new-array p1, p1, [Landroid/os/Parcelable;
|
|
|
|
invoke-interface {p3, p1}, Ljava/util/List;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;
|
|
|
|
move-result-object p1
|
|
|
|
check-cast p1, [Landroid/os/Parcelable;
|
|
|
|
const-string p2, "android.intent.extra.INITIAL_INTENTS"
|
|
|
|
invoke-virtual {p0, p2, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;[Landroid/os/Parcelable;)Landroid/content/Intent;
|
|
|
|
:cond_1
|
|
return-object p0
|
|
|
|
:cond_2
|
|
new-instance p0, Ljava/io/IOException;
|
|
|
|
const-string p1, "No media applications available on this device."
|
|
|
|
invoke-direct {p0, p1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p0
|
|
.end method
|