正在查看: 万能钥匙 v1.1.23 应用的 ImageModuleHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 ImageModuleHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.api.media;
import android.app.Activity;
import android.content.ClipData;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import androidx.fragment.app.FragmentActivity;
import com.finogeeks.lib.applet.R;
import com.finogeeks.lib.applet.api.CallbackHandlerKt;
import com.finogeeks.lib.applet.api.SafetyApi;
import com.finogeeks.lib.applet.appletdir.AbsAppletDirProvider;
import com.finogeeks.lib.applet.appletdir.AppletStoreDirProvider;
import com.finogeeks.lib.applet.appletdir.AppletTempDirProvider;
import com.finogeeks.lib.applet.appletdir.AppletUsrDirProvider;
import com.finogeeks.lib.applet.config.AppConfig;
import com.finogeeks.lib.applet.externallib.bottomsheet.BottomSheet;
import com.finogeeks.lib.applet.externallib.bottomsheet.BottomSheetListener;
import com.finogeeks.lib.applet.externallib.bottomsheet.menu.BottomSheetMenuItem;
import com.finogeeks.lib.applet.externallib.easyphotos.easyphotos.models.album.entity.Photo;
import com.finogeeks.lib.applet.f.a.easyphotos.EasyPhotosRequest;
import com.finogeeks.lib.applet.interfaces.ICallback;
import com.finogeeks.lib.applet.main.IntentsKt;
import com.finogeeks.lib.applet.main.host.Host;
import com.finogeeks.lib.applet.model.CameraParams;
import com.finogeeks.lib.applet.model.Event;
import com.finogeeks.lib.applet.model.FileInfo;
import com.finogeeks.lib.applet.modules.applet_scope.AppletScopeManager;
import com.finogeeks.lib.applet.modules.applet_scope.ScopeRequest;
import com.finogeeks.lib.applet.modules.applet_scope.bean.AppletScopeBean;
import com.finogeeks.lib.applet.modules.ext.C0325a;
import com.finogeeks.lib.applet.modules.ext.C0326b;
import com.finogeeks.lib.applet.modules.ext.s;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.modules.permission.PermissionKt;
import com.finogeeks.lib.applet.modules.subscaleview.ImageEditeActivity;
import com.finogeeks.lib.applet.modules.subscaleview.MediaViewerData;
import com.finogeeks.lib.applet.rest.model.UserMessageType;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import com.finogeeks.lib.applet.utils.ThemeModeUtil;
import com.finogeeks.lib.applet.utils.b1;
import com.finogeeks.lib.applet.utils.c0;
import com.finogeeks.lib.applet.utils.c1;
import com.finogeeks.lib.applet.utils.x;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.a0;
import kotlin.jvm.internal.d0;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.y;
import lg0.e0;
import org.json.JSONArray;
import org.json.JSONObject;
import tj0.t;
import tj0.u;
@Metadata(d1 = {"\u0000¤\u0001\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0006\u0018\u00002\u00020\u0001:\u0001aB\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J%\u0010\r\u001a\u00020\f2\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\n¢\u0006\u0004\b\r\u0010\u000eJ\u001f\u0010\u000f\u001a\u00020\f2\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\nH\u0002¢\u0006\u0004\b\u000f\u0010\u0010J'\u0010\u0012\u001a\u00020\f2\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0011\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\nH\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u0017\u0010\u0016\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u0014H\u0002¢\u0006\u0004\b\u0016\u0010\u0017J\u001d\u0010\u0019\u001a\u00020\f2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b\u0019\u0010\u001aJ\r\u0010\u001b\u001a\u00020\f¢\u0006\u0004\b\u001b\u0010\u001cJ%\u0010\u001e\u001a\u00020\f2\u0006\u0010\u001d\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b\u001e\u0010\u001fJ\u001d\u0010 \u001a\u00020\f2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b \u0010\u001aJ'\u0010$\u001a\u00020\f2\u000e\u0010#\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\"0!2\u0006\u0010\u000b\u001a\u00020\u0018H\u0002¢\u0006\u0004\b$\u0010%J/\u0010+\u001a\u00020\f2\u0006\u0010'\u001a\u00020&2\u0006\u0010(\u001a\u00020&2\b\u0010*\u001a\u0004\u0018\u00010)2\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b+\u0010,J\u001d\u0010-\u001a\u00020\f2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b-\u0010\u001aJ\u001d\u0010.\u001a\u00020\f2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b.\u0010\u001aJ5\u00103\u001a\u00020\f2\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\b2\u0006\u00100\u001a\u00020/2\u0006\u00102\u001a\u0002012\u0006\u0010\u000b\u001a\u00020\u0018¢\u0006\u0004\b3\u00104R\u0014\u00106\u001a\u0002058\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b6\u00107R\u001b\u0010=\u001a\u0002088BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b9\u0010:\u001a\u0004\b;\u0010<R\u0014\u0010>\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b>\u0010?R\u0018\u0010@\u001a\u0004\u0018\u00010\"8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b@\u0010AR\u0016\u0010B\u001a\u00020&8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bB\u0010CR\u0016\u0010E\u001a\u00020D8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bE\u0010FR#\u0010L\u001a\n H*\u0004\u0018\u00010G0G8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bI\u0010:\u001a\u0004\bJ\u0010KR\u001c\u0010N\u001a\n H*\u0004\u0018\u00010M0M8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bN\u0010OR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010PR\u0016\u0010Q\u001a\u00020D8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bQ\u0010FR\u001b\u0010V\u001a\u00020R8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bS\u0010:\u001a\u0004\bT\u0010UR\u001b\u0010[\u001a\u00020W8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bX\u0010:\u001a\u0004\bY\u0010ZR\u001b\u0010`\u001a\u00020\\8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b]\u0010:\u001a\u0004\b^\u0010_¨\u0006b"}, d2 = {"Lcom/finogeeks/lib/applet/api/media/ImageModuleHandler;", "", "Lcom/finogeeks/lib/applet/main/host/Host;", "host", "<init>", "(Lcom/finogeeks/lib/applet/main/host/Host;)V", "", FinFileResourceUtil.KEY_EVENT, "Lorg/json/JSONObject;", "param", "Lcom/finogeeks/lib/applet/api/SafetyApi$SafeCallback;", "callback", "Llg0/e0;", "chooseImage", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/api/SafetyApi$SafeCallback;)V", "chooseImageByAlbum", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/api/SafetyApi$SafeCallback;)V", UserMessageType.CAMERA, "chooseImageByCamera", "(Ljava/lang/String;Ljava/lang/String;Lcom/finogeeks/lib/applet/api/SafetyApi$SafeCallback;)V", "Ljava/io/File;", "file", "compressChooseImage", "(Ljava/io/File;)Ljava/io/File;", "Lcom/finogeeks/lib/applet/interfaces/ICallback;", "compressImage", "(Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "destroy", "()V", "editeMode", "editImage", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "getLocalImgData", "", "Lcom/finogeeks/lib/applet/model/FileInfo;", "photos", "handleResult", "(Ljava/util/List;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "", "requestCode", "resultCode", "Landroid/content/Intent;", "data", "onActivityResult", "(IILandroid/content/Intent;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "previewImage", "previewMedia", "Lcom/finogeeks/lib/applet/modules/applet_scope/AppletScopeManager;", "scopeManager", "Lcom/finogeeks/lib/applet/modules/applet_scope/ScopeRequest;", "scopeRequest", "saveImageToPhotosAlbum", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/modules/applet_scope/AppletScopeManager;Lcom/finogeeks/lib/applet/modules/applet_scope/ScopeRequest;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "Landroidx/fragment/app/FragmentActivity;", "activity", "Landroidx/fragment/app/FragmentActivity;", "Lcom/finogeeks/lib/applet/config/AppConfig;", "appConfig$delegate", "Llg0/h;", "getAppConfig", "()Lcom/finogeeks/lib/applet/config/AppConfig;", "appConfig", "appId", "Ljava/lang/String;", "cameraImageFileInfo", "Lcom/finogeeks/lib/applet/model/FileInfo;", "chooseCount", "I", "", "compressWhenChooseImage", "Z", "Landroid/content/ContentResolver;", "kotlin.jvm.PlatformType", "contentResolver$delegate", "getContentResolver", "()Landroid/content/ContentResolver;", "contentResolver", "Ljava/util/concurrent/ExecutorService;", "executorService", "Ljava/util/concurrent/ExecutorService;", "Lcom/finogeeks/lib/applet/main/host/Host;", "isDestroy", "Lcom/finogeeks/lib/applet/appletdir/AppletStoreDirProvider;", "storeDirProvider$delegate", "getStoreDirProvider", "()Lcom/finogeeks/lib/applet/appletdir/AppletStoreDirProvider;", "storeDirProvider", "Lcom/finogeeks/lib/applet/appletdir/AppletTempDirProvider;", "tempDirProvider$delegate", "getTempDirProvider", "()Lcom/finogeeks/lib/applet/appletdir/AppletTempDirProvider;", "tempDirProvider", "Lcom/finogeeks/lib/applet/appletdir/AppletUsrDirProvider;", "usrDirProvider$delegate", "getUsrDirProvider", "()Lcom/finogeeks/lib/applet/appletdir/AppletUsrDirProvider;", "usrDirProvider", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class ImageModuleHandler {
static final hh0.l[] m = {g0.j(new y(g0.b(ImageModuleHandler.class), "contentResolver", "getContentResolver()Landroid/content/ContentResolver;")), g0.j(new y(g0.b(ImageModuleHandler.class), "appConfig", "getAppConfig()Lcom/finogeeks/lib/applet/config/AppConfig;")), g0.j(new y(g0.b(ImageModuleHandler.class), "usrDirProvider", "getUsrDirProvider()Lcom/finogeeks/lib/applet/appletdir/AppletUsrDirProvider;")), g0.j(new y(g0.b(ImageModuleHandler.class), "tempDirProvider", "getTempDirProvider()Lcom/finogeeks/lib/applet/appletdir/AppletTempDirProvider;")), g0.j(new y(g0.b(ImageModuleHandler.class), "storeDirProvider", "getStoreDirProvider()Lcom/finogeeks/lib/applet/appletdir/AppletStoreDirProvider;"))};
private final FragmentActivity a;
private final String b;
private FileInfo c;
private boolean d;
private final ExecutorService e;
private final lg0.h f;
private int g;
private boolean h;
private final lg0.h i;
private final lg0.h j;
private final lg0.h k;
private final Host l;
public static final class a {
private a() {
}
public a(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public static final class b extends kotlin.jvm.internal.p implements ah0.a<AppConfig> {
public b() {
super(0);
}
public final AppConfig m100invoke() {
return ImageModuleHandler.this.l.getAppConfig();
}
}
public static final class c implements BottomSheetListener {
private boolean a;
final String c;
final SafetyApi.b d;
final String e;
public c(String str, SafetyApi.b bVar, String str2) {
this.c = str;
this.d = bVar;
this.e = str2;
}
@Override
public void onSheetDismissed(BottomSheet bottomSheet, Object obj, int i) {
kotlin.jvm.internal.n.j(bottomSheet, "bottomSheet");
if (this.a) {
return;
}
CallbackHandlerKt.cancelAsFail(this.d);
}
@Override
public void onSheetItemSelected(BottomSheet bottomSheet, MenuItem menuItem, Object obj) {
kotlin.jvm.internal.n.j(bottomSheet, "bottomSheet");
kotlin.jvm.internal.n.j(menuItem, "menuItem");
if (this.a) {
return;
}
String valueOf = String.valueOf(menuItem.getTitle());
if (kotlin.jvm.internal.n.d(valueOf, ImageModuleHandler.this.a.getString(R.string.fin_applet_album))) {
ImageModuleHandler.this.a(this.c, this.d);
} else if (kotlin.jvm.internal.n.d(valueOf, ImageModuleHandler.this.a.getString(R.string.fin_applet_camera))) {
ImageModuleHandler imageModuleHandler = ImageModuleHandler.this;
String str = this.c;
String str2 = this.e;
kotlin.jvm.internal.n.e(str2, UserMessageType.CAMERA);
imageModuleHandler.a(str, str2, this.d);
} else {
CallbackHandlerKt.cancelAsFail(this.d);
}
this.a = true;
}
@Override
public void onSheetShown(BottomSheet bottomSheet, Object obj) {
kotlin.jvm.internal.n.j(bottomSheet, "bottomSheet");
}
}
public static final class d extends kotlin.jvm.internal.p implements ah0.a<e0> {
final SafetyApi.b a;
final String b;
public d(SafetyApi.b bVar, String str) {
super(0);
this.a = bVar;
this.b = str;
}
public Object invoke() {
m101invoke();
return e0.a;
}
public final void m101invoke() {
this.a.onFail(CallbackHandlerKt.apiFail(this.b));
}
}
@Metadata(d1 = {"\u0000\u000e\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0005\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", "allow", "Llg0/e0;", "invoke", "(Z)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
public static final class e extends kotlin.jvm.internal.p implements ah0.l<Boolean, e0> {
final AppletScopeManager b;
final String c;
final SafetyApi.b d;
final String e;
public static final class a extends kotlin.jvm.internal.p implements ah0.a<e0> {
public a() {
super(0);
}
public Object invoke() {
m102invoke();
return e0.a;
}
public final void m102invoke() {
e.this.b.authResultCallback(AppletScopeBean.SCOPE_CAMERA, true);
EasyPhotosRequest easyPhotosRequest = new EasyPhotosRequest(ImageModuleHandler.this.a);
easyPhotosRequest.a("IMAGE");
easyPhotosRequest.a(kotlin.jvm.internal.n.d(e.this.c, CameraParams.DEVICE_POSITION_FACING_FRONT));
String absolutePath = ImageModuleHandler.this.e().getDirForWrite().getAbsolutePath();
kotlin.jvm.internal.n.e(absolutePath, "dir");
easyPhotosRequest.b(absolutePath);
easyPhotosRequest.a(ImageModuleHandler.this.b, 1018);
}
}
public static final class b extends kotlin.jvm.internal.p implements ah0.l<String[], e0> {
public b() {
super(1);
}
public final void a(String[] strArr) {
kotlin.jvm.internal.n.j(strArr, "it");
e.this.b.authResultCallback(AppletScopeBean.SCOPE_CAMERA, false);
e eVar = e.this;
CallbackHandlerKt.unauthorized(eVar.d, eVar.e, strArr);
}
public Object invoke(Object obj) {
a((String[]) obj);
return e0.a;
}
}
public static final class c extends kotlin.jvm.internal.p implements ah0.a<e0> {
public c() {
super(0);
}
public Object invoke() {
m103invoke();
return e0.a;
}
public final void m103invoke() {
e.this.b.authResultCallback(AppletScopeBean.SCOPE_CAMERA, false);
e eVar = e.this;
CallbackHandlerKt.disableAuthorized(eVar.d, eVar.e);
}
}
public e(AppletScopeManager appletScopeManager, String str, SafetyApi.b bVar, String str2) {
super(1);
this.b = appletScopeManager;
this.c = str;
this.d = bVar;
this.e = str2;
}
public final void a(boolean z10) {
if (z10) {
PermissionKt.askForPermissions(ImageModuleHandler.this.a, "android.permission.CAMERA").onGranted(new a()).onDenied(new b()).onDisallowByApplet((ah0.a<e0>) new c()).go();
} else {
this.b.authResultCallback(AppletScopeBean.SCOPE_CAMERA, false);
CallbackHandlerKt.authDeny(this.d, this.e);
}
}
public Object invoke(Object obj) {
a(((Boolean) obj).booleanValue());
return e0.a;
}
}
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0005\u001a\u00020\u0002*\b\u0012\u0004\u0012\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lcom/finogeeks/lib/applet/modules/ext/AnkoAsyncContext;", "Lcom/finogeeks/lib/applet/api/media/ImageModuleHandler;", "Llg0/e0;", "invoke", "(Lcom/finogeeks/lib/applet/modules/ext/AnkoAsyncContext;)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
public static final class AnkoAsyncContext extends kotlin.jvm.internal.p implements ah0.l<C0326b<ImageModuleHandler>, e0> {
final String b;
final String c;
final d0 d;
final d0 e;
final Bitmap.CompressFormat f;
final int g;
final ICallback h;
final String i;
final int j;
final int k;
@Metadata(d1 = {"\u0000\b\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0003\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0001\u0010\u0002"}, d2 = {"Llg0/e0;", "run", "()V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
public static final class a implements Runnable {
final C0326b b;
final a0 c;
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0005\u001a\u00020\u0002*\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00010\u00000\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lcom/finogeeks/lib/applet/modules/ext/AnkoAsyncContext;", "Lcom/finogeeks/lib/applet/api/media/ImageModuleHandler;", "Llg0/e0;", "invoke", "(Lcom/finogeeks/lib/applet/modules/ext/AnkoAsyncContext;)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
public static final class C0077a extends kotlin.jvm.internal.p implements ah0.l<C0326b<C0326b<ImageModuleHandler>>, e0> {
public static final class RunnableC0078a implements Runnable {
public RunnableC0078a() {
}
@Override
public final void run() {
if (ImageModuleHandler.this.h) {
return;
}
a aVar = a.this;
if (aVar.c.a) {
AnkoAsyncContext.this.h.onSuccess(new JSONObject().put(ImageEditeActivity.EXTRA_TEMP_FILE_PATH, AnkoAsyncContext.this.i));
} else {
CallbackHandlerKt.fail(AnkoAsyncContext.this.h, "decode image fail");
}
}
}
public C0077a() {
super(1);
}
public final void a(C0326b<C0326b<ImageModuleHandler>> c0326b) {
kotlin.jvm.internal.n.j(c0326b, "$receiver");
a aVar = a.this;
a0 a0Var = aVar.c;
AnkoAsyncContext ankoAsyncContext = AnkoAsyncContext.this;
String str = ankoAsyncContext.b;
String str2 = ankoAsyncContext.c;
kotlin.jvm.internal.n.e(str2, "saveFilePath");
AnkoAsyncContext ankoAsyncContext2 = AnkoAsyncContext.this;
a0Var.a = x.a(str, str2, ankoAsyncContext2.j, ankoAsyncContext2.k, ankoAsyncContext2.f, ankoAsyncContext2.g);
ImageModuleHandler.this.a.runOnUiThread(new RunnableC0078a());
}
public Object invoke(Object obj) {
a((C0326b) obj);
return e0.a;
}
}
public a(C0326b c0326b, a0 a0Var) {
this.b = c0326b;
this.c = a0Var;
}
@Override
public final void run() {
if (ImageModuleHandler.this.h) {
return;
}
if (this.c.a) {
AnkoAsyncContext.this.h.onSuccess(new JSONObject().put(ImageEditeActivity.EXTRA_TEMP_FILE_PATH, AnkoAsyncContext.this.i));
return;
}
AnkoAsyncContext ankoAsyncContext = AnkoAsyncContext.this;
if (ankoAsyncContext.d.a == ankoAsyncContext.j && ankoAsyncContext.e.a == ankoAsyncContext.k) {
CallbackHandlerKt.fail(ankoAsyncContext.h, "decode image fail");
} else {
FLog.d$default("ImageModuleHandler", "compressImage error, try original width/height compress again", null, 4, null);
com.finogeeks.lib.applet.modules.ext.d.a(this.b, null, new C0077a(), 1, null);
}
}
}
public AnkoAsyncContext(String str, String str2, d0 d0Var, d0 d0Var2, Bitmap.CompressFormat compressFormat, int i, ICallback iCallback, String str3, int i2, int i3) {
super(1);
this.b = str;
this.c = str2;
this.d = d0Var;
this.e = d0Var2;
this.f = compressFormat;
this.g = i;
this.h = iCallback;
this.i = str3;
this.j = i2;
this.k = i3;
}
public final void a(C0326b<ImageModuleHandler> c0326b) {
kotlin.jvm.internal.n.j(c0326b, "$receiver");
a0 a0Var = new a0();
String str = this.b;
String str2 = this.c;
kotlin.jvm.internal.n.e(str2, "saveFilePath");
a0Var.a = x.a(str, str2, this.d.a, this.e.a, this.f, this.g);
ImageModuleHandler.this.a.runOnUiThread(new a(c0326b, a0Var));
}
public Object invoke(Object obj) {
a((C0326b) obj);
return e0.a;
}
}
public static final class g extends kotlin.jvm.internal.p implements ah0.a<ContentResolver> {
public g() {
super(0);
}
public final ContentResolver m104invoke() {
return ImageModuleHandler.this.a.getContentResolver();
}
}
public static final class h implements Runnable {
final ICallback a;
final JSONObject b;
public h(ICallback iCallback, JSONObject jSONObject) {
this.a = iCallback;
this.b = jSONObject;
}
@Override
public final void run() {
this.a.onSuccess(this.b);
}
}
public static final class i implements Runnable {
final ICallback a;
public i(ICallback iCallback) {
this.a = iCallback;
}
@Override
public final void run() {
this.a.onFail();
}
}
public static final class j implements Runnable {
final List b;
final ICallback c;
public j(List list, ICallback iCallback) {
this.b = list;
this.c = iCallback;
}
@Override
public final void run() {
ImageModuleHandler.this.a((List<FileInfo>) this.b, this.c);
}
}
public static final class k implements Runnable {
final ICallback b;
public k(ICallback iCallback) {
this.b = iCallback;
}
@Override
public final void run() {
ImageModuleHandler imageModuleHandler = ImageModuleHandler.this;
imageModuleHandler.a((List<FileInfo>) mg0.o.d(imageModuleHandler.c), this.b);
}
}
public static final class l extends kotlin.jvm.internal.p implements ah0.a<e0> {
final JSONObject b;
final ICallback c;
public l(JSONObject jSONObject, ICallback iCallback) {
super(0);
this.b = jSONObject;
this.c = iCallback;
}
public Object invoke() {
m105invoke();
return e0.a;
}
public final void m105invoke() {
if (com.finogeeks.lib.applet.modules.ext.p.a(this.b)) {
this.c.onFail();
return;
}
String optString = this.b.optString(ImageEditeActivity.EXTRA_FILE_PATH);
if (optString == null || t.y(optString)) {
this.c.onFail();
return;
}
File localFile = ImageModuleHandler.this.b().getLocalFile(ImageModuleHandler.this.a, optString);
if (localFile == null || !localFile.exists()) {
this.c.onFail();
return;
}
String d = com.finogeeks.lib.applet.utils.r.d(ImageModuleHandler.this.a, Uri.fromFile(localFile));
if (d == null || t.y(d) || !t.L(d, "image/", false, 2, (Object) null)) {
this.c.onFail();
return;
}
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "/Camera");
if (!file.exists()) {
file.mkdirs();
}
if (c0.a(localFile, (Context) ImageModuleHandler.this.a, c1.IMAGE, String.valueOf(System.currentTimeMillis()) + com.finogeeks.lib.applet.utils.r.d(optString), Environment.DIRECTORY_DCIM, "Camera") != null) {
this.c.onSuccess(null);
} else {
this.c.onFail();
}
}
}
public static final class m extends kotlin.jvm.internal.p implements ah0.a<e0> {
final AppletScopeManager a;
final ScopeRequest b;
final l c;
public m(AppletScopeManager appletScopeManager, ScopeRequest scopeRequest, l lVar) {
super(0);
this.a = appletScopeManager;
this.b = scopeRequest;
this.c = lVar;
}
public Object invoke() {
m106invoke();
return e0.a;
}
public final void m106invoke() {
this.a.authResultCallback(((AppletScopeBean) mg0.x.k0(this.b.getRequestScopeList())).getScope(), true);
this.c.m105invoke();
}
}
public static final class n extends kotlin.jvm.internal.p implements ah0.l<String[], e0> {
final AppletScopeManager a;
final ScopeRequest b;
final ICallback c;
final String d;
public n(AppletScopeManager appletScopeManager, ScopeRequest scopeRequest, ICallback iCallback, String str) {
super(1);
this.a = appletScopeManager;
this.b = scopeRequest;
this.c = iCallback;
this.d = str;
}
public final void a(String[] strArr) {
kotlin.jvm.internal.n.j(strArr, "it");
this.a.authResultCallback(((AppletScopeBean) mg0.x.k0(this.b.getRequestScopeList())).getScope(), false);
CallbackHandlerKt.unauthorized(this.c, this.d, strArr);
}
public Object invoke(Object obj) {
a((String[]) obj);
return e0.a;
}
}
public static final class o extends kotlin.jvm.internal.p implements ah0.a<e0> {
final AppletScopeManager a;
final ScopeRequest b;
final ICallback c;
final String d;
public o(AppletScopeManager appletScopeManager, ScopeRequest scopeRequest, ICallback iCallback, String str) {
super(0);
this.a = appletScopeManager;
this.b = scopeRequest;
this.c = iCallback;
this.d = str;
}
public Object invoke() {
m107invoke();
return e0.a;
}
public final void m107invoke() {
this.a.authResultCallback(((AppletScopeBean) mg0.x.k0(this.b.getRequestScopeList())).getScope(), false);
CallbackHandlerKt.disableAuthorized(this.c, this.d);
}
}
public static final class p extends kotlin.jvm.internal.p implements ah0.a<AppletStoreDirProvider> {
public p() {
super(0);
}
public final AppletStoreDirProvider m108invoke() {
return AppletStoreDirProvider.INSTANCE.createByAppConfig(ImageModuleHandler.this.a, ImageModuleHandler.this.b());
}
}
public static final class q extends kotlin.jvm.internal.p implements ah0.a<AppletTempDirProvider> {
public q() {
super(0);
}
public final AppletTempDirProvider m109invoke() {
return AppletTempDirProvider.INSTANCE.createByAppConfig(ImageModuleHandler.this.a, ImageModuleHandler.this.b());
}
}
public static final class r extends kotlin.jvm.internal.p implements ah0.a<AppletUsrDirProvider> {
public r() {
super(0);
}
public final AppletUsrDirProvider m110invoke() {
return AppletUsrDirProvider.INSTANCE.createByAppConfig(ImageModuleHandler.this.a, ImageModuleHandler.this.b());
}
}
static {
new a(null);
}
public ImageModuleHandler(Host host) {
kotlin.jvm.internal.n.j(host, "host");
this.l = host;
this.a = host.getK();
this.b = host.getAppId();
this.e = Executors.newSingleThreadExecutor();
this.f = lg0.i.a(new g());
this.i = lg0.i.a(new b());
lg0.i.a(new r());
this.j = lg0.i.a(new q());
this.k = lg0.i.a(new p());
}
private final File a(File file) {
String name = file.getName();
kotlin.jvm.internal.n.e(name, "file.name");
String b2 = s.b(name);
if (!t.y(b2)) {
if (t.v(b2, "png", true)) {
com.finogeeks.lib.applet.modules.ext.n.a(file.getAbsolutePath(), file.getAbsolutePath(), Bitmap.CompressFormat.PNG, 524288L);
return file;
}
if (t.v(b2, "jpg", true) || t.v(b2, "jpeg", true)) {
com.finogeeks.lib.applet.modules.ext.n.a(file.getAbsolutePath(), file.getAbsolutePath(), Bitmap.CompressFormat.JPEG, 524288L);
return file;
}
}
return file;
}
public final void a(String str, SafetyApi.b bVar) {
com.finogeeks.lib.applet.utils.d0.a.a(this.a, this.g > 1, 1017, null, new d(bVar, str));
}
public final void a(String str, String str2, SafetyApi.b bVar) {
AppletScopeManager appletScopeManager = new AppletScopeManager(this.a, this.b);
ScopeRequest scopeRequest = new ScopeRequest();
scopeRequest.addScope(AppletScopeBean.SCOPE_CAMERA);
appletScopeManager.requestScope(this.l, scopeRequest, new e(appletScopeManager, str2, bVar, str));
}
public final void a(List<FileInfo> list, ICallback iCallback) {
ICallback iCallback2;
ImageModuleHandler imageModuleHandler;
JSONObject jSONObject;
Iterator<FileInfo> it;
String str;
File file;
File file2;
ImageModuleHandler imageModuleHandler2 = this;
List<FileInfo> list2 = list;
String str2 = "dstFile.absolutePath";
int i2 = 4;
FLog.d$default("ImageModuleHandler", "handleResult photos: " + list2, null, 4, null);
JSONArray jSONArray = new JSONArray();
JSONArray jSONArray2 = new JSONArray();
int i3 = imageModuleHandler2.g;
if (i3 > 0) {
list2 = mg0.x.S0(list2, i3);
}
try {
Iterator<FileInfo> it2 = list2.iterator();
while (it2.hasNext()) {
try {
FileInfo next = it2.next();
if (next != null) {
Uri uri = next.getUri();
String path = next.getPath();
if (uri != null) {
if (path == null || t.y(path)) {
it = it2;
str = str2;
} else {
JSONObject jSONObject2 = new JSONObject();
String d2 = com.finogeeks.lib.applet.utils.r.d(path);
FLog.d$default("ImageModuleHandler", "handleResult ext: " + d2, null, i2, null);
if (d2 == null || t.y(d2)) {
String d3 = com.finogeeks.lib.applet.utils.r.d(imageModuleHandler2.a, uri);
FLog.d$default("ImageModuleHandler", "handleResult mimeType: " + d3, null, i2, null);
if (d3 != null) {
switch (d3.hashCode()) {
case -1487394660:
d3.equals("image/jpeg");
break;
case -1487103447:
if (d3.equals("image/tiff")) {
d2 = ".tif";
break;
}
break;
case -1487018032:
if (d3.equals("image/webp")) {
d2 = ".webp";
break;
}
break;
case -879272239:
if (d3.equals("image/bmp")) {
d2 = ".bmp";
break;
}
break;
case -879267568:
if (d3.equals("image/gif")) {
d2 = ".gif";
break;
}
break;
case -879258763:
if (d3.equals("image/png")) {
d2 = ".png";
break;
}
break;
case -227171396:
if (d3.equals("image/svg+xml")) {
d2 = ".svg";
break;
}
break;
case 1146342924:
if (d3.equals("image/x-ico")) {
d2 = ".ico";
break;
}
break;
}
}
d2 = ".jpg";
}
StringBuilder sb = new StringBuilder();
sb.append("tmp_");
sb.append(com.finogeeks.lib.applet.utils.a0.a("chooseImage_" + path));
sb.append(d2);
File file3 = new File(imageModuleHandler2.e().getDirForWrite(), sb.toString());
boolean a2 = com.finogeeks.lib.applet.utils.r.a(imageModuleHandler2.c().openInputStream(uri), file3.getAbsolutePath());
FLog.d$default("ImageModuleHandler", "handleResult copy result=" + a2, null, 4, null);
if (a2) {
it = it2;
long length = file3.length();
FLog.d$default("ImageModuleHandler", "handleResult compressWhenChooseImage : " + imageModuleHandler2.d, null, 4, null);
if (imageModuleHandler2.d) {
float c2 = com.finogeeks.lib.applet.modules.ext.n.c(file3);
file2 = imageModuleHandler2.a(file3);
String absolutePath = file2.getAbsolutePath();
kotlin.jvm.internal.n.e(absolutePath, str2);
file = file3;
String absolutePath2 = file2.getAbsolutePath();
kotlin.jvm.internal.n.e(absolutePath2, str2);
com.finogeeks.lib.applet.modules.ext.n.a(absolutePath, absolutePath2, c2);
} else {
file = file3;
file2 = file;
}
long length2 = file2.length();
StringBuilder sb2 = new StringBuilder();
str = str2;
sb2.append("result: file:");
sb2.append(file.getAbsolutePath());
sb2.append(" dstFile:");
sb2.append(file2.getAbsolutePath());
FLog.d$default("ImageModuleHandler", sb2.toString(), null, 4, null);
FLog.d$default("ImageModuleHandler", "result: size:" + length + " dstSize:" + length2, null, 4, null);
FLog.d$default("ImageModuleHandler", "handleResult tempFilePaths1=" + jSONArray + " destFile=" + file2, null, 4, null);
StringBuilder sb3 = new StringBuilder();
sb3.append(FinFileResourceUtil.SCHEME);
sb3.append(file2.getName());
jSONArray.put(sb3.toString());
FLog.d$default("ImageModuleHandler", "handleResult tempFilePaths2=" + jSONArray, null, 4, null);
jSONObject2.put("path", FinFileResourceUtil.SCHEME + file2.getName());
jSONObject2.put("size", com.finogeeks.lib.applet.utils.r.c(file2.getAbsolutePath()));
} else {
it = it2;
str = str2;
jSONArray.put("file:" + path);
jSONObject2.put("path", "file:" + path);
jSONObject2.put("size", com.finogeeks.lib.applet.utils.r.c(path));
}
jSONArray2.put(jSONObject2);
}
it2 = it;
str2 = str;
i2 = 4;
}
imageModuleHandler2 = this;
}
} catch (Exception unused) {
imageModuleHandler = this;
iCallback2 = iCallback;
FLog.e$default("ImageModuleHandler", "chooseImage assemble result exception!", null, 4, null);
imageModuleHandler.a.runOnUiThread(new i(iCallback2));
}
}
jSONObject = new JSONObject();
jSONObject.put("tempFilePaths", jSONArray);
jSONObject.put("tempFiles", jSONArray2);
imageModuleHandler = this;
} catch (Exception unused2) {
iCallback2 = iCallback;
imageModuleHandler = imageModuleHandler2;
}
try {
iCallback2 = iCallback;
try {
imageModuleHandler.a.runOnUiThread(new h(iCallback2, jSONObject));
} catch (Exception unused3) {
FLog.e$default("ImageModuleHandler", "chooseImage assemble result exception!", null, 4, null);
imageModuleHandler.a.runOnUiThread(new i(iCallback2));
}
} catch (Exception unused4) {
iCallback2 = iCallback;
FLog.e$default("ImageModuleHandler", "chooseImage assemble result exception!", null, 4, null);
imageModuleHandler.a.runOnUiThread(new i(iCallback2));
}
}
public final AppConfig b() {
lg0.h hVar = this.i;
hh0.l lVar = m[1];
return (AppConfig) hVar.getValue();
}
private final ContentResolver c() {
lg0.h hVar = this.f;
hh0.l lVar = m[0];
return (ContentResolver) hVar.getValue();
}
private final AppletStoreDirProvider d() {
lg0.h hVar = this.k;
hh0.l lVar = m[4];
return (AppletStoreDirProvider) hVar.getValue();
}
public final AppletTempDirProvider e() {
lg0.h hVar = this.j;
hh0.l lVar = m[3];
return (AppletTempDirProvider) hVar.getValue();
}
public final void a() {
this.h = true;
}
public final void a(int i2, int i3, Intent intent, ICallback iCallback) {
List list;
kotlin.jvm.internal.n.j(iCallback, "callback");
if (i3 != -1) {
CallbackHandlerKt.cancelAsFail(iCallback);
}
switch (i2) {
case 1017:
if (intent == null) {
iCallback.onFail();
break;
} else {
ClipData clipData = intent.getClipData();
if (clipData == null) {
list = mg0.o.d(new FileInfo(intent.getData(), com.finogeeks.lib.applet.utils.r.e(this.a, intent.getData())));
} else {
int itemCount = clipData.getItemCount();
ArrayList arrayList = new ArrayList(itemCount);
for (int i4 = 0; i4 < itemCount; i4++) {
ClipData.Item itemAt = clipData.getItemAt(i4);
kotlin.jvm.internal.n.e(itemAt, "clipData.getItemAt(it)");
Uri uri = itemAt.getUri();
arrayList.add(new FileInfo(uri, com.finogeeks.lib.applet.utils.r.e(this.a, uri)));
}
list = arrayList;
}
this.e.execute(new j(list, iCallback));
break;
}
case 1018:
Photo a2 = com.finogeeks.lib.applet.f.a.easyphotos.c.a.a(intent);
if (a2 == null) {
iCallback.onFail();
break;
} else {
File file = new File(a2.path);
this.c = new FileInfo(Build.VERSION.SDK_INT >= 24 ? com.finogeeks.lib.applet.utils.r.a((Context) this.a, file) : Uri.fromFile(file), file.getAbsolutePath());
this.e.execute(new k(iCallback));
break;
}
case 1019:
if (intent == null) {
iCallback.onFail();
break;
} else {
String stringExtra = intent.getStringExtra(ImageEditeActivity.EXTRA_TEMP_FILE_PATH);
if (stringExtra != null && !t.y(stringExtra)) {
iCallback.onSuccess(new JSONObject().put(ImageEditeActivity.EXTRA_TEMP_FILE_PATH, stringExtra));
break;
} else {
iCallback.onFail();
break;
}
}
default:
CallbackHandlerKt.cancelAsFail(iCallback);
break;
}
}
public final void a(String str, JSONObject jSONObject, SafetyApi.b bVar) {
kotlin.jvm.internal.n.j(str, FinFileResourceUtil.KEY_EVENT);
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(bVar, "callback");
JSONArray optJSONArray = jSONObject.optJSONArray("sourceType");
if (optJSONArray == null) {
bVar.onFail();
return;
}
int length = optJSONArray.length();
if (length < 1) {
bVar.onFail();
return;
}
JSONArray optJSONArray2 = jSONObject.optJSONArray("sizeType");
this.d = (optJSONArray2 != null && optJSONArray2.length() == 1 && kotlin.jvm.internal.n.d(optJSONArray2.get(0), "original")) ? false : true;
this.g = jSONObject.optInt("count", 9);
String optString = jSONObject.optString(UserMessageType.CAMERA, CameraParams.DEVICE_POSITION_FACING_BACK);
if (length == 1) {
if (kotlin.jvm.internal.n.d(optJSONArray.optString(0), "album")) {
a(str, bVar);
return;
} else {
kotlin.jvm.internal.n.e(optString, UserMessageType.CAMERA);
a(str, optString, bVar);
return;
}
}
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 < length; i2++) {
String optString2 = optJSONArray.optString(i2);
if (kotlin.jvm.internal.n.d("album", optString2)) {
FragmentActivity fragmentActivity = this.a;
arrayList.add(new BottomSheetMenuItem((Context) fragmentActivity, i2, (CharSequence) fragmentActivity.getString(R.string.fin_applet_album), (Drawable) null));
} else if (kotlin.jvm.internal.n.d(UserMessageType.CAMERA, optString2)) {
FragmentActivity fragmentActivity2 = this.a;
arrayList.add(new BottomSheetMenuItem((Context) fragmentActivity2, i2, (CharSequence) fragmentActivity2.getString(R.string.fin_applet_camera), (Drawable) null));
}
}
FragmentActivity fragmentActivity3 = this.a;
arrayList.add(new BottomSheetMenuItem((Context) fragmentActivity3, length, (CharSequence) fragmentActivity3.getString(R.string.fin_applet_cancel), (Drawable) null));
new BottomSheet.Builder(this.a, ThemeModeUtil.getBottomSheetStyle(this.l.getFinAppConfig().getUiConfig(), this.a)).setMenuItems(arrayList).setListener(new c(str, bVar, optString)).show();
}
public final void a(String str, JSONObject jSONObject, ICallback iCallback) {
String str2;
String str3;
kotlin.jvm.internal.n.j(str, "editeMode");
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(iCallback, "callback");
String optString = jSONObject.optString("src");
kotlin.jvm.internal.n.e(optString, "src");
if (optString.length() == 0) {
Event event = iCallback.getEvent();
kotlin.jvm.internal.n.e(event, "callback.event");
String name = event.getName();
kotlin.jvm.internal.n.e(name, "callback.event.name");
iCallback.onFail(CallbackHandlerKt.apiFail(name, "parameter error: parameter.src should be not empty string"));
return;
}
if (s.f(optString)) {
Event event2 = iCallback.getEvent();
kotlin.jvm.internal.n.e(event2, "callback.event");
String name2 = event2.getName();
kotlin.jvm.internal.n.e(name2, "callback.event.name");
iCallback.onFail(CallbackHandlerKt.apiFail(name2, ":Parse imageUrl fail, maybe imageUrl is illegal?"));
return;
}
if (t.L(optString, FinFileResourceUtil.SCHEME, false, 2, (Object) null)) {
str2 = AbsAppletDirProvider.INSTANCE.convertFinFilePath(this.a, b(), optString);
} else {
str2 = b().getMiniAppSourcePath(this.a) + u.t0(optString, "/");
}
String str4 = str2;
File file = new File(str4);
if (!file.exists() && com.finogeeks.lib.applet.m.a.a.a(this.b)) {
file = b1.c(this.l, str4);
kotlin.jvm.internal.n.e(file, "StreamLoadUtil.getStream…etResPath(host, filePath)");
}
if (!file.exists()) {
Event event3 = iCallback.getEvent();
kotlin.jvm.internal.n.e(event3, "callback.event");
String name3 = event3.getName();
kotlin.jvm.internal.n.e(name3, "callback.event.name");
iCallback.onFail(CallbackHandlerKt.apiFail(name3, ":Parse imageUrl fail, maybe imageUrl is illegal?"));
return;
}
if (!com.finogeeks.lib.applet.utils.r.i(str4)) {
Event event4 = iCallback.getEvent();
kotlin.jvm.internal.n.e(event4, "callback.event");
String name4 = event4.getName();
kotlin.jvm.internal.n.e(name4, "callback.event.name");
iCallback.onFail(CallbackHandlerKt.apiFail(name4, "image invalid"));
return;
}
FLog.d$default("ImageModuleHandler", "editImage filePath:" + str4, null, 4, null);
if (kotlin.jvm.internal.n.d(str, ImageEditeActivity.EDITE_MODE_FIXED_CROP)) {
str3 = jSONObject.optString("cropScale");
kotlin.jvm.internal.n.e(str3, "param.optString(\"cropScale\")");
if (str3.length() == 0) {
str3 = ImageEditeActivity.EDITE_FIXED_SIZE_1X1;
}
if (!ImageEditeActivity.INSTANCE.getSupportFixedSize().contains(str3)) {
Event event5 = iCallback.getEvent();
kotlin.jvm.internal.n.e(event5, "callback.event");
String name5 = event5.getName();
kotlin.jvm.internal.n.e(name5, "callback.event.name");
iCallback.onFail(CallbackHandlerKt.apiFail(name5, "invalid cropScale"));
return;
}
} else {
str3 = "";
}
String str5 = str3;
FragmentActivity fragmentActivity = this.a;
String str6 = this.b;
String absolutePath = e().getDirForWrite().getAbsolutePath();
kotlin.jvm.internal.n.e(absolutePath, "tempDirProvider.getDirForWrite().absolutePath");
IntentsKt.a(fragmentActivity, 1019, str6, str4, absolutePath, str, str5);
}
public final void a(String str, JSONObject jSONObject, AppletScopeManager appletScopeManager, ScopeRequest scopeRequest, ICallback iCallback) {
kotlin.jvm.internal.n.j(str, FinFileResourceUtil.KEY_EVENT);
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(appletScopeManager, "scopeManager");
kotlin.jvm.internal.n.j(scopeRequest, "scopeRequest");
kotlin.jvm.internal.n.j(iCallback, "callback");
C0325a.a((Activity) this.a, (ah0.a<e0>) new m(appletScopeManager, scopeRequest, new l(jSONObject, iCallback)), (ah0.l<? super String[], e0>) new n(appletScopeManager, scopeRequest, iCallback, str), (ah0.a<e0>) new o(appletScopeManager, scopeRequest, iCallback, str));
}
public final void a(JSONObject jSONObject, ICallback iCallback) {
String str;
String str2;
String str3;
Bitmap.CompressFormat compressFormat;
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(iCallback, "callback");
String optString = jSONObject.optString("src");
kotlin.jvm.internal.n.e(optString, "src");
if (t.L(optString, FinFileResourceUtil.SCHEME, false, 2, (Object) null)) {
str = AbsAppletDirProvider.INSTANCE.convertFinFilePath(this.a, b(), optString);
} else {
str = b().getMiniAppSourcePath(this.a) + u.t0(optString, "/");
}
File file = new File(str);
if (!file.exists() && com.finogeeks.lib.applet.m.a.a.a(this.b)) {
file = b1.c(this.l, str);
kotlin.jvm.internal.n.e(file, "StreamLoadUtil.getStream…etResPath(host, filePath)");
}
if (!file.exists()) {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("errMsg", "compressImage:fail:file doesn't exist");
iCallback.onFail(jSONObject2);
return;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(str, options);
int i2 = options.outWidth;
int i3 = options.outHeight;
if (i2 <= 0 || i3 <= 0) {
FLog.w$default("ImageModuleHandler", "compressImage error, image width:" + i2 + " height:" + i3, null, 4, null);
CallbackHandlerKt.fail(iCallback, "decode image fail");
return;
}
d0 d0Var = new d0();
d0Var.a = i2;
d0 d0Var2 = new d0();
d0Var2.a = i3;
int max = Math.max(jSONObject.optInt("compressedWidth"), 0);
int max2 = Math.max(jSONObject.optInt("compressedHeight"), 0);
if (max == 0 && max2 == 0) {
d0Var.a = i2;
d0Var2.a = i3;
} else if (max > 0 && max2 > 0) {
d0Var.a = max;
d0Var2.a = max2;
} else if (max > 0) {
d0Var.a = max;
d0Var2.a = (int) Math.ceil((max * i3) / i2);
} else if (max2 > 0) {
d0Var2.a = max2;
d0Var.a = (int) Math.ceil((max2 * i2) / i3);
}
StringBuilder sb = new StringBuilder();
sb.append("tmp_");
sb.append(com.finogeeks.lib.applet.utils.a0.a("compressImage_" + str + '_' + System.currentTimeMillis()));
String sb2 = sb.toString();
String str4 = options.outMimeType;
if (str4 != null) {
Locale locale = Locale.getDefault();
kotlin.jvm.internal.n.e(locale, "Locale.getDefault()");
str2 = str4.toLowerCase(locale);
kotlin.jvm.internal.n.e(str2, "(this as java.lang.String).toLowerCase(locale)");
} else {
str2 = null;
}
if (kotlin.jvm.internal.n.d(str2, "image/png") || kotlin.jvm.internal.n.d(str2, "image/gif")) {
str3 = sb2 + ".png";
compressFormat = Bitmap.CompressFormat.PNG;
} else {
str3 = sb2 + ".jpg";
compressFormat = Bitmap.CompressFormat.JPEG;
}
String str5 = str;
com.finogeeks.lib.applet.modules.ext.d.a(this, null, new AnkoAsyncContext(str5, new File(e().getDirForWrite(), str3).getAbsolutePath(), d0Var, d0Var2, compressFormat, jSONObject.optInt("quality", 80), iCallback, FinFileResourceUtil.SCHEME + str3, i2, i3), 1, null);
}
public final void b(JSONObject jSONObject, ICallback iCallback) {
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(iCallback, "callback");
String optString = jSONObject.optString("path");
if (optString == null || t.y(optString)) {
iCallback.onFail();
return;
}
File localFile = b().getLocalFile(this.a, optString);
if (!localFile.exists()) {
iCallback.onFail(new JSONObject().put("errMsg", "The picture doesn't exist, path:" + optString));
return;
}
String b2 = s.b(optString);
if (t.y(b2)) {
b2 = "*";
}
JSONObject jSONObject2 = new JSONObject();
StringBuilder sb = new StringBuilder();
sb.append("data:image/");
sb.append(b2);
sb.append(";base64,");
kotlin.jvm.internal.n.e(localFile, "file");
sb.append(com.finogeeks.lib.applet.modules.ext.n.g(localFile));
iCallback.onSuccess(jSONObject2.put("localData", sb.toString()));
}
public final void c(JSONObject jSONObject, ICallback iCallback) {
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(iCallback, "callback");
String optString = jSONObject.optString("current", "");
JSONArray optJSONArray = jSONObject.optJSONArray("urls");
if (optJSONArray == null || optJSONArray.length() == 0) {
FLog.w$default("ImageModuleHandler", "urls is null", null, 4, null);
iCallback.onFail();
return;
}
boolean optBoolean = jSONObject.optBoolean("showmenu", true);
int length = optJSONArray.length();
ArrayList arrayList = new ArrayList(length);
int i2 = 0;
for (int i3 = 0; i3 < length; i3++) {
String optString2 = optJSONArray.optString(i3);
if (!TextUtils.isEmpty(optString2)) {
if (kotlin.jvm.internal.n.d(optString2, optString)) {
i2 = i3;
}
kotlin.jvm.internal.n.e(optString2, "uriString");
if (t.L(optString2, "finfile://usr/", false, 2, (Object) null)) {
optString2 = b().getLocalFileAbsolutePath(this.a, optString2);
} else if (t.L(optString2, FinFileResourceUtil.SCHEME, false, 2, (Object) null)) {
optString2 = AbsAppletDirProvider.INSTANCE.convertFinFilePath(this.a, b(), optString2);
} else if (com.finogeeks.lib.applet.utils.j.a(optString2)) {
StringBuilder sb = new StringBuilder();
sb.append("tmp_");
sb.append(com.finogeeks.lib.applet.utils.a0.a("previewImage_" + optString2));
File a2 = com.finogeeks.lib.applet.utils.j.a(com.finogeeks.lib.applet.utils.j.b(optString2), new File(e().getDirForWrite(), sb.toString()).getAbsolutePath());
optString2 = a2 != null ? a2.getAbsolutePath() : null;
} else if (!s.f(optString2)) {
File miniAppSourcePendingFile = b().getMiniAppSourcePendingFile(this.a, optString2);
if (miniAppSourcePendingFile.exists()) {
kotlin.jvm.internal.n.e(miniAppSourcePendingFile, "sourceFile");
optString2 = miniAppSourcePendingFile.getAbsolutePath();
} else if (com.finogeeks.lib.applet.m.a.a.a(this.b)) {
File c2 = b1.c(this.l, optString2);
if (c2.exists()) {
kotlin.jvm.internal.n.e(c2, "sourceFile");
optString2 = c2.getAbsolutePath();
} else {
File file = new File(optString2);
if (file.exists()) {
optString2 = file.getAbsolutePath();
}
}
} else {
File file2 = new File(optString2);
if (file2.exists()) {
optString2 = file2.getAbsolutePath();
}
}
}
if (optString2 != null && (s.f(optString2) || new File(optString2).exists())) {
arrayList.add(optString2);
}
}
}
if (arrayList.isEmpty()) {
iCallback.onFail(CallbackHandlerKt.apiFail("previewImage", "No medias, sources may not exist."));
return;
}
ArrayList arrayList2 = new ArrayList();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
arrayList2.add(new MediaViewerData(1, (String) it.next(), optBoolean));
}
FragmentActivity fragmentActivity = this.a;
String str = this.b;
String absolutePath = d().getDirForWrite().getAbsolutePath();
kotlin.jvm.internal.n.e(absolutePath, "storeDirProvider.getDirForWrite().absolutePath");
IntentsKt.a((Activity) fragmentActivity, str, arrayList2, i2, absolutePath, (View) null, 16, (Object) null);
iCallback.onSuccess(null);
}
public final void d(JSONObject jSONObject, ICallback iCallback) {
String str;
kotlin.jvm.internal.n.j(jSONObject, "param");
kotlin.jvm.internal.n.j(iCallback, "callback");
JSONArray optJSONArray = jSONObject.optJSONArray("sources");
if (optJSONArray == null) {
iCallback.onFail();
return;
}
int length = optJSONArray.length();
if (length < 1) {
iCallback.onFail();
return;
}
boolean optBoolean = jSONObject.optBoolean("showmenu", true);
int optInt = jSONObject.optInt("current");
ArrayList arrayList = new ArrayList();
boolean z10 = false;
int i2 = 0;
while (i2 < length) {
Object obj = optJSONArray.get(i2);
if (!(obj instanceof JSONObject)) {
obj = null;
}
JSONObject jSONObject2 = (JSONObject) obj;
if (jSONObject2 != null) {
String optString = jSONObject2.optString("url");
String optString2 = jSONObject2.optString("type", "image");
String optString3 = jSONObject2.optString("poster");
kotlin.jvm.internal.n.e(optString, "url");
if (t.L(optString, FinFileResourceUtil.SCHEME, z10, 2, (Object) null)) {
str = AbsAppletDirProvider.INSTANCE.convertFinFilePath(this.a, b(), optString);
} else if (com.finogeeks.lib.applet.utils.j.a(optString)) {
StringBuilder sb = new StringBuilder();
sb.append("tmp_");
sb.append(com.finogeeks.lib.applet.utils.a0.a("previewMedia_" + optString));
File a2 = com.finogeeks.lib.applet.utils.j.a(com.finogeeks.lib.applet.utils.j.b(optString), new File(e().getDirForWrite(), sb.toString()).getAbsolutePath());
str = s.g(a2 != null ? a2.getAbsolutePath() : null);
} else {
if (optString.length() != 0) {
if (s.f(optString)) {
str = optString;
} else {
File miniAppSourcePendingFile = b().getMiniAppSourcePendingFile(this.a, optString);
if (!miniAppSourcePendingFile.exists() && com.finogeeks.lib.applet.m.a.a.a(this.b)) {
miniAppSourcePendingFile = b1.c(this.l, optString);
}
if (miniAppSourcePendingFile.exists()) {
kotlin.jvm.internal.n.e(miniAppSourcePendingFile, "sourceFile");
str = miniAppSourcePendingFile.getAbsolutePath();
} else {
File file = new File(optString);
if (file.exists()) {
str = file.getAbsolutePath();
}
}
}
}
str = null;
}
if (str != null && (s.f(str) || new File(str).exists())) {
arrayList.add(new MediaViewerData(kotlin.jvm.internal.n.d(optString2, "image") ? 1 : 2, str, optString3, optBoolean));
}
}
i2++;
z10 = false;
}
if (arrayList.isEmpty()) {
iCallback.onFail(CallbackHandlerKt.apiFail("previewMedia", "No medias, sources may not exist."));
return;
}
FragmentActivity fragmentActivity = this.a;
String str2 = this.b;
String absolutePath = d().getDirForWrite().getAbsolutePath();
kotlin.jvm.internal.n.e(absolutePath, "storeDirProvider.getDirForWrite().absolutePath");
IntentsKt.a((Activity) fragmentActivity, str2, arrayList, optInt, absolutePath, (View) null, 16, (Object) null);
iCallback.onSuccess(null);
}
}