Merge branch 'master' into X5

# Conflicts:
#	android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java
#	lib/mop.dart
master
zhongweiguang 2023-03-24 11:18:27 +08:00
commit 484a2878b2
13 changed files with 1349 additions and 126 deletions

View File

@ -8,6 +8,7 @@ import com.finogeeks.mop.api.mop.AppletManageModule;
import com.finogeeks.mop.api.mop.AppletModule; import com.finogeeks.mop.api.mop.AppletModule;
import com.finogeeks.mop.api.mop.BaseModule; import com.finogeeks.mop.api.mop.BaseModule;
import com.finogeeks.mop.api.mop.ExtensionApiModule; import com.finogeeks.mop.api.mop.ExtensionApiModule;
import com.finogeeks.mop.api.mop.InitSDKModule;
import com.finogeeks.mop.api.mop.VersionModule; import com.finogeeks.mop.api.mop.VersionModule;
import com.finogeeks.mop.api.mop.SmSignModule; import com.finogeeks.mop.api.mop.SmSignModule;
import com.finogeeks.mop.api.mop.WXQrCodeModule; import com.finogeeks.mop.api.mop.WXQrCodeModule;
@ -65,6 +66,7 @@ public class ApisManager {
} }
private void initSdkApi(Activity activity) { private void initSdkApi(Activity activity) {
add(new InitSDKModule(activity));
add(new BaseModule(activity)); add(new BaseModule(activity));
add(new AppletModule(activity)); add(new AppletModule(activity));
add(new AppletManageModule(activity)); add(new AppletManageModule(activity));

View File

@ -4,17 +4,16 @@ import android.app.Application;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.finogeeks.lib.applet.BuildConfig;
import com.finogeeks.lib.applet.client.FinAppClient; import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig; import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.client.FinStoreConfig; import com.finogeeks.lib.applet.client.FinStoreConfig;
import com.finogeeks.lib.applet.interfaces.FinCallback; import com.finogeeks.lib.applet.interfaces.FinCallback;
import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.api.mop.util.InitUtils;
import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.interfaces.ICallback;
import com.finogeeks.mop.service.MopPluginService; import com.finogeeks.mop.service.MopPluginService;
import com.finogeeks.xlog.XLogLevel; import com.finogeeks.xlog.XLogLevel;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -22,7 +21,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class BaseModule extends BaseApi { public class BaseModule extends BaseApi {
private final static String TAG = BaseModule.class.getSimpleName(); private final static String TAG = "BaseModule";
public BaseModule(Context context) { public BaseModule(Context context) {
super(context); super(context);
@ -118,11 +117,9 @@ public class BaseModule extends BaseApi {
} }
} }
} }
FinAppConfig.UIConfig uiConfig = null;
if (param.get("uiConfig") != null) {
uiConfig = gson.fromJson(gson.toJson(param.get("uiConfig")), FinAppConfig.UIConfig.class);
}
// uiConfig
FinAppConfig.UIConfig uiConfig = InitUtils.createUIConfigFromMap((Map<Object, Object>) param.get("uiConfig"));
FinAppConfig.Builder builder = new FinAppConfig.Builder() FinAppConfig.Builder builder = new FinAppConfig.Builder()
.setSdkKey(appkey) .setSdkKey(appkey)
@ -137,11 +134,10 @@ public class BaseModule extends BaseApi {
.setBindAppletWithMainProcess(bindAppletWithMainProcess) .setBindAppletWithMainProcess(bindAppletWithMainProcess)
.setLogLevel(XLogLevel.LEVEL_VERBOSE) .setLogLevel(XLogLevel.LEVEL_VERBOSE)
.setXLogDir(new File(getContext().getExternalCacheDir(),"xlog")) .setXLogDir(new File(getContext().getExternalCacheDir(),"xlog"))
.setPageCountLimit(pageCountLimit)
.setUseLocalTbsCore(useLocalTbsCore) .setUseLocalTbsCore(useLocalTbsCore)
.setTbsCoreUrl(tbsCoreUrl); .setTbsCoreUrl(tbsCoreUrl);
// .setPageCountLimit(pageCountLimit);
if (customWebViewUserAgent != null) if (customWebViewUserAgent != null)
builder.setCustomWebViewUserAgent(customWebViewUserAgent); builder.setCustomWebViewUserAgent(customWebViewUserAgent);
if (appletIntervalUpdateLimit != null) if (appletIntervalUpdateLimit != null)

View File

@ -0,0 +1,215 @@
package com.finogeeks.mop.api.mop;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.client.FinAppConfigPriority;
import com.finogeeks.lib.applet.client.FinStoreConfig;
import com.finogeeks.lib.applet.interfaces.FinCallback;
import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.api.mop.util.InitUtils;
import com.finogeeks.mop.interfaces.ICallback;
import com.finogeeks.mop.service.MopPluginService;
import com.finogeeks.xlog.XLogLevel;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class InitSDKModule extends BaseApi {
private final static String TAG = "InitSDKModule";
public InitSDKModule(Context context) {
super(context);
}
@Override
public String[] apis() {
return new String[]{"initSDK"};
}
@Override
@SuppressWarnings("unchecked")
public void invoke(String event, Map param, ICallback callback) {
if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) {
//
return;
}
Log.d(TAG, "param:" + param);
FinAppConfig.Builder configBuilder = new FinAppConfig.Builder();
// config
Map<Object, Object> configMap = (Map<Object, Object>) param.get("config");
List<Map<Object, Object>> finStoreConfigs = (List<Map<Object, Object>>) configMap.get("finStoreConfigs");
List<FinStoreConfig> storeConfigs = new ArrayList<>();
for (Map<Object, Object> store : finStoreConfigs) {
String sdkKey = (String) store.get("sdkKey");
String sdkSecret = (String) store.get("sdkSecret");
String apiServer = (String) store.get("apiServer");
String apmServer = (String) store.get("apmServer");
if (apmServer == null) {
apmServer = "";
}
String fingerprint = (String) store.get("fingerprint");
if (fingerprint == null) {
fingerprint = "";
}
String cryptType = (String) store.get("cryptType");
Boolean encryptServerData = (Boolean) store.get("encryptServerData");
storeConfigs.add(new FinStoreConfig(sdkKey, sdkSecret, apiServer, apmServer, "",
fingerprint, cryptType, encryptServerData));
}
configBuilder.setFinStoreConfigs(storeConfigs);
String userId = (String) configMap.get("userId");
if (userId != null) {
configBuilder.setUserId(userId);
}
String productIdentification = (String) configMap.get("productIdentification");
if (productIdentification != null) {
configBuilder.setProductIdentification(productIdentification);
}
configBuilder.setDisableRequestPermissions((Boolean) configMap.get("disableRequestPermissions"));
configBuilder.setAppletAutoAuthorize((Boolean) configMap.get("appletAutoAuthorize"));
configBuilder.setDisableGetSuperviseInfo((Boolean) configMap.get("disableGetSuperviseInfo"));
configBuilder.setIgnoreWebviewCertAuth((Boolean) configMap.get("ignoreWebviewCertAuth"));
configBuilder.setAppletIntervalUpdateLimit((Integer) configMap.get("appletIntervalUpdateLimit"));
Map<String, Object> apmExtendInfo = (Map<String, Object>) configMap.get("apmExtendInfo");
if (apmExtendInfo != null) {
configBuilder.setApmExtendInfo(apmExtendInfo);
}
configBuilder.setEnableApmDataCompression((Boolean) configMap.get("enableApmDataCompression"));
configBuilder.setEncryptServerData((Boolean) configMap.get("encryptServerData"));
configBuilder.setEncryptServerData((Boolean) configMap.get("encryptServerData"));
int appletDebugModeIndex = (Integer) configMap.get("appletDebugMode");
if (appletDebugModeIndex == 0) {
configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeUndefined);
} else if (appletDebugModeIndex == 1) {
configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeEnable);
} else if (appletDebugModeIndex == 2) {
configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeDisable);
} else if (appletDebugModeIndex == 3) {
configBuilder.setAppletDebugMode(FinAppConfig.AppletDebugMode.appletDebugModeForbidden);
}
configBuilder.setEnableWatermark((Boolean) configMap.get("enableWatermark"));
int watermarkPriorityIndex = (Integer) configMap.get("watermarkPriority");
if (watermarkPriorityIndex == 0) {
configBuilder.setWatermarkPriority(FinAppConfigPriority.GLOBAL);
} else if (watermarkPriorityIndex == 1) {
configBuilder.setWatermarkPriority(FinAppConfigPriority.SPECIFIED);
} else if (watermarkPriorityIndex == 2) {
configBuilder.setWatermarkPriority(FinAppConfigPriority.APPLET_FILE);
}
Map<String, String> header = (Map<String, String>) configMap.get("header");
if (header != null) {
configBuilder.setHeader(header);
}
int headerPriorityIndex = (Integer) configMap.get("headerPriority");
if (headerPriorityIndex == 0) {
configBuilder.setHeaderPriority(FinAppConfigPriority.GLOBAL);
} else if (headerPriorityIndex == 1) {
configBuilder.setHeaderPriority(FinAppConfigPriority.SPECIFIED);
} else if (headerPriorityIndex == 2) {
configBuilder.setHeaderPriority(FinAppConfigPriority.APPLET_FILE);
}
configBuilder.setPageCountLimit((Integer) configMap.get("pageCountLimit"));
String[] schemes = (String[]) configMap.get("schemes");
if (schemes != null) {
configBuilder.setSchemes(schemes);
}
configBuilder.setDebugMode((Boolean) configMap.get("debug"));
Integer maxRunningApplet = (Integer) configMap.get("maxRunningApplet");
if (maxRunningApplet != null) {
configBuilder.setMaxRunningApplet(maxRunningApplet);
}
Integer webViewMixedContentMode = (Integer) configMap.get("webViewMixedContentMode");
if (webViewMixedContentMode != null) {
configBuilder.setWebViewMixedContentMode(webViewMixedContentMode);
}
configBuilder.setBindAppletWithMainProcess((Boolean) configMap.get("bindAppletWithMainProcess"));
String killAppletProcessNotice = (String) configMap.get("killAppletProcessNotice");
if (killAppletProcessNotice != null) {
configBuilder.setKillAppletProcessNotice(killAppletProcessNotice);
}
configBuilder.setMinAndroidSdkVersion((Integer) configMap.get("minAndroidSdkVersion"));
configBuilder.setEnableScreenShot((Boolean) configMap.get("enableScreenShot"));
int screenShotPriorityIndex = (Integer) configMap.get("screenShotPriority");
if (screenShotPriorityIndex == 0) {
configBuilder.setScreenShotPriority(FinAppConfigPriority.GLOBAL);
} else if (screenShotPriorityIndex == 1) {
configBuilder.setScreenShotPriority(FinAppConfigPriority.SPECIFIED);
} else if (screenShotPriorityIndex == 2) {
configBuilder.setScreenShotPriority(FinAppConfigPriority.APPLET_FILE);
}
int logLevelIndex = (Integer) configMap.get("logLevel");
if (logLevelIndex == 0) {
configBuilder.setLogLevel(XLogLevel.LEVEL_ERROR);
} else if (logLevelIndex == 1) {
configBuilder.setLogLevel(XLogLevel.LEVEL_WARNING);
} else if (logLevelIndex == 2) {
configBuilder.setLogLevel(XLogLevel.LEVEL_INFO);
} else if (logLevelIndex == 3) {
configBuilder.setLogLevel(XLogLevel.LEVEL_DEBUG);
} else if (logLevelIndex == 4) {
configBuilder.setLogLevel(XLogLevel.LEVEL_VERBOSE);
} else if (logLevelIndex == 5) {
configBuilder.setLogLevel(XLogLevel.LEVEL_NONE);
}
Integer logMaxAliveSec = (Integer) configMap.get("logMaxAliveSec");
if (logMaxAliveSec != null) {
configBuilder.setLogMaxAliveSec(logMaxAliveSec);
}
String logDir = (String) configMap.get("logDir");
if (logDir != null) {
configBuilder.setXLogDir(logDir);
}
configBuilder.setEnablePreNewProcess((Boolean) configMap.get("enablePreNewProcess"));
Map<Object, Object> uiConfigMap = (Map<Object, Object>) param.get("uiConfig");
String appendingCustomUserAgent = (String) uiConfigMap.get("appendingCustomUserAgent");
if (appendingCustomUserAgent != null) {
configBuilder.setCustomWebViewUserAgent(appendingCustomUserAgent);
}
String appletText = (String) uiConfigMap.get("appletText");
if (appletText != null) {
configBuilder.setAppletText(appletText);
}
// uiConfig
FinAppConfig.UIConfig uiConfig = InitUtils.createUIConfigFromMap(uiConfigMap);
if (uiConfig != null) {
configBuilder.setUiConfig(uiConfig);
}
FinAppConfig finAppConfig = configBuilder.build();
Log.d(TAG, "finAppConfig:" + new Gson().toJson(finAppConfig));
final Application application = MopPluginService.getInstance().getActivity().getApplication();
// SDKSDK
FinCallback<Object> cb = new FinCallback<Object>() {
@Override
public void onSuccess(Object result) {
// SDK
callback.onSuccess(null);
}
@Override
public void onError(int code, String error) {
// SDK
callback.onFail(null);
}
@Override
public void onProgress(int status, String error) {
}
};
FinAppClient.INSTANCE.init(application, finAppConfig, cb);
}
}

