1.fix merge conflict

master
Justson 2020-12-08 09:41:43 +08:00
commit 3f96bafef7
4 changed files with 70 additions and 16 deletions

View File

@ -91,5 +91,6 @@ kapt {
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:2.12.35' implementation 'com.finogeeks.lib:finapplet:2.13.4'
implementation 'com.finogeeks.mop:plugins:0.0.23'
} }

View File

@ -4,6 +4,8 @@ import android.content.Context;
import android.util.Log; import android.util.Log;
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.FinAppInfo;
import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.interfaces.ICallback;
@ -22,7 +24,6 @@ public class AppletModule extends BaseApi {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
} }
@Override @Override
@ -40,6 +41,7 @@ public class AppletModule extends BaseApi {
}); });
return; return;
} }
Log.d("MopPlugin", "openApplet:params:" + param);
String appId = String.valueOf(param.get("appId")); String appId = String.valueOf(param.get("appId"));
Integer sequence = (Integer) param.get("sequence"); Integer sequence = (Integer) param.get("sequence");
Map<String, String> params = (Map) param.get("params"); Map<String, String> params = (Map) param.get("params");
@ -50,9 +52,43 @@ public class AppletModule extends BaseApi {
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, sequence, null); FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, sequence, null);
} }
} else { } else {
Log.d("MopPlugin", "openApplet:params:" + param);
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, params); FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, params);
} }
// String apiServer = (String) param.get("apiServer");
// String apiPrefix = (String) param.get("apiPrefix");
// if (apiServer == null || apiServer.isEmpty() || apiPrefix == null || apiPrefix.isEmpty()) {
// if (params == null) {
// if (sequence == null) {
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId);
// } else {
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, sequence, null);
// }
// } else {
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, params);
// }
// } else {
// String fingerprint = (String) param.get("fingerprint");
// if (fingerprint == null) {
// fingerprint = "";
// }
// String cryptType = (String) param.get("cryptType");
// if (cryptType == null || cryptType.isEmpty()) {
// cryptType = FinAppConfig.ENCRYPTION_TYPE_MD5;
// }
// FinAppletStoreConfig finAppletStoreConfig = new FinAppletStoreConfig(apiServer, apiPrefix, fingerprint, cryptType);
// FinAppInfo.StartParams startParams = null;
// if (params != null) {
// String pageURL = params.get("path");
// String launchParams = params.get("query");
// String scene = params.get("scene");
// startParams = new FinAppInfo.StartParams(pageURL, launchParams, scene);
// }
// Log.d("MopPlugin", "openApplet:finAppletStoreConfig:" + finAppletStoreConfig.toString());
// Log.d("MopPlugin", "openApplet:appId:" + appId);
// Log.d("MopPlugin", "openApplet:sequence:" + sequence);
// Log.d("MopPlugin", "openApplet:startParams:" + startParams);
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, finAppletStoreConfig, appId, sequence, startParams);
// }
callback.onSuccess(new HashMap()); callback.onSuccess(new HashMap());
} }
} }

View File

@ -1,14 +1,17 @@
package com.finogeeks.mop.api.mop; package com.finogeeks.mop.api.mop;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
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.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.interfaces.ICallback; import com.finogeeks.mop.interfaces.ICallback;
import com.finogeeks.mop.plugins.client.FinPluginClient;
import com.finogeeks.mop.service.MopPluginService; import com.finogeeks.mop.service.MopPluginService;
import java.util.HashMap; import java.util.HashMap;
@ -61,19 +64,22 @@ public class BaseModule extends BaseApi {
disablePermission = false; disablePermission = false;
} }
FinAppConfig config = new FinAppConfig.Builder() FinAppConfig config = new FinAppConfig.Builder()
.setAppKey(appkey) .setSdkKey(appkey)
.setAppSecret(secret) .setSdkSecret(secret)
.setApiUrl(apiServer) .setApiUrl(apiServer)
.setApiPrefix(apiPrefix) .setApiPrefix(apiPrefix)
.setGlideWithJWT(false)
.setEncryptionType(cryptType) .setEncryptionType(cryptType)
.setDebugMode(BuildConfig.DEBUG)
.setDisableRequestPermissions(disablePermission) .setDisableRequestPermissions(disablePermission)
.build(); .build();
final Application application = MopPluginService.getInstance().getActivity().getApplication();
// SDKSDK // SDKSDK
FinCallback<Object> cb = new FinCallback<Object>() { FinCallback<Object> cb = new FinCallback<Object>() {
@Override @Override
public void onSuccess(Object result) { public void onSuccess(Object result) {
// SDK // SDK
FinPluginClient.INSTANCE.getPluginManager().registerPlugins(application);
callback.onSuccess(null); callback.onSuccess(null);
} }
@ -89,8 +95,6 @@ public class BaseModule extends BaseApi {
} }
}; };
FinAppClient.INSTANCE.init(MopPluginService.getInstance().getActivity().getApplication(), config, cb); FinAppClient.INSTANCE.init(application, config, cb);
} }
} }

View File

@ -85,23 +85,36 @@ class Mop {
return ret; return ret;
} }
///
///
/// open the miniprogram [appId] from the mop server. /// open the miniprogram [appId] from the mop server.
/// ///
/// [appId] is required. /// [appId] is required.
/// [path] is miniprogram open path. example /pages/index/index /// [path] is miniprogram open path. example /pages/index/index
/// [query] is miniprogram query parameters. example key1=value1&key2=value2 /// [query] is miniprogram query parameters. example key1=value1&key2=value2
/// /// [sequence] is miniprogram sequence. example 0,1.2.3,4,5...
/// /// [apiServer] is optional. the mop server address. default is https://mp.finogeek.com
Future<Map> openApplet(final String appId, /// [apiPrefix] is optional. the mop server prefix. default is /api/v1/mop
{final String path, final String query, final int sequence}) async { /// [fingerprint] is optional. the mop sdk fingerprint. is nullable
/// [cryptType] is optional. cryptType, should be MD5/SM
Future<Map> openApplet(
final String appId, {
final String path,
final String query,
final int sequence,
final String apiServer,
final String apiPrefix,
final String fingerprint,
final String cryptType,
}) async {
Map<String, Object> params = {'appId': appId}; Map<String, Object> params = {'appId': appId};
Map param = {}; Map param = {};
if (path != null) param["path"] = path; if (path != null) param["path"] = path;
if (query != null) param["query"] = query; if (query != null) param["query"] = query;
if (param.length > 0) params["params"] = param; if (param.length > 0) params["params"] = param;
if (sequence != null) params["sequence"] = sequence; if (sequence != null) params["sequence"] = sequence;
if (apiServer != null) params["apiServer"] = apiServer;
if (apiPrefix != null) params["apiPrefix"] = apiPrefix;
if (fingerprint != null) params["fingerprint"] = fingerprint;
if (cryptType != null) params["cryptType"] = cryptType;
final Map ret = await _channel.invokeMethod('openApplet', params); final Map ret = await _channel.invokeMethod('openApplet', params);
return ret; return ret;
} }