Merge branch 'feat/singleprocess' into 2.39.0
# Conflicts: # android/build.gradle # android/src/main/java/com/finogeeks/mop/api/mop/AppletManageModule.javamaster
commit
1cda8dcd14
|
@ -11,6 +11,8 @@ import com.finogeeks.lib.applet.anim.SlideFromRightToLeftAnim;
|
|||
import com.finogeeks.lib.applet.anim.SlideFromTopToBottomAnim;
|
||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
||||
import com.finogeeks.lib.applet.client.FinAppInfo;
|
||||
import com.finogeeks.lib.applet.client.FinAppProcessClient;
|
||||
import com.finogeeks.lib.applet.db.entity.FinApplet;
|
||||
import com.finogeeks.lib.applet.interfaces.FinCallback;
|
||||
import com.finogeeks.lib.applet.rest.model.WechatLoginInfo;
|
||||
import com.finogeeks.mop.api.BaseApi;
|
||||
|
@ -54,6 +56,7 @@ public class AppletManageModule extends BaseApi {
|
|||
res.put("version", appletInfo.getAppVersion());
|
||||
res.put("thumbnail", appletInfo.getAppThumbnail());
|
||||
res.put("appletType", appletInfo.getAppType());
|
||||
res.put("isSingleProcess", FinAppProcessClient.INSTANCE.getAppletProcessActivity(applet.getId()) != null);
|
||||
Map<String, String> wechatLoginInfo = new HashMap<>(4);
|
||||
WechatLoginInfo wechatLogin = appletInfo.getWechatLoginInfo();
|
||||
if (wechatLogin != null) {
|
||||
|
|
|
@ -63,23 +63,31 @@ public class AppletModule extends BaseApi {
|
|||
Integer sequence = (Integer) param.get("sequence");
|
||||
Map<String, String> params = (Map) param.get("params");
|
||||
String apiServer = (String) param.get("apiServer");
|
||||
Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
|
||||
// mContext是FlutterActivity,
|
||||
// 在Android 6.0、7.0系统的部分设备中热启动小程序时,如果context参数用mContext,会出现无法启动小程序的问题
|
||||
// 所以这里使用Application Context
|
||||
Context context = mContext.getApplicationContext();
|
||||
FinAppInfo.StartParams startParams = params == null ? null : new FinAppInfo.StartParams(params.get("path"), params.get("query"), params.get("scene"));
|
||||
Log.d(TAG, "openApplet:" + appId + "," + param + "," + sequence + "," + apiServer);
|
||||
Log.d(TAG, "openApplet:" + appId + "," + param + "," + sequence + "," + apiServer + ", isSingleProcess:" + isSingleProcess);
|
||||
|
||||
if (apiServer != null) {
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context,
|
||||
IFinAppletRequest.Companion.fromAppId(apiServer, appId)
|
||||
.setStartParams(startParams)
|
||||
.setSequence(sequence),
|
||||
.setSequence(sequence)
|
||||
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)),
|
||||
null
|
||||
);
|
||||
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, apiServer, appId, sequence, startParams,null);
|
||||
} else {
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, appId, sequence, startParams,null);
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context,
|
||||
IFinAppletRequest.Companion.fromAppId(appId)
|
||||
.setStartParams(startParams)
|
||||
.setSequence(sequence)
|
||||
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
// String apiServer = (String) param.get("apiServer");
|
||||
|
@ -136,6 +144,8 @@ public class AppletModule extends BaseApi {
|
|||
String apiServer = (String) param.get("apiServer");
|
||||
String offlineMiniprogramZipPath = (String) param.get("offlineMiniprogramZipPath");
|
||||
String offlineFrameworkZipPath = (String) param.get("offlineFrameworkZipPath");
|
||||
Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
|
||||
|
||||
Log.d("MopPlugin", "startApplet (appId=" + appId + ", sequence=" + sequence + " apiServer=" + apiServer + ")");
|
||||
// mContext是FlutterActivity,
|
||||
// 在Android 6.0、7.0系统的部分设备中热启动小程序时,如果context参数用mContext,会出现无法启动小程序的问题
|
||||
|
@ -149,7 +159,8 @@ public class AppletModule extends BaseApi {
|
|||
IFinAppletRequest.Companion.fromAppId(apiServer, appId)
|
||||
.setSequence(sequence)
|
||||
.setStartParams(params)
|
||||
.setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath),
|
||||
.setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath)
|
||||
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)),
|
||||
null);
|
||||
// 改成通过request来启动小程序
|
||||
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, IFinAppletRequest.Companion.fromAppId("apiServer", "appId")
|
||||
|
@ -159,14 +170,18 @@ public class AppletModule extends BaseApi {
|
|||
|
||||
private void scanOpenApplet(Map param, ICallback callback) {
|
||||
String info = String.valueOf(param.get("info"));
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info), null);
|
||||
Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info)
|
||||
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)), null);
|
||||
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, new StartAppletDecryptRequest(info),null);
|
||||
callback.onSuccess(new HashMap());
|
||||
}
|
||||
|
||||
private void qrcodeOpenApplet(Map param, ICallback callback){
|
||||
String qrcode = String.valueOf(param.get("qrcode"));
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode), new FinCallback<String>() {
|
||||
Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
|
||||
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode)
|
||||
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)), new FinCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
callback.onSuccess(new HashMap());
|
||||
|
|
|
@ -12,9 +12,11 @@ import com.finogeeks.lib.applet.interfaces.FinCallback;
|
|||
import com.finogeeks.mop.api.BaseApi;
|
||||
import com.finogeeks.mop.interfaces.ICallback;
|
||||
import com.finogeeks.mop.service.MopPluginService;
|
||||
import com.finogeeks.xlog.XLogLevel;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -121,7 +123,9 @@ public class BaseModule extends BaseApi {
|
|||
.setUserId(userId)
|
||||
.setDebugMode(debug)
|
||||
.setDisableRequestPermissions(disablePermission)
|
||||
.setBindAppletWithMainProcess(bindAppletWithMainProcess);
|
||||
.setBindAppletWithMainProcess(bindAppletWithMainProcess)
|
||||
.setLogLevel(XLogLevel.LEVEL_VERBOSE)
|
||||
.setXLogDir(new File(getContext().getExternalCacheDir(),"xlog"));
|
||||
// .setPageCountLimit(pageCountLimit);
|
||||
|
||||
if (customWebViewUserAgent != null)
|
||||
|
|
|
@ -42,7 +42,7 @@ packages:
|
|||
name: collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
version: "1.15.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -56,7 +56,7 @@ packages:
|
|||
name: fake_async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.2.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -95,13 +95,6 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -115,14 +108,14 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "2.37.3"
|
||||
version: "2.37.13"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -134,7 +127,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
version: "1.8.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -169,14 +162,21 @@ packages:
|
|||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.9"
|
||||
version: "0.4.3"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.1"
|
||||
sdks:
|
||||
dart: ">=2.17.0-0 <3.0.0"
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
flutter: ">=2.2.3"
|
||||
|
|
35
lib/mop.dart
35
lib/mop.dart
|
@ -225,12 +225,15 @@ class BaseAppletRequest {
|
|||
Map<String, String>? startParams;
|
||||
// iOS端打开小程序时是否显示动画,默认为true。
|
||||
bool? animated;
|
||||
// 是否以单进程模式运行,仅限android,默认为false
|
||||
bool isSingleProcess;
|
||||
|
||||
BaseAppletRequest({
|
||||
required this.apiServer,
|
||||
required this.appletId,
|
||||
this.startParams,
|
||||
this.animated = true,
|
||||
this.isSingleProcess = false,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
|
@ -238,7 +241,8 @@ class BaseAppletRequest {
|
|||
"apiServer": apiServer,
|
||||
"appletId": appletId,
|
||||
"startParams": startParams,
|
||||
"animated": animated
|
||||
"animated": animated,
|
||||
"isSingleProcess": isSingleProcess,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -258,6 +262,8 @@ class RemoteAppletRequest {
|
|||
String? offlineFrameworkZipPath;
|
||||
// iOS端打开小程序时是否显示动画,默认为true。
|
||||
bool animated;
|
||||
// 是否以单进程模式运行,仅限android,默认为false
|
||||
bool isSingleProcess;
|
||||
|
||||
RemoteAppletRequest({
|
||||
required this.apiServer,
|
||||
|
@ -267,6 +273,7 @@ class RemoteAppletRequest {
|
|||
this.offlineMiniprogramZipPath,
|
||||
this.offlineFrameworkZipPath,
|
||||
this.animated = true,
|
||||
this.isSingleProcess = false,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -274,7 +281,8 @@ class RemoteAppletRequest {
|
|||
Map<String, dynamic> result = {
|
||||
"apiServer": apiServer,
|
||||
"appletId": appletId,
|
||||
"animated": animated
|
||||
"animated": animated,
|
||||
"isSingleProcess": isSingleProcess,
|
||||
};
|
||||
if (startParams != null) result["startParams"] = startParams;
|
||||
if (offlineMiniprogramZipPath != null) result["offlineMiniprogramZipPath"] = offlineMiniprogramZipPath;
|
||||
|
@ -290,13 +298,16 @@ class QRCodeAppletRequest {
|
|||
String qrCode;
|
||||
// 是否显示打开动画
|
||||
bool animated = true;
|
||||
// 是否以单进程模式运行,仅限android,默认为false
|
||||
bool isSingleProcess;
|
||||
|
||||
QRCodeAppletRequest(this.qrCode);
|
||||
QRCodeAppletRequest(this.qrCode, {this.isSingleProcess = false});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"apiServer": qrCode,
|
||||
"animated": animated
|
||||
"animated": animated,
|
||||
"isSingleProcess": isSingleProcess,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -447,6 +458,7 @@ class Mop {
|
|||
final int? sequence,
|
||||
final String? apiServer,
|
||||
final String? scene,
|
||||
final bool isSingleProcess = false,
|
||||
}) async {
|
||||
Map<String, Object> params = {'appId': appId};
|
||||
Map param = {};
|
||||
|
@ -456,6 +468,7 @@ class Mop {
|
|||
if (sequence != null) params["sequence"] = sequence;
|
||||
if (apiServer != null) params["apiServer"] = apiServer;
|
||||
if (scene != null) param["scene"] = scene;
|
||||
params["isSingleProcess"] = isSingleProcess;
|
||||
final Map ret = await _channel.invokeMethod('openApplet', params);
|
||||
return ret;
|
||||
}
|
||||
|
@ -524,8 +537,11 @@ class Mop {
|
|||
///
|
||||
/// (扫码后)解密-鉴权-打开小程序
|
||||
///
|
||||
Future scanOpenApplet(String info) async {
|
||||
Map<String, Object> params = {'info': info};
|
||||
Future scanOpenApplet(String info, {bool isSingleProcess = false}) async {
|
||||
Map<String, Object> params = {
|
||||
'info': info,
|
||||
'isSingleProcess': isSingleProcess,
|
||||
};
|
||||
return await _channel.invokeMapMethod("scanOpenApplet", params);
|
||||
}
|
||||
|
||||
|
@ -533,8 +549,11 @@ class Mop {
|
|||
/// 通过二维码打开小程序
|
||||
/// [qrcode] 二维码内容
|
||||
///
|
||||
Future qrcodeOpenApplet(String qrcode) async {
|
||||
Map<String, Object> params = {'qrcode': qrcode};
|
||||
Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async {
|
||||
Map<String, Object> params = {
|
||||
'qrcode': qrcode,
|
||||
'isSingleProcess': isSingleProcess,
|
||||
};
|
||||
return await _channel.invokeMapMethod("qrcodeOpenApplet", params);
|
||||
}
|
||||
|
||||
|
|
28
pubspec.lock
28
pubspec.lock
|
@ -42,14 +42,14 @@ packages:
|
|||
name: collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
version: "1.15.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.2.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -88,13 +88,6 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -108,7 +101,7 @@ packages:
|
|||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -120,7 +113,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
version: "1.8.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -155,14 +148,21 @@ packages:
|
|||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.9"
|
||||
version: "0.4.3"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.1"
|
||||
sdks:
|
||||
dart: ">=2.17.0-0 <3.0.0"
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
flutter: ">=2.2.3"
|
||||
|
|
Loading…
Reference in New Issue