View File

@ -0,0 +1,161 @@
package com.finogeeks.mop.api.mop.util;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.client.FinAppConfigPriority;
import java.util.Map;
public class InitUtils {
public static FinAppConfig.UIConfig createUIConfigFromMap(Map<Object, Object> map) {
if (map != null) {
FinAppConfig.UIConfig uiConfig = new FinAppConfig.UIConfig();
uiConfig.setNavigationBarTitleLightColor((Integer) map.get("navigationBarTitleLightColor"));
uiConfig.setNavigationBarTitleDarkColor((Integer) map.get("navigationBarTitleDarkColor"));
uiConfig.setNavigationBarBackBtnLightColor((Integer) map.get("navigationBarBackBtnLightColor"));
uiConfig.setAlwaysShowBackInDefaultNavigationBar((Boolean) map.get("isAlwaysShowBackInDefaultNavigationBar"));
uiConfig.setClearNavigationBarNavButtonBackground((Boolean) map.get("isClearNavigationBarNavButtonBackground"));
uiConfig.setHideFeedbackAndComplaints((Boolean) map.get("isHideFeedbackAndComplaints"));
uiConfig.setHideBackHome((Boolean) map.get("isHideBackHome"));
uiConfig.setHideForwardMenu((Boolean) map.get("isHideForwardMenu"));
uiConfig.setHideRefreshMenu((Boolean) map.get("isHideRefreshMenu"));
uiConfig.setHideShareAppletMenu((Boolean) map.get("isHideShareAppletMenu"));
uiConfig.setHideAddToDesktopMenu((Boolean) map.get("isHideAddToDesktopMenu"));
uiConfig.setHideFavoriteMenu((Boolean) map.get("isHideFavoriteMenu"));
uiConfig.setHideSettingMenu((Boolean) map.get("isHideSettingMenu"));
uiConfig.setHideTransitionCloseButton((Boolean) map.get("hideTransitionCloseButton"));
Map<Object, Object> capsuleConfigMap = (Map<Object, Object>) map.get("capsuleConfig");
if (capsuleConfigMap != null) {
FinAppConfig.UIConfig.CapsuleConfig capsuleConfig = new FinAppConfig.UIConfig.CapsuleConfig();
capsuleConfig.capsuleWidth = (float) capsuleConfigMap.get("capsuleWidth");
capsuleConfig.capsuleHeight = (float) capsuleConfigMap.get("capsuleHeight");
capsuleConfig.capsuleRightMargin = (float) capsuleConfigMap.get("capsuleRightMargin");
capsuleConfig.capsuleCornerRadius = (float) capsuleConfigMap.get("capsuleCornerRadius");
capsuleConfig.capsuleBorderWidth = (float) capsuleConfigMap.get("capsuleBorderWidth");
capsuleConfig.capsuleBgLightColor = (int) capsuleConfigMap.get("capsuleBgLightColor");
capsuleConfig.capsuleBgDarkColor = (int) capsuleConfigMap.get("capsuleBgDarkColor");
capsuleConfig.capsuleBorderLightColor = (int) capsuleConfigMap.get("capsuleBorderLightColor");
capsuleConfig.capsuleBorderDarkColor = (int) capsuleConfigMap.get("capsuleBorderDarkColor");
capsuleConfig.capsuleDividerLightColor = (int) capsuleConfigMap.get("capsuleDividerLightColor");
capsuleConfig.capsuleDividerDarkColor = (int) capsuleConfigMap.get("capsuleDividerDarkColor");
Integer moreLightImage = (Integer) capsuleConfigMap.get("moreLightImage");
if (moreLightImage != null) {
capsuleConfig.moreLightImage = moreLightImage;
}
Integer moreDarkImage = (Integer) capsuleConfigMap.get("moreDarkImage");
if (moreDarkImage != null) {
capsuleConfig.moreDarkImage = moreDarkImage;
}
capsuleConfig.moreBtnWidth = (float) capsuleConfigMap.get("moreBtnWidth");
capsuleConfig.moreBtnLeftMargin = (float) capsuleConfigMap.get("moreBtnLeftMargin");
Integer closeLightImage = (Integer) capsuleConfigMap.get("closeLightImage");
if (closeLightImage != null) {
capsuleConfig.closeLightImage = closeLightImage;
}
Integer closeDarkImage = (Integer) capsuleConfigMap.get("closeDarkImage");
if (closeDarkImage != null) {
capsuleConfig.closeDarkImage = closeDarkImage;
}
capsuleConfig.closeBtnWidth = (float) capsuleConfigMap.get("closeBtnWidth");
capsuleConfig.closeBtnLeftMargin = (float) capsuleConfigMap.get("closeBtnLeftMargin");
uiConfig.setCapsuleConfig(capsuleConfig);
}
Map<Object, Object> navHomeConfigMap = (Map<Object, Object>) map.get("navHomeConfig");
if (navHomeConfigMap != null) {
FinAppConfig.UIConfig.NavHomeConfig navHomeConfig = new FinAppConfig.UIConfig.NavHomeConfig();
navHomeConfig.width = (float) navHomeConfigMap.get("width");
navHomeConfig.height = (float) navHomeConfigMap.get("height");
navHomeConfig.leftMargin = (float) navHomeConfigMap.get("leftMargin");
navHomeConfig.cornerRadius = (float) navHomeConfigMap.get("cornerRadius");
navHomeConfig.borderWidth = (float) navHomeConfigMap.get("borderWidth");
navHomeConfig.borderLightColor = (int) navHomeConfigMap.get("borderLightColor");
navHomeConfig.borderDarkColor = (int) navHomeConfigMap.get("borderDarkColor");
navHomeConfig.bgLightColor = (int) navHomeConfigMap.get("bgLightColor");
navHomeConfig.bgDarkColor = (int) navHomeConfigMap.get("bgDarkColor");
uiConfig.setNavHomeConfig(navHomeConfig);
}
Map<Object, Object> authViewConfigMap = (Map<Object, Object>) map.get("authViewConfig");
if (authViewConfigMap != null) {
FinAppConfig.UIConfig.AuthViewConfig authViewConfig = new FinAppConfig.UIConfig.AuthViewConfig();
authViewConfig.appletNameTextSize = (float) authViewConfigMap.get("appletNameTextSize");
authViewConfig.appletNameLightColor = (int) authViewConfigMap.get("appletNameLightColor");
authViewConfig.appletNameDarkColor = (int) authViewConfigMap.get("appletNameDarkColor");
authViewConfig.authorizeTitleTextSize = (float) authViewConfigMap.get("authorizeTitleTextSize");
authViewConfig.authorizeTitleLightColor = (int) authViewConfigMap.get("authorizeTitleLightColor");
authViewConfig.authorizeTitleDarkColor = (int) authViewConfigMap.get("authorizeTitleDarkColor");
authViewConfig.authorizeDescriptionTextSize = (float) authViewConfigMap.get("authorizeDescriptionTextSize");
authViewConfig.authorizeDescriptionLightColor = (int) authViewConfigMap.get("authorizeDescriptionLightColor");
authViewConfig.authorizeDescriptionDarkColor = (int) authViewConfigMap.get("authorizeDescriptionDarkColor");
authViewConfig.agreementTitleTextSize = (float) authViewConfigMap.get("agreementTitleTextSize");
authViewConfig.agreementTitleLightColor = (int) authViewConfigMap.get("agreementTitleLightColor");
authViewConfig.agreementTitleDarkColor = (int) authViewConfigMap.get("agreementTitleDarkColor");
authViewConfig.agreementDescriptionTextSize = (float) authViewConfigMap.get("agreementDescriptionTextSize");
authViewConfig.agreementDescriptionLightColor = (int) authViewConfigMap.get("agreementDescriptionLightColor");
authViewConfig.agreementDescriptionDarkColor = (int) authViewConfigMap.get("agreementDescriptionDarkColor");
authViewConfig.linkLightColor = (int) authViewConfigMap.get("linkLightColor");
authViewConfig.linkDarkColor = (int) authViewConfigMap.get("linkDarkColor");
Map<Object, Object> allowButtonLightConfig = (Map<Object, Object>) authViewConfigMap.get("allowButtonLightConfig");
if (allowButtonLightConfig != null) {
authViewConfig.allowButtonLightConfig = getAuthButtonConfig(allowButtonLightConfig);
}
Map<Object, Object> allowButtonDarkConfig = (Map<Object, Object>) authViewConfigMap.get("allowButtonDarkConfig");
if (allowButtonDarkConfig != null) {
authViewConfig.allowButtonDarkConfig = getAuthButtonConfig(allowButtonDarkConfig);
}
Map<Object, Object> rejectButtonLightConfig = (Map<Object, Object>) authViewConfigMap.get("rejectButtonLightConfig");
if (rejectButtonLightConfig != null) {
authViewConfig.rejectButtonLightConfig = getAuthButtonConfig(rejectButtonLightConfig);
}
Map<Object, Object> rejectButtonDarkConfig = (Map<Object, Object>) authViewConfigMap.get("rejectButtonDarkConfig");
if (rejectButtonDarkConfig != null) {
authViewConfig.rejectButtonDarkConfig = getAuthButtonConfig(rejectButtonDarkConfig);
}
uiConfig.setAuthViewConfig(authViewConfig);
}
Map<Object, Object> floatWindowConfigMap = (Map<Object, Object>) map.get("floatWindowConfig");
if (floatWindowConfigMap != null) {
FinAppConfig.UIConfig.FloatWindowConfig floatWindowConfig = new FinAppConfig.UIConfig.FloatWindowConfig();
floatWindowConfig.floatMode = (boolean) floatWindowConfigMap.get("floatMode");
floatWindowConfig.x = (int) floatWindowConfigMap.get("x");
floatWindowConfig.y = (int) floatWindowConfigMap.get("y");
floatWindowConfig.width = (int) floatWindowConfigMap.get("width");
floatWindowConfig.height = (int) floatWindowConfigMap.get("height");
uiConfig.setFloatWindowConfig(floatWindowConfig);
}
Integer webViewProgressBarColor = (Integer) map.get("webViewProgressBarColor");
if (webViewProgressBarColor != null) {
uiConfig.setWebViewProgressBarColor(webViewProgressBarColor);
}
uiConfig.setHideWebViewProgressBar((Boolean) map.get("hideWebViewProgressBar"));
uiConfig.setMoreMenuStyle((Integer) map.get("moreMenuStyle"));
int isHideBackHomePriorityIndex = (Integer) map.get("isHideBackHomePriority");
if (isHideBackHomePriorityIndex == 0) {
uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.GLOBAL);
} else if (isHideBackHomePriorityIndex == 1) {
uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.SPECIFIED);
} else if (isHideBackHomePriorityIndex == 2) {
uiConfig.setIsHideBackHomePriority(FinAppConfigPriority.APPLET_FILE);
}
uiConfig.setAutoAdaptDarkMode((Boolean) map.get("autoAdaptDarkMode"));
uiConfig.setDisableSlideCloseAppletGesture((Boolean) map.get("disableSlideCloseAppletGesture"));
String loadingLayoutCls = (String) map.get("loadingLayoutCls");
if (loadingLayoutCls != null) {
uiConfig.setLoadingLayoutCls(loadingLayoutCls);
}
return uiConfig;
}
return null;
}
private static FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig getAuthButtonConfig(Map<Object, Object> map) {
return new FinAppConfig.UIConfig.AuthViewConfig.AuthButtonConfig(
(float) map.get("cornerRadius"),
(int) map.get("normalBackgroundColor"),
(int) map.get("pressedBackgroundColor"),
(int) map.get("normalBorderColor"),
(int) map.get("pressedBorderColor"),
(int) map.get("normalTextColor"),
(int) map.get("pressedTextColor")
);
}
}

