what-the-bank/sources/o/C0599Kie.java

336 lines
14 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Parcelable;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import androidx.core.app.ActivityCompat;
import com.mr.flutter.plugin.filepicker.FilePickerPlugin;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import o.C12776fGw;
/* renamed from: o.Kie, reason: case insensitive filesystem */
/* loaded from: classes3.dex */
public final class C0599Kie implements PluginRegistry.ActivityResultListener, PluginRegistry.RequestPermissionsResultListener {
public static final int b = (FilePickerPlugin.class.hashCode() + 43) & 65535;
public String[] a;
public EventChannel.EventSink c;
public boolean d;
public boolean e;
private final Activity f;
public MethodChannel.Result g;
public final IeS h;
public String i;
/* renamed from: o.Kie$IeS */
/* loaded from: classes3.dex */
public interface IeS {
void a(String str, int i);
boolean a(String str);
}
static /* synthetic */ ArrayList OM_(Bundle bundle) {
if (Build.VERSION.SDK_INT >= 33) {
return bundle.getParcelableArrayList("selectedItems", Parcelable.class);
}
return bundle.getParcelableArrayList("selectedItems");
}
static /* synthetic */ void e(C0599Kie c0599Kie, String str, String str2) {
if (c0599Kie.g != null) {
c0599Kie.b(false);
c0599Kie.g.error(str, str2, null);
c0599Kie.g = null;
}
}
public C0599Kie(Activity activity) {
this(activity, new IeS(activity) { // from class: o.Kie.5
private Activity c;
{
this.c = activity;
}
@Override // o.C0599Kie.IeS
public final boolean a(String str) {
return ActivityCompat.checkSelfPermission(this.c, str) == 0;
}
@Override // o.C0599Kie.IeS
public final void a(String str, int i) {
ActivityCompat.lM_(this.c, new String[]{str}, i);
}
});
}
private C0599Kie(Activity activity, IeS ieS) {
this.e = false;
this.d = false;
this.f = activity;
this.g = null;
this.h = ieS;
}
@Override // io.flutter.plugin.common.PluginRegistry.ActivityResultListener
public final boolean onActivityResult(int i, int i2, Intent intent) {
if (this.i == null) {
return false;
}
int i3 = b;
if (i == i3 && i2 == -1) {
b(true);
new Thread(new Runnable(this, intent) { // from class: o.Kie.1
private C0599Kie a;
private Intent e;
{
this.a = this;
this.e = intent;
}
@Override // java.lang.Runnable
public final void run() {
Uri uri;
C12776fGw OO_;
String str;
if (this.e != null) {
ArrayList arrayList = new ArrayList();
if (this.e.getClipData() != null) {
int itemCount = this.e.getClipData().getItemCount();
for (int i4 = 0; i4 < itemCount; i4++) {
Uri uri2 = this.e.getClipData().getItemAt(i4).getUri();
C12776fGw OO_2 = VpV.OO_(this.a.f, uri2, this.a.d);
if (OO_2 != null) {
arrayList.add(OO_2);
uri2.getPath();
}
}
this.a.a(arrayList);
return;
}
if (this.e.getData() != null) {
Uri data = this.e.getData();
if (!this.a.i.equals("dir")) {
C12776fGw OO_3 = VpV.OO_(this.a.f, data, this.a.d);
if (OO_3 != null) {
arrayList.add(OO_3);
}
if (!arrayList.isEmpty()) {
this.a.a(arrayList);
return;
} else {
C0599Kie.e(this.a, "unknown_path", "Failed to retrieve path.");
return;
}
}
Uri buildDocumentUriUsingTree = DocumentsContract.buildDocumentUriUsingTree(data, DocumentsContract.getTreeDocumentId(data));
Activity activity = this.a.f;
if (buildDocumentUriUsingTree != null) {
if (Build.VERSION.SDK_INT < 30 && "com.android.providers.downloads.documents".equals(buildDocumentUriUsingTree.getAuthority())) {
String documentId = DocumentsContract.getDocumentId(buildDocumentUriUsingTree);
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();
if (documentId.equals("downloads")) {
r2 = path;
} else if (documentId.matches("^ms[df]\\:.*")) {
String ON_ = VpV.ON_(buildDocumentUriUsingTree, activity);
StringBuilder sb = new StringBuilder();
sb.append(path);
sb.append("/");
sb.append(ON_);
r2 = sb.toString();
} else if (documentId.startsWith("raw:")) {
r2 = documentId.split(":")[1];
}
} else {
String[] split = DocumentsContract.getTreeDocumentId(buildDocumentUriUsingTree).split(":");
String e = VpV.e(split.length > 0 ? split[0] : null, activity);
new C12776fGw.LWm();
if (e == null) {
r2 = File.separator;
} else {
if (e.endsWith(File.separator)) {
e = e.substring(0, e.length() - 1);
}
r2 = e;
String[] split2 = DocumentsContract.getTreeDocumentId(buildDocumentUriUsingTree).split(":");
if (split2.length < 2 || (str = split2[1]) == null) {
str = File.separator;
}
if (str.endsWith(File.separator)) {
str = str.substring(0, str.length() - 1);
}
if (str.length() > 0) {
if (str.startsWith(File.separator)) {
StringBuilder sb2 = new StringBuilder();
sb2.append(r2);
sb2.append(str);
r2 = sb2.toString();
} else {
StringBuilder sb3 = new StringBuilder();
sb3.append(r2);
sb3.append(File.separator);
sb3.append(str);
r2 = sb3.toString();
}
}
}
}
}
if (r2 != null) {
this.a.a(r2);
return;
} else {
C0599Kie.e(this.a, "unknown_path", "Failed to retrieve directory path.");
return;
}
}
if (this.e.getExtras() != null) {
Bundle extras = this.e.getExtras();
if (extras.keySet().contains("selectedItems")) {
ArrayList OM_ = C0599Kie.OM_(extras);
if (OM_ != null) {
Iterator it = OM_.iterator();
while (it.hasNext()) {
Parcelable parcelable = (Parcelable) it.next();
if ((parcelable instanceof Uri) && (OO_ = VpV.OO_(this.a.f, (uri = (Uri) parcelable), this.a.d)) != null) {
arrayList.add(OO_);
uri.getPath();
}
}
}
this.a.a(arrayList);
return;
}
C0599Kie.e(this.a, "unknown_path", "Failed to retrieve path from bundle.");
return;
}
C0599Kie.e(this.a, "unknown_activity", "Unknown activity error, please fill an issue.");
return;
}
C0599Kie.e(this.a, "unknown_activity", "Unknown activity error, please fill an issue.");
}
}).start();
return true;
}
if (i == i3 && i2 == 0) {
a((Object) null);
return true;
}
if (i == i3 && this.g != null) {
b(false);
this.g.error("unknown_activity", "Unknown activity error, please fill an issue.", null);
this.g = null;
}
return false;
}
@Override // io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
public final boolean onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
if (b != i) {
return false;
}
if (iArr.length > 0 && iArr[0] == 0) {
d();
return true;
}
if (this.g == null) {
return true;
}
b(false);
this.g.error("read_external_storage_denied", "User did not allow reading external storage", null);
this.g = null;
return true;
}
public final void d() {
Intent intent;
String str = this.i;
if (str == null) {
return;
}
if (str.equals("dir")) {
intent = new Intent("android.intent.action.OPEN_DOCUMENT_TREE");
} else {
if (this.i.equals("image/*")) {
intent = new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
} else {
intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
}
StringBuilder sb = new StringBuilder();
sb.append(Environment.getExternalStorageDirectory().getPath());
sb.append(File.separator);
intent.setDataAndType(Uri.parse(sb.toString()), this.i);
intent.setType(this.i);
intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", this.e);
intent.putExtra("multi-pick", this.e);
if (this.i.contains(",")) {
this.a = this.i.split(",");
}
String[] strArr = this.a;
if (strArr != null) {
intent.putExtra("android.intent.extra.MIME_TYPES", strArr);
}
}
if (intent.resolveActivity(this.f.getPackageManager()) != null) {
this.f.startActivityForResult(intent, b);
} else if (this.g != null) {
b(false);
this.g.error("invalid_format_type", "Can't handle the provided file type.", null);
this.g = null;
}
}
/* JADX INFO: Access modifiers changed from: private */
public void a(Object obj) {
b(false);
if (this.g != null) {
if (obj != null && !(obj instanceof String)) {
ArrayList arrayList = new ArrayList();
Iterator it = ((ArrayList) obj).iterator();
while (it.hasNext()) {
arrayList.add(((C12776fGw) it.next()).e());
}
obj = arrayList;
}
this.g.success(obj);
this.g = null;
}
}
private void b(boolean z) {
if (this.c == null || this.i.equals("dir")) {
return;
}
new Handler(this, Looper.getMainLooper(), z) { // from class: o.Kie.2
private boolean a;
private C0599Kie b;
{
this.b = this;
this.a = z;
}
@Override // android.os.Handler
public final void handleMessage(Message message) {
this.b.c.success(Boolean.valueOf(this.a));
}
}.obtainMessage().sendToTarget();
}
}