View File

@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface MOB_addWebExtentionApi : MOPBaseApi @interface MOP_addWebExtentionApi : MOPBaseApi
@property(nonatomic, copy) NSString* name; @property(nonatomic, copy) NSString* name;
@end @end

View File

@ -5,11 +5,11 @@
// Created by on 2021/12/21. // Created by on 2021/12/21.
// //
#import "MOB_addWebExtentionApi.h" #import "MOP_addWebExtentionApi.h"
#import "MopPlugin.h" #import "MopPlugin.h"
#import <FinApplet/FinApplet.h> #import <FinApplet/FinApplet.h>
@implementation MOB_addWebExtentionApi @implementation MOP_addWebExtentionApi
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel - (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{ {

View File

@ -0,0 +1,16 @@
//
// MOP_changeUserId.h
// mop
//
// Created by on 2023/3/23.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_changeUserId : MOPBaseApi
@property (nonatomic, copy) NSString *userId;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,17 @@
//
// MOP_changeUserId.m
// mop
//
// Created by on 2023/3/23.
//
#import "MOP_changeUserId.h"
#import <FinApplet/FinApplet.h>
@implementation MOP_changeUserId
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
[FATClient sharedClient].config.currentUserId = self.userId;
success(@{});
}
@end

View File

@ -0,0 +1,18 @@
//
// Mop_initSDK.h
// mop
//
// Created by on 2023/3/17.
//
#import <UIKit/UIKit.h>
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_initSDK : MOPBaseApi
@property (nonatomic, strong) NSDictionary *config;
@property (nonatomic, strong) NSDictionary *uiConfig;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,302 @@
//
// Mop_newInitialize.m
// mop
//
// Created by on 2023/3/17.
//
#import "Mop_initSDK.h"
#import "MOPTools.h"
@implementation MOP_initSDK
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
if (!self.config) {
failure(@"config不能为空");
return;
}
FATConfig *config;
NSArray *storeConfigList = self.config[@"finStoreConfigs"];
if (storeConfigList && storeConfigList.count > 0) {
NSMutableArray *storeArrayM = [NSMutableArray array];
for (NSDictionary *dict in storeConfigList) {
FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init];
storeConfig.sdkKey = dict[@"sdkKey"];
storeConfig.sdkSecret = dict[@"sdkSecret"];
storeConfig.apiServer = dict[@"apiServer"];
storeConfig.apmServer = dict[@"apmServer"];
storeConfig.fingerprint = dict[@"fingerprint"];
if ([@"SM" isEqualToString:dict[@"cryptType"]]) {
storeConfig.cryptType = FATApiCryptTypeSM;
} else {
storeConfig.cryptType = FATApiCryptTypeMD5;
}
storeConfig.encryptServerData = [dict[@"encryptServerData"] boolValue];
[storeArrayM addObject:storeConfig];
}
config = [FATConfig configWithStoreConfigs:storeArrayM];
} else {
failure(@"storeConfigs不能为空");
return;
}
config.currentUserId = self.config[@"userId"];
config.productIdentification = self.config[@"productIdentification"];
config.disableAuthorize = [self.config[@"disableRequestPermissions"] boolValue];
config.appletAutoAuthorize = [self.config[@"appletAutoAuthorize"] boolValue];
config.disableGetSuperviseInfo = [self.config[@"disableGetSuperviseInfo"] boolValue];
config.ignoreWebviewCertAuth = [self.config[@"ignoreWebviewCertAuth"] boolValue];
config.appletIntervalUpdateLimit = [self.config[@"appletIntervalUpdateLimit"] integerValue];
config.startCrashProtection = [self.config[@"startCrashProtection"] boolValue];
config.enableApmDataCompression = [self.config[@"enableApmDataCompression"] boolValue];
config.encryptServerData = [self.config[@"encryptServerData"] boolValue];
config.enableAppletDebug = [self.config[@"appletDebugMode"] integerValue];
config.enableWatermark = [self.config[@"enableWatermark"] boolValue];
config.watermarkPriority = [self.config[@"watermarkPriority"] integerValue];
config.baseLoadingViewClass = self.config[@"baseLoadingViewClass"];
config.baseLoadFailedViewClass = self.config[@"baseLoadFailedViewClass"];
config.header = self.config[@"header"];
config.headerPriority = [self.config[@"headerPriority"] integerValue];
config.enableH5AjaxHook = [self.config[@"enableH5AjaxHook"] boolValue];
config.h5AjaxHookRequestKey = self.config[@"h5AjaxHookRequestKey"];
config.pageCountLimit = [self.config[@"pageCountLimit"] integerValue];
config.schemes = self.config[@"schemes"];
NSError* error = nil;
FATUIConfig *uiconfig = [[FATUIConfig alloc]init];
uiconfig.autoAdaptDarkMode = YES;
if (_uiConfig) {
if (_uiConfig[@"navigationTitleTextAttributes"]) {
uiconfig.navigationTitleTextAttributes = _uiConfig[@"navigationTitleTextAttributes"];
}
uiconfig.navigationBarHeight = [_uiConfig[@"navigationBarHeight"] floatValue];
if (_uiConfig[@"navigationBarTitleLightColor"]) {
uiconfig.navigationBarTitleLightColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarTitleLightColor"] intValue]];
}
if (_uiConfig[@"navigationBarTitleDarkColor"]) {
uiconfig.navigationBarTitleDarkColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarTitleDarkColor"] intValue]];
}
if (_uiConfig[@"navigationBarBackBtnLightColor"]) {
uiconfig.navigationBarBackBtnLightColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarBackBtnLightColor"] intValue]];
}
if (_uiConfig[@"navigationBarBackBtnDarkColor"]) {
uiconfig.navigationBarBackBtnDarkColor = [MOPTools colorWithRGBHex:[_uiConfig[@"navigationBarBackBtnDarkColor"] intValue]];
}
uiconfig.moreMenuStyle = [_uiConfig[@"moreMenuStyle"] integerValue];
uiconfig.hideBackToHomePriority = [_uiConfig[@"isHideBackHomePriority"] integerValue];
uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue];
uiconfig.hideBackToHome = [_uiConfig[@"isHideBackHome"] boolValue];
uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue];
uiconfig.hideShareAppletMenu = [_uiConfig[@"isHideShareAppletMenu"] boolValue];
uiconfig.hideRefreshMenu = [_uiConfig[@"isHideRefreshMenu"] boolValue];
uiconfig.hideTransitionCloseButton = [_uiConfig[@"hideTransitionCloseButton"] boolValue];
uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue];
if (_uiConfig[@"webViewProgressBarColor"]) {
uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"webViewProgressBarColor"] intValue]];
}
uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue];
uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue];
uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue];
uiconfig.hideSettingMenu = [_uiConfig[@"isHideSettingMenu"] boolValue];
uiconfig.hideFavoriteMenu = [_uiConfig[@"isHideFavoriteMenu"] boolValue];
uiconfig.hideAddToDesktopMenu = [_uiConfig[@"isHideAddToDesktopMenu"] boolValue];
uiconfig.appletText = _uiConfig[@"appletText"];
uiconfig.disableSlideCloseAppletGesture = [_uiConfig[@"disableSlideCloseAppletGesture"] boolValue];
if (_uiConfig[@"capsuleConfig"]) {
NSDictionary *capsuleConfigDic = _uiConfig[@"capsuleConfig"];
FATCapsuleConfig *capsuleConfig = [[FATCapsuleConfig alloc]init];
capsuleConfig.capsuleWidth = [capsuleConfigDic[@"capsuleWidth"] floatValue];
capsuleConfig.capsuleHeight = [capsuleConfigDic[@"capsuleHeight"] floatValue];
capsuleConfig.capsuleRightMargin = [capsuleConfigDic[@"capsuleRightMargin"] floatValue];
capsuleConfig.capsuleCornerRadius = [capsuleConfigDic[@"capsuleCornerRadius"] floatValue];
capsuleConfig.capsuleBorderWidth = [capsuleConfigDic[@"capsuleBorderWidth"] floatValue];
capsuleConfig.moreBtnWidth = [capsuleConfigDic[@"moreBtnWidth"] floatValue];
capsuleConfig.moreBtnLeftMargin = [capsuleConfigDic[@"moreBtnLeftMargin"] floatValue];
capsuleConfig.closeBtnWidth = [capsuleConfigDic[@"closeBtnWidth"] floatValue];
capsuleConfig.closeBtnLeftMargin = [capsuleConfigDic[@"closeBtnLeftMargin"] floatValue];
capsuleConfig.capsuleBorderLightColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBorderLightColor"] intValue]];
capsuleConfig.capsuleBorderDarkColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBorderDarkColor"] intValue]];
capsuleConfig.capsuleBgLightColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBgLightColor"] intValue]];
capsuleConfig.capsuleBgDarkColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleBgDarkColor"] intValue]];
capsuleConfig.capsuleDividerLightColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleDividerLightColor"] intValue]];
capsuleConfig.capsuleDividerDarkColor = [MOPTools colorWithRGBHex:[capsuleConfigDic[@"capsuleDividerDarkColor"] intValue]];
uiconfig.capsuleConfig = capsuleConfig;
}
if (_uiConfig[@"navHomeConfig"]) {
NSDictionary *navHomeConfigDic = _uiConfig[@"navHomeConfig"];
FATNavHomeConfig *navHomeConfig = [[FATNavHomeConfig alloc]init];
navHomeConfig.width = [navHomeConfigDic[@"width"] floatValue];
navHomeConfig.height = [navHomeConfigDic[@"height"] floatValue];
navHomeConfig.leftMargin = [navHomeConfigDic[@"leftMargin"] floatValue];
navHomeConfig.cornerRadius = [navHomeConfigDic[@"cornerRadius"] floatValue];
navHomeConfig.borderWidth = [navHomeConfigDic[@"width"] floatValue];
if (navHomeConfigDic[@"borderLightColor"]) {
navHomeConfig.borderLightColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"borderLightColor"] intValue]];
}
if (navHomeConfigDic[@"borderDarkColor"]) {
navHomeConfig.borderDarkColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"borderDarkColor"] intValue]];
}
if (navHomeConfigDic[@"bgLightColor"]) {
navHomeConfig.bgLightColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"bgLightColor"] intValue]];
}
if (navHomeConfigDic[@"bgDarkColor"]) {
navHomeConfig.bgDarkColor = [MOPTools colorWithRGBHex:[navHomeConfigDic[@"bgDarkColor"] intValue]];
}
uiconfig.navHomeConfig = navHomeConfig;
}
if (_uiConfig[@"authViewConfig"]) {
NSDictionary *authViewConfigDic = _uiConfig[@"authViewConfig"];
FATAuthViewConfig *authViewConfig = [[FATAuthViewConfig alloc]init];
authViewConfig.appletNameFont = [UIFont systemFontOfSize:[authViewConfigDic[@"appletNameTextSize"] floatValue]];
if (authViewConfigDic[@"appletNameLightColor"]) {
authViewConfig.appletNameLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"appletNameLightColor"] intValue]];
}
if (authViewConfigDic[@"appletNameDarkColor"]) {
authViewConfig.appletNameDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"appletNameDarkColor"] intValue]];
}
authViewConfig.authorizeTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeTitleTextSize"] floatValue] weight:UIFontWeightMedium];
if (authViewConfigDic[@"authorizeTitleLightColor"]) {
authViewConfig.authorizeTitleLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeTitleLightColor"] intValue]];
}
if (authViewConfigDic[@"authorizeTitleDarkColor"]) {
authViewConfig.authorizeTitleDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeTitleDarkColor"] intValue]];
}
authViewConfig.authorizeDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"authorizeDescriptionTextSize"] floatValue]];
if (authViewConfigDic[@"authorizeDescriptionLightColor"]) {
authViewConfig.authorizeDescriptionLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeDescriptionLightColor"] intValue]];
}
if (authViewConfigDic[@"authorizeDescriptionDarkColor"]) {
authViewConfig.authorizeDescriptionDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"authorizeDescriptionDarkColor"] intValue]];
}
authViewConfig.agreementTitleFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementTitleTextSize"] floatValue]];
if (authViewConfigDic[@"agreementTitleLightColor"]) {
authViewConfig.agreementTitleLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementTitleLightColor"] intValue]];
}
if (authViewConfigDic[@"agreementTitleDarkColor"]) {
authViewConfig.agreementTitleDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementTitleDarkColor"] intValue]];
}
authViewConfig.agreementDescriptionFont = [UIFont systemFontOfSize:[authViewConfigDic[@"agreementDescriptionTextSize"] floatValue]];
if (authViewConfigDic[@"agreementDescriptionLightColor"]) {
authViewConfig.agreementDescriptionLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementDescriptionLightColor"] intValue]];
}
if (authViewConfigDic[@"agreementDescriptionDarkColor"]) {
authViewConfig.agreementDescriptionDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"agreementDescriptionDarkColor"] intValue]];
}
if (authViewConfigDic[@"linkLightColor"]) {
authViewConfig.linkLightColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"linkLightColor"] intValue]];
}
if (authViewConfigDic[@"linkDarkColor"]) {
authViewConfig.linkDarkColor = [MOPTools colorWithRGBHex:[authViewConfigDic[@"linkDarkColor"] intValue]];
}
if (authViewConfigDic[@"allowButtonLightConfig"]) {
FATAuthButtonConfig *allowButtonLightConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"allowButtonLightConfig"]];
authViewConfig.allowButtonLightConfig = allowButtonLightConfig;
}
if (authViewConfigDic[@"allowButtonDarkConfig"]) {
FATAuthButtonConfig *allowButtonDarkConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"allowButtonDarkConfig"]];
authViewConfig.allowButtonDarkConfig = allowButtonDarkConfig;
}
if (authViewConfigDic[@"rejectButtonLightConfig"]) {
FATAuthButtonConfig *rejectButtonLightConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"rejectButtonLightConfig"]];
authViewConfig.rejectButtonLightConfig = rejectButtonLightConfig;
}
if (authViewConfigDic[@"rejectButtonDarkConfig"]) {
FATAuthButtonConfig *rejectButtonDarkConfig = [self createAuthButtonConfigWithDic:authViewConfigDic[@"rejectButtonDarkConfig"]];
authViewConfig.rejectButtonDarkConfig = rejectButtonDarkConfig;
}
uiconfig.authViewConfig = authViewConfig;
}
uiconfig.appendingCustomUserAgent = _uiConfig[@"customWebViewUserAgent"];
uiconfig.hideWebViewProgressBar = [_uiConfig[@"hideWebViewProgressBar"] boolValue];
uiconfig.autoAdaptDarkMode = [_uiConfig[@"autoAdaptDarkMode"] boolValue];
uiconfig.transtionStyle = [_uiConfig[@"transtionStyle"] integerValue];
}
// uiconfig.moreMenuStyle = FATMoreViewStyleNormal;
[[FATClient sharedClient] initWithConfig:config uiConfig:uiconfig error:&error];
if (error) {
failure(@"初始化失败");
return;
}
NSInteger logLevelIntValue = [self.config[@"logLevel"] integerValue];
if (logLevelIntValue >= 5) {
[[FATClient sharedClient].logManager closeLog];
} else {
FATLogLevel logLevel = logLevelIntValue;
NSString *logDir = self.config[@"logDir"];
[[FATClient sharedClient].logManager initLogWithLogDir:logDir logLevel:logLevel consoleLog:YES];
}
[[FATClient sharedClient] setEnableLog:YES];
success(@{});
}
- (FATAuthButtonConfig *)createAuthButtonConfigWithDic:(NSDictionary *)dic {
if (!dic) {
return nil;
}
FATAuthButtonConfig * authButtonConfig = [[FATAuthButtonConfig alloc]init];
if (dic[@"cornerRadius"]) {
authButtonConfig.cornerRadius = [dic[@"cornerRadius"] floatValue];
}
if (dic[@"normalBackgroundColor"]) {
authButtonConfig.normalBackgroundColor = [MOPTools colorWithRGBHex:[dic[@"normalBackgroundColor"] intValue]];
}
if (dic[@"pressedBackgroundColor"]) {
authButtonConfig.pressedBackgroundColor = [MOPTools colorWithRGBHex:[dic[@"pressedBackgroundColor"] intValue]];
}
if (dic[@"normalTextColor"]) {
authButtonConfig.normalTextColor = [MOPTools colorWithRGBHex:[dic[@"normalTextColor"] intValue]];
}
if (dic[@"pressedTextColor"]) {
authButtonConfig.pressedTextColor = [MOPTools colorWithRGBHex:[dic[@"pressedTextColor"] intValue]];
}
if (dic[@"normalBorderColor"]) {
authButtonConfig.normalBorderColor = [MOPTools colorWithRGBHex:[dic[@"normalBorderColor"] intValue]];
}
if (dic[@"pressedBorderColor"]) {
authButtonConfig.pressedBorderColor = [MOPTools colorWithRGBHex:[dic[@"pressedBorderColor"] intValue]];
}
return authButtonConfig;
}
@end

View File

@ -30,7 +30,6 @@
for (NSDictionary *dict in _finStoreConfigs) { for (NSDictionary *dict in _finStoreConfigs) {
FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init]; FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init];
storeConfig.sdkKey = dict[@"sdkKey"]; storeConfig.sdkKey = dict[@"sdkKey"];
// storeConfig.sdkKey = @"22LyZEib0gLTQdU3MUauAb4V4W8Uxd/gMgmH8Hg1bGQ=";
storeConfig.sdkSecret = dict[@"sdkSecret"]; storeConfig.sdkSecret = dict[@"sdkSecret"];
storeConfig.apiServer = dict[@"apiServer"]; storeConfig.apiServer = dict[@"apiServer"];
storeConfig.apmServer = dict[@"apmServer"]; storeConfig.apmServer = dict[@"apmServer"];
@ -82,8 +81,8 @@
if (_uiConfig[@"navigationTitleTextAttributes"]) { if (_uiConfig[@"navigationTitleTextAttributes"]) {
uiconfig.navigationTitleTextAttributes = _uiConfig[@"navigationTitleTextAttributes"]; uiconfig.navigationTitleTextAttributes = _uiConfig[@"navigationTitleTextAttributes"];
} }
if (_uiConfig[@"progressBarColor"]) { if (_uiConfig[@"webViewProgressBarColor"]) {
uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"progressBarColor"] intValue]]; uiconfig.progressBarColor = [MOPTools colorWithRGBHex:[_uiConfig[@"webViewProgressBarColor"] intValue]];
} }
uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue]; uiconfig.hideFeedbackMenu = [_uiConfig[@"isHideFeedbackAndComplaints"] boolValue];
uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue]; uiconfig.hideForwardMenu = [_uiConfig[@"isHideForwardMenu"] boolValue];

View File

@ -20,7 +20,7 @@
Class ApiClass = NSClassFromString(apiMethod); Class ApiClass = NSClassFromString(apiMethod);
if (!ApiClass) { if (!ApiClass) {
NSLog(@"MOPybridExtensionConverter Error"); NSLog(@"MOPybridExtensionConverter Error %@",apiMethod);
return nil; return nil;
} }

View File

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -22,7 +23,7 @@ class FinStoreConfig {
String apiServer; String apiServer;
/// apm,apiServer /// apm,apiServer
String apmServer; String? apmServer;
/// MD5 SM /// MD5 SM
String cryptType; String cryptType;
@ -33,8 +34,9 @@ class FinStoreConfig {
/// 使YES /// 使YES
bool encryptServerData; bool encryptServerData;
FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer, this.apmServer, FinStoreConfig(this.sdkKey, this.sdkSecret, this.apiServer,
{this.cryptType = "MD5", {this.apmServer,
this.cryptType = "MD5",
this.fingerprint, this.fingerprint,
this.encryptServerData = false}); this.encryptServerData = false});
@ -51,60 +53,316 @@ class FinStoreConfig {
} }
} }
class UIConfig { class Config {
Map<String, dynamic>? navigationTitleTextAttributes; //font ///
List<FinStoreConfig> finStoreConfigs;
/// /// id->->id
/// userId
/// //退
/// userId
String? userId;
/// finclipfinogeeksuserAgentfinogeeks
String? productIdentification;
/// SDK
/// trueSDK使api
bool disableRequestPermissions = false;
///
/// true
bool appletAutoAuthorize = false;
/// SDKAPIfalse
/// trueSDKAPI
bool disableGetSuperviseInfo = false;
/// webviewfalse,
/// trueHttps
bool ignoreWebviewCertAuth = false;
///
/// SDKwifi使x
/// 0~5003
int appletIntervalUpdateLimit = 3;
/// apm
Map<String, String>? apmExtendInfo;
/// Crashfalse(iOS)
/// UnrecognizedSelectorKVONotificationTimerContainer(nil)String (nil)
/// 便
bool startCrashProtection = false;
///
/// false
bool enableApmDataCompression = false;
/// 使
/// YES
bool encryptServerData = false;
/// debug
/// BOOLStateUndefinedapp.json debug:true vconsole
/// BOOLStateTruevconsole
/// BOOLStateFalse
/// BOOLStateForbiddenvconsoleapi
BOOLState appletDebugMode = BOOLState.BOOLStateUndefined;
///
bool enableWatermark = false;
///
ConfigPriority watermarkPriority = ConfigPriority.ConfigGlobalPriority;
/// iOS
///
/// FATBaseLoadingView
/// swiftSwiftDemo.FCloadingViewSwiftDemoFCloadingView
String? baseLoadingViewClass;
/// iOS
///
/// FATBaseLoadFailedView
/// swiftSwiftDemo.FCloadingViewSwiftDemoFCloadingView
String? baseLoadFailedViewClass;
/// header
/// apikey
/// ft.requestft.downloadFileft.uploadFile
Map<String, String>? header;
/// header
ConfigPriority headerPriority = ConfigPriority.ConfigGlobalPriority;
/// iOS
/// H5hook
/// 宿app http httpsH5request bodySDKhook request
/// body宿App宿Apprequestbody
/// URLProtocolbody
bool enableH5AjaxHook = false;
/// iOS
/// enableH5AjaxHookhook requestrequest url FinClipHookBridge-RequestId=xxx
/// Key FinClip-RequestIdFinClip-RequestId=xxx
String? h5AjaxHookRequestKey;
/// 0
/// 55navigateTo 4
int pageCountLimit = 0;
/// scheme
List<String>? schemes;
/// Android
/// debug
bool debug = false;
/// Android
///
int? maxRunningApplet;
/// Android
/// WebView mixed content mode
int? webViewMixedContentMode;
/// Android
/// appApp
bool bindAppletWithMainProcess = false;
/// Android
/// App
String? killAppletProcessNotice;
/// Android
/// Android SDK
int minAndroidSdkVersion = 21; // Build.VERSION_CODES.LOLLIPOP
/// Android
///
bool enableScreenShot = false;
/// Android
/// GLOBAL
ConfigPriority screenShotPriority = ConfigPriority.ConfigGlobalPriority;
///
LogLevel logLevel = LogLevel.LEVEL_NONE;
/// Android
///
/// 1 1 * 24 * 60 * 60
int? logMaxAliveSec;
/// XLog
String? logDir;
/// Android
///
bool enablePreNewProcess = false;
Config(this.finStoreConfigs);
Map<String, dynamic> toMap() {
List<Map<String, dynamic>>? storeConfigs =
finStoreConfigs.map((e) => e.toMap()).toList();
return {
"finStoreConfigs": storeConfigs,
"userId": userId,
"productIdentification": productIdentification,
"disableRequestPermissions": disableRequestPermissions,
"appletAutoAuthorize": appletAutoAuthorize,
"disableGetSuperviseInfo": disableGetSuperviseInfo,
"ignoreWebviewCertAuth": ignoreWebviewCertAuth,
"appletIntervalUpdateLimit": appletIntervalUpdateLimit,
"apmExtendInfo": apmExtendInfo,
"startCrashProtection": startCrashProtection,
"enableApmDataCompression": enableApmDataCompression,
"encryptServerData": encryptServerData,
"appletDebugMode": appletDebugMode.index,
"enableWatermark": enableWatermark,
"watermarkPriority": watermarkPriority.index,
"baseLoadingViewClass": baseLoadingViewClass,
"baseLoadFailedViewClass": baseLoadFailedViewClass,
"header": header,
"headerPriority": headerPriority.index,
"enableH5AjaxHook": enableH5AjaxHook,
"h5AjaxHookRequestKey": h5AjaxHookRequestKey,
"pageCountLimit": pageCountLimit,
"schemes": schemes,
"debug": debug,
"maxRunningApplet": maxRunningApplet,
"webViewMixedContentMode": webViewMixedContentMode,
"bindAppletWithMainProcess": bindAppletWithMainProcess,
"killAppletProcessNotice": killAppletProcessNotice,
"minAndroidSdkVersion": minAndroidSdkVersion,
"enableScreenShot": enableScreenShot,
"screenShotPriority": screenShotPriority.index,
"logLevel": logLevel.index,
"logMaxAliveSec": logMaxAliveSec,
"logDir": logDir,
"enablePreNewProcess": enablePreNewProcess,
};
}
}
class UIConfig {
// fontAndroid
Map<String, dynamic>? navigationTitleTextAttributes;
// ()44Android
double navigationBarHeight = 44;
//
int navigationBarTitleLightColor = 0xffffffff;
//
int navigationBarTitleDarkColor = 0xff000000;
//
int navigationBarBackBtnLightColor = 0xffffffff;
//
int navigationBarBackBtnDarkColor = 0xff000000;
// 0: 1:Normal
int moreMenuStyle = 0;
/// iOShideBackToHomePriority
/// FATConfigAppletFilePriority
ConfigPriority isHideBackHomePriority = ConfigPriority.ConfigGlobalPriority;
/// ios
bool isAlwaysShowBackInDefaultNavigationBar = false; bool isAlwaysShowBackInDefaultNavigationBar = false;
/// /// ios
bool isClearNavigationBarNavButtonBackground = false; bool isClearNavigationBarNavButtonBackground = false;
///"更多""反馈与投诉" /// ...
bool isHideFeedbackAndComplaints = false; bool isHideFeedbackAndComplaints = false;
///"更多""返回首页" /// ...
bool isHideBackHome = false; bool isHideBackHome = false;
///"更多""转发" /// ... false
bool isHideForwardMenu = false; bool isHideForwardMenu = false;
///"更多""分享" /// ... true
bool isHideShareAppletMenu = true; bool isHideShareAppletMenu = true;
///"更多""添加到桌面" /// ...
bool isHideAddToDesktopMenu = true; bool isHideAddToDesktopMenu = true;
///"更多""收藏" /// ...
bool isHideFavoriteMenu = true; bool isHideFavoriteMenu = true;
/// ServiceSDK // ... false
bool hideTransitionCloseButton = false; bool isHideRefreshMenu = false;
/// // ... false
bool disableSlideCloseAppletGesture = false; bool isHideSettingMenu = false;
/// ///
CapsuleConfig? capsuleConfig; CapsuleConfig? capsuleConfig;
//
NavHomeConfig? navHomeConfig;
FloatWindowConfig? floatWindowConfig; FloatWindowConfig? floatWindowConfig;
//iOS // UI
AuthViewConfig? authViewConfig;
// iOSprogressBarColor
// H5 0xFFFFAA00 // H5 0xFFFFAA00
int? progressBarColor; int? webViewProgressBarColor;
// H5false
bool hideWebViewProgressBar = false;
// true // true
bool autoAdaptDarkMode = true; bool autoAdaptDarkMode = false;
//appletText // userAgent
String? appendingCustomUserAgent;
/// AndroidAndroidsetActivityTransitionAnim
///
/// FATTranstionStyleUp
/// api
/// 1. scheme
/// 2. universal link
/// 3. navigateToMiniprogram
TranstionStyle transtionStyle = TranstionStyle.TranstionStyleUp;
/// ServiceSDK
bool hideTransitionCloseButton = false;
/// NO
///
bool disableSlideCloseAppletGesture = false;
/// appletText
String? appletText; String? appletText;
/// Android
/// LoadingClass
String? loadingLayoutCls;
/// 使live /// 使live
bool useNativeLiveComponent = false; bool useNativeLiveComponent = false;
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
"navigationTitleTextAttributes": navigationTitleTextAttributes, "navigationTitleTextAttributes": navigationTitleTextAttributes,
"navigationBarHeight": navigationBarHeight,
"navigationBarTitleLightColor": navigationBarTitleLightColor.toSigned(32),
"navigationBarTitleDarkColor": navigationBarTitleDarkColor.toSigned(32),
"navigationBarBackBtnLightColor":
navigationBarBackBtnLightColor.toSigned(32),
"navigationBarBackBtnDarkColor":
navigationBarBackBtnDarkColor.toSigned(32),
"isAlwaysShowBackInDefaultNavigationBar": "isAlwaysShowBackInDefaultNavigationBar":
isAlwaysShowBackInDefaultNavigationBar, isAlwaysShowBackInDefaultNavigationBar,
"isClearNavigationBarNavButtonBackground": "isClearNavigationBarNavButtonBackground":
@ -112,17 +370,27 @@ class UIConfig {
"isHideFeedbackAndComplaints": isHideFeedbackAndComplaints, "isHideFeedbackAndComplaints": isHideFeedbackAndComplaints,
"isHideBackHome": isHideBackHome, "isHideBackHome": isHideBackHome,
"isHideForwardMenu": isHideForwardMenu, "isHideForwardMenu": isHideForwardMenu,
"isHideRefreshMenu": isHideRefreshMenu,
"isHideShareAppletMenu": isHideShareAppletMenu, "isHideShareAppletMenu": isHideShareAppletMenu,
"isHideSettingMenu": isHideSettingMenu,
"isHideAddToDesktopMenu": isHideAddToDesktopMenu, "isHideAddToDesktopMenu": isHideAddToDesktopMenu,
"isHideFavoriteMenu": isHideFavoriteMenu, "isHideFavoriteMenu": isHideFavoriteMenu,
"hideTransitionCloseButton": hideTransitionCloseButton, "hideTransitionCloseButton": hideTransitionCloseButton,
"disableSlideCloseAppletGesture": disableSlideCloseAppletGesture,
"capsuleConfig": capsuleConfig?.toMap(), "capsuleConfig": capsuleConfig?.toMap(),
"navHomeConfig": navHomeConfig?.toMap(),
"authViewConfig": authViewConfig?.toMap(),
"floatWindowConfig": floatWindowConfig?.toMap(), "floatWindowConfig": floatWindowConfig?.toMap(),
"progressBarColor": progressBarColor, "webViewProgressBarColor": webViewProgressBarColor?.toSigned(32),
"hideWebViewProgressBar": hideWebViewProgressBar,
"moreMenuStyle": moreMenuStyle,
"isHideBackHomePriority": isHideBackHomePriority.index,
"autoAdaptDarkMode": autoAdaptDarkMode, "autoAdaptDarkMode": autoAdaptDarkMode,
"appendingCustomUserAgent": appendingCustomUserAgent,
"transtionStyle": transtionStyle.index,
"disableSlideCloseAppletGesture": disableSlideCloseAppletGesture,
"appletText": appletText,
"loadingLayoutCls": loadingLayoutCls,
"useNativeLiveComponent": useNativeLiveComponent, "useNativeLiveComponent": useNativeLiveComponent,
"appletText": appletText
}; };
} }
} }
@ -136,7 +404,7 @@ class CapsuleConfig {
double capsuleHeight = 32; double capsuleHeight = 32;
/// ///
double capsuleRightMargin = 7; double capsuleRightMargin = 8;
/// 5 /// 5
double capsuleCornerRadius = 5; double capsuleCornerRadius = 5;
@ -151,11 +419,9 @@ class CapsuleConfig {
int capsuleBgDarkColor = 0x80ffffff; int capsuleBgDarkColor = 0x80ffffff;
/// ///
int capsuleBorderLightColor = 0x80ffffff; int capsuleBorderLightColor = 0x80ffffff;
/// ///
int capsuleBorderDarkColor = 0x26000000; int capsuleBorderDarkColor = 0x26000000;
/// 线 /// 线
@ -177,7 +443,6 @@ class CapsuleConfig {
double moreBtnLeftMargin = 6; double moreBtnLeftMargin = 6;
/// 使 /// 使
int? closeLightImage; int? closeLightImage;
/// 使 /// 使
@ -234,15 +499,239 @@ class FloatWindowConfig {
} }
} }
class NavHomeConfig {
///
double width;
///
double height;
/// Android8iOS10
double leftMargin = Platform.isAndroid ? 8 : 10;
/// 5
double cornerRadius = 5;
/// Android0.75iOS0.8
double borderWidth = Platform.isAndroid ? 0.75 : 0.8;
///
///
int borderLightColor = 0x80ffffff;
///
///
int borderDarkColor = 0x26000000;
///
///
int bgLightColor = 0x33000000;
///
///
int bgDarkColor = 0x80ffffff;
NavHomeConfig(this.width, this.height, this.borderLightColor,
this.borderDarkColor, this.bgLightColor, this.bgDarkColor);
Map<String, dynamic> toMap() {
return {
"width": width,
"height": height,
"leftMargin": leftMargin,
"cornerRadius": cornerRadius,
"borderWidth": borderWidth,
"borderLightColor": borderLightColor.toSigned(32),
"borderDarkColor": borderDarkColor.toSigned(32),
"bgLightColor": bgLightColor.toSigned(32),
"bgDarkColor": bgDarkColor.toSigned(32),
};
}
}
class AuthViewConfig {
/// PingFangSC-Regular16
double appletNameTextSize = 16;
/// #222222
int appletNameLightColor = 0xff222222;
/// #D0D0D0
int appletNameDarkColor = 0xffd0d0d0;
/// PingFangSC-Medium17
/// 使PingFangSC-Regular
double authorizeTitleTextSize = 17;
/// #222222
/// 使
int authorizeTitleLightColor = 0xff222222;
/// #D0D0D0
/// 使
int authorizeTitleDarkColor = 0xffd0d0d0;
/// PingFangSC-Regular14
double authorizeDescriptionTextSize = 14;
/// #666666
int authorizeDescriptionLightColor = 0xff666666;
/// #5c5c5c
int authorizeDescriptionDarkColor = 0xff5c5c5c;
/// PingFangSC-Regular16
double agreementTitleTextSize = 16;
/// #222222
int agreementTitleLightColor = 0xff222222;
/// #D0D0D0
int agreementTitleDarkColor = 0xffd0d0d0;
/// PingFangSC-Regular14
double agreementDescriptionTextSize = 14;
/// #222222
int agreementDescriptionLightColor = 0xff222222;
/// #D0D0D0
int agreementDescriptionDarkColor = 0xffd0d0d0;
/// #4285f4
int linkLightColor = 0xff4285f4;
/// #4285f4
int linkDarkColor = 0xff4285f4;
///
/// 4
/// #4285F4
/// #4285F4
/// #FFFFFF
/// #3B77DB
/// #3B77DB
/// #FFFFFF
AuthButtonConfig? allowButtonLightConfig;
///
/// 4
/// #4285F4
/// #4285F4
/// #FFFFFF
/// #5E97F5
/// #5E97F5
/// #FFFFFF
AuthButtonConfig? allowButtonDarkConfig;
///
/// 4
/// #FFFFFF
/// #E2E2E2
/// #222222
/// #D8D8D8
/// #D8D8D8
/// #222222
AuthButtonConfig? rejectButtonLightConfig;
///
/// 4
/// #2C2C2C
/// #2C2C2C
/// #D0D0D0
/// #414141
/// #414141
/// #D0D0D0
AuthButtonConfig? rejectButtonDarkConfig;
Map<String, dynamic> toMap() {
return {
"appletNameTextSize": appletNameTextSize,
"appletNameLightColor": appletNameLightColor.toSigned(32),
"appletNameDarkColor": appletNameDarkColor.toSigned(32),
"authorizeTitleTextSize": authorizeTitleTextSize,
"authorizeTitleLightColor": authorizeTitleLightColor.toSigned(32),
"authorizeTitleDarkColor": authorizeTitleDarkColor.toSigned(32),
"authorizeDescriptionTextSize": authorizeDescriptionTextSize,
"authorizeDescriptionLightColor":
authorizeDescriptionLightColor.toSigned(32),
"authorizeDescriptionDarkColor":
authorizeDescriptionDarkColor.toSigned(32),
"agreementTitleTextSize": agreementTitleTextSize,
"agreementTitleLightColor": agreementTitleLightColor.toSigned(32),
"agreementTitleDarkColor": agreementTitleDarkColor.toSigned(32),
"agreementDescriptionTextSize": agreementDescriptionTextSize,
"agreementDescriptionLightColor":
agreementDescriptionLightColor.toSigned(32),
"agreementDescriptionDarkColor":
agreementDescriptionDarkColor.toSigned(32),
"linkLightColor": linkLightColor.toSigned(32),
"linkDarkColor": linkDarkColor.toSigned(32),
"allowButtonLightConfig": allowButtonLightConfig?.toMap(),
"allowButtonDarkConfig": allowButtonDarkConfig?.toMap(),
"rejectButtonLightConfig": rejectButtonLightConfig?.toMap(),
"rejectButtonDarkConfig": rejectButtonDarkConfig?.toMap(),
};
}
}
class AuthButtonConfig {
///
double cornerRadius;
///
int normalBackgroundColor;
///
int pressedBackgroundColor;
///
int normalTextColor;
///
int pressedTextColor;
///
int normalBorderColor;
///
int pressedBorderColor;
AuthButtonConfig(
this.cornerRadius,
this.normalBackgroundColor,
this.pressedBackgroundColor,
this.normalTextColor,
this.pressedTextColor,
this.normalBorderColor,
this.pressedBorderColor);
Map<String, dynamic> toMap() {
return {
"cornerRadius": cornerRadius,
"normalBackgroundColor": normalBackgroundColor.toSigned(32),
"pressedBackgroundColor": pressedBackgroundColor.toSigned(32),
"normalTextColor": normalTextColor.toSigned(32),
"pressedTextColor": pressedTextColor.toSigned(32),
"normalBorderColor": normalBorderColor.toSigned(32),
"pressedBorderColor": pressedBorderColor.toSigned(32)
};
}
}
class BaseAppletRequest { class BaseAppletRequest {
// //
String apiServer; String apiServer;
// id // id
String appletId; String appletId;
// //
Map<String, String>? startParams; Map<String, String>? startParams;
// iOStrue // iOStrue
bool? animated; bool? animated;
// androidfalse // androidfalse
bool isSingleProcess; bool isSingleProcess;
@ -268,18 +757,25 @@ class BaseAppletRequest {
class RemoteAppletRequest { class RemoteAppletRequest {
// //
String apiServer; String apiServer;
// id // id
String appletId; String appletId;
// //
Map<String, String>? startParams; Map<String, String>? startParams;
// //
int? sequence; int? sequence;
// 线 // 线
String? offlineMiniprogramZipPath; String? offlineMiniprogramZipPath;
// 线 // 线
String? offlineFrameworkZipPath; String? offlineFrameworkZipPath;
// iOStrue // iOStrue
bool animated; bool animated;
// androidfalse // androidfalse
bool isSingleProcess; bool isSingleProcess;
@ -316,8 +812,10 @@ class RemoteAppletRequest {
class QRCodeAppletRequest { class QRCodeAppletRequest {
// //
String qrCode; String qrCode;
// //
bool animated = true; bool animated = true;
// androidfalse // androidfalse
bool isSingleProcess; bool isSingleProcess;
@ -341,6 +839,33 @@ enum Anim {
NoneAnim NoneAnim
} }
enum ConfigPriority {
ConfigGlobalPriority, //
ConfigSpecifiedPriority, //
ConfigAppletFilePriority, // app.ext.json
}
enum TranstionStyle {
TranstionStyleUp, // present
TranstionStylePush, // push
}
enum BOOLState {
BOOLStateUndefined, //
BOOLStateTrue, // vconsoleapi
BOOLStateFalse, // setEnableDebugvconsole
BOOLStateForbidden, // vconsoleapi
}
enum LogLevel {
LEVEL_ERROR, // ERROR
LEVEL_WARNING, // ERRORWARNING
LEVEL_INFO, // ERRORWARNINGINFO
LEVEL_DEBUG, // ERRORWARINGINFODEBUG
LEVEL_VERBOSE, // ERRORWARINGINFODEBUGVERBOSE
LEVEL_NONE
}
class Mop { class Mop {
static final Mop _instance = new Mop._internal(); static final Mop _instance = new Mop._internal();
late MethodChannel _channel; late MethodChannel _channel;
@ -407,8 +932,6 @@ class Mop {
} }
} }
///
///
/// initialize mop miniprogram engine. /// initialize mop miniprogram engine.
/// ///
/// [sdkkey] is required. it can be getted from api.finclip.com /// [sdkkey] is required. it can be getted from api.finclip.com
@ -425,7 +948,6 @@ class Mop {
/// [customWebViewUserAgent] webview ua /// [customWebViewUserAgent] webview ua
/// [appletIntervalUpdateLimit] /// [appletIntervalUpdateLimit]
/// [maxRunningApplet] /// [maxRunningApplet]
///
Future<Map> initialize( Future<Map> initialize(
String sdkkey, String sdkkey,
String secret, { String secret, {
@ -444,8 +966,7 @@ class Mop {
int? appletIntervalUpdateLimit, int? appletIntervalUpdateLimit,
int? maxRunningApplet, int? maxRunningApplet,
bool useLocalTbsCore = false, bool useLocalTbsCore = false,
String? tbsCoreUrl String? tbsCoreUrl,
}) async { }) async {
List<Map<String, dynamic>>? storeConfigs = List<Map<String, dynamic>>? storeConfigs =
finStoreConfigs?.map((e) => e.toMap()).toList(); finStoreConfigs?.map((e) => e.toMap()).toList();
@ -473,6 +994,14 @@ class Mop {
return ret; return ret;
} }
Future<Map> initSDK(Config config, {UIConfig? uiConfig}) async {
final Map ret = await _channel.invokeMethod('initSDK', {
'config': config.toMap(),
'uiConfig': uiConfig?.toMap(),
});
return ret;
}
/// open the miniprogram [appId] from the mop server. /// open the miniprogram [appId] from the mop server.
/// ///
/// [appId] is required. /// [appId] is required.
@ -511,12 +1040,9 @@ class Mop {
return ret; return ret;
} }
///
/// get current using applet /// get current using applet
/// 使 /// 使
/// {appId,name,icon,description,version,thumbnail} /// {appId,name,icon,description,version,thumbnail}
///
///
Future<Map<String, dynamic>> currentApplet() async { Future<Map<String, dynamic>> currentApplet() async {
final ret = await _channel.invokeMapMethod("currentApplet"); final ret = await _channel.invokeMapMethod("currentApplet");
return Map<String, dynamic>.from(ret!); return Map<String, dynamic>.from(ret!);
@ -528,18 +1054,14 @@ class Mop {
return Map<String, dynamic>.from(ret!); return Map<String, dynamic>.from(ret!);
} }
///
/// close all running applets /// close all running applets
/// ///
///
Future closeAllApplets() async { Future closeAllApplets() async {
return await _channel.invokeMethod("closeAllApplets"); return await _channel.invokeMethod("closeAllApplets");
} }
///
/// clear applets cache /// clear applets cache
/// ///
///
Future clearApplets() async { Future clearApplets() async {
return await _channel.invokeMethod("clearApplets"); return await _channel.invokeMethod("clearApplets");
} }
@ -556,18 +1078,14 @@ class Mop {
return await _channel.invokeMethod("removeAllUsedApplets", params); return await _channel.invokeMethod("removeAllUsedApplets", params);
} }
///
/// ///
///
Future<String> sdkVersion() async { Future<String> sdkVersion() async {
return await _channel return await _channel
.invokeMapMethod("sdkVersion") .invokeMapMethod("sdkVersion")
.then((value) => value?["data"]); .then((value) => value?["data"]);
} }
///
/// -- /// --
///
Future scanOpenApplet(String info, {bool isSingleProcess = false}) async { Future scanOpenApplet(String info, {bool isSingleProcess = false}) async {
Map<String, Object> params = { Map<String, Object> params = {
'info': info, 'info': info,
@ -576,10 +1094,8 @@ class Mop {
return await _channel.invokeMapMethod("scanOpenApplet", params); return await _channel.invokeMapMethod("scanOpenApplet", params);
} }
///
/// ///
/// [qrcode] /// [qrcode]
///
Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async { Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async {
Map<String, Object> params = { Map<String, Object> params = {
'qrcode': qrcode, 'qrcode': qrcode,
@ -588,9 +1104,7 @@ class Mop {
return await _channel.invokeMapMethod("qrcodeOpenApplet", params); return await _channel.invokeMapMethod("qrcodeOpenApplet", params);
} }
///
/// QrCode /// QrCode
///
Future<Map<String, dynamic>> parseAppletInfoFromWXQrCode( Future<Map<String, dynamic>> parseAppletInfoFromWXQrCode(
String qrCode, String apiServer) async { String qrCode, String apiServer) async {
final ret = await _channel.invokeMapMethod("parseAppletInfoFromWXQrCode", final ret = await _channel.invokeMapMethod("parseAppletInfoFromWXQrCode",
@ -598,10 +1112,8 @@ class Mop {
return Map<String, dynamic>.from(ret!); return Map<String, dynamic>.from(ret!);
} }
///
/// register handler to provide custom info or behaviour /// register handler to provide custom info or behaviour
/// ///
///
void registerAppletHandler(AppletHandler handler) { void registerAppletHandler(AppletHandler handler) {
_appletHandlerApis["forwardApplet"] = (params) async { _appletHandlerApis["forwardApplet"] = (params) async {
handler.forwardApplet(Map<String, dynamic>.from(params)); handler.forwardApplet(Map<String, dynamic>.from(params));
@ -609,20 +1121,20 @@ class Mop {
_appletHandlerApis["getUserInfo"] = (params) { _appletHandlerApis["getUserInfo"] = (params) {
return handler.getUserInfo(); return handler.getUserInfo();
}; };
// _appletHandlerApis["getCustomMenus"] = (params) async { _appletHandlerApis["getCustomMenus"] = (params) async {
// final res = await handler.getCustomMenus(params["appId"]); final res = await handler.getCustomMenus(params["appId"]);
// List<Map<String, dynamic>> list = []; List<Map<String, dynamic>> list = [];
// res.forEach((element) { res.forEach((element) {
// Map<String, dynamic> map = Map(); Map<String, dynamic> map = Map();
// map["menuId"] = element.menuId; map["menuId"] = element.menuId;
// map["image"] = element.image; map["image"] = element.image;
// map["title"] = element.title; map["title"] = element.title;
// map["type"] = element.type; map["type"] = element.type;
// list.add(map); list.add(map);
// }); });
// debugPrint("registerAppletHandler getCustomMenus list $list"); debugPrint("registerAppletHandler getCustomMenus list $list");
// return list; return list;
// }; };
_appletHandlerApis["onCustomMenuClick"] = (params) async { _appletHandlerApis["onCustomMenuClick"] = (params) async {
return handler.onCustomMenuClick( return handler.onCustomMenuClick(
params["appId"], params["appId"],
@ -641,10 +1153,8 @@ class Mop {
_channel.invokeMethod("registerAppletHandler"); _channel.invokeMethod("registerAppletHandler");
} }
///
/// register extension api /// register extension api
/// api /// api
///
void registerExtensionApi(String name, ExtensionApiHandler handler) { void registerExtensionApi(String name, ExtensionApiHandler handler) {
_extensionApis[name] = handler; _extensionApis[name] = handler;
_channel.invokeMethod("registerExtensionApi", {"name": name}); _channel.invokeMethod("registerExtensionApi", {"name": name});
@ -665,33 +1175,26 @@ class Mop {
return; return;
} }
///
/// ///
///
Future<void> closeApplet(String appletId, bool animated) async { Future<void> closeApplet(String appletId, bool animated) async {
await _channel.invokeMethod( await _channel.invokeMethod(
"closeApplet", {"appletId": appletId, "animated": animated}); "closeApplet", {"appletId": appletId, "animated": animated});
return; return;
} }
///
/// ///
///
Future<void> finishRunningApplet(String appletId, bool animated) async { Future<void> finishRunningApplet(String appletId, bool animated) async {
await _channel.invokeMethod( await _channel.invokeMethod(
"finishRunningApplet", {"appletId": appletId, "animated": animated}); "finishRunningApplet", {"appletId": appletId, "animated": animated});
return; return;
} }
///
/// ///
///
Future setActivityTransitionAnim(Anim anim) async { Future setActivityTransitionAnim(Anim anim) async {
await _channel.invokeMethod("setActivityTransitionAnim", {"anim": ""}); await _channel.invokeMethod("setActivityTransitionAnim", {"anim": ""});
return; return;
} }
///
/// ///
/// [appId] id /// [appId] id
/// [eventData] /// [eventData]
@ -702,13 +1205,11 @@ class Mop {
return; return;
} }
///
/// webviewjs /// webviewjs
/// [appId] id /// [appId] id
/// [eventName] /// [eventName]
/// [nativeViewId] webviewId /// [nativeViewId] webviewId
/// [eventData] /// [eventData]
///
Future<void> callJS(String appId, String eventName, String nativeViewId, Future<void> callJS(String appId, String eventName, String nativeViewId,
Map<String, dynamic> eventData) async { Map<String, dynamic> eventData) async {
await _channel.invokeMethod("callJS", { await _channel.invokeMethod("callJS", {
@ -720,18 +1221,14 @@ class Mop {
return; return;
} }
///
/// register webview extension api /// register webview extension api
/// webviewapi /// webviewapi
///
void addWebExtentionApi(String name, ExtensionApiHandler handler) { void addWebExtentionApi(String name, ExtensionApiHandler handler) {
_webExtensionApis[name] = handler; _webExtensionApis[name] = handler;
_channel.invokeMethod("addWebExtentionApi", {"name": name}); _channel.invokeMethod("addWebExtentionApi", {"name": name});
} }
///
/// ///
///
void moveCurrentAppletToFront() async { void moveCurrentAppletToFront() async {
return await _channel.invokeMethod("moveCurrentAppletToFront"); return await _channel.invokeMethod("moveCurrentAppletToFront");
} }