From e73f590f04499c9206a008390bb3c8ec512ea07c Mon Sep 17 00:00:00 2001 From: kangxuyao Date: Wed, 28 Sep 2022 14:49:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8D=95=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- .../finogeeks/mop/api/mop/AppletModule.java | 27 ++++++++++--- .../com/finogeeks/mop/api/mop/BaseModule.java | 6 ++- example/pubspec.lock | 30 +++++++------- lib/mop.dart | 39 ++++++++++++++----- pubspec.lock | 28 ++++++------- 6 files changed, 85 insertions(+), 47 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 0f9e541..0c8e7ad 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.38.1' + implementation 'com.finogeeks.lib:finapplet:2.38.0-alpha20220927v03' implementation 'com.finogeeks.mop:plugins:2.38.1' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java index d14d97c..9091047 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java @@ -63,23 +63,31 @@ public class AppletModule extends BaseApi { Integer sequence = (Integer) param.get("sequence"); Map 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() { + Boolean isSingleProcess = (Boolean) param.get("isSingleProcess"); + FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode) + .setSingleProcess(Boolean.TRUE.equals(isSingleProcess)), new FinCallback() { @Override public void onSuccess(String s) { callback.onSuccess(new HashMap()); diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java index 8cb637f..802b8e2 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java @@ -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) diff --git a/example/pubspec.lock b/example/pubspec.lock index e86417e..f69158c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -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" diff --git a/lib/mop.dart b/lib/mop.dart index 7bd54a8..4719a22 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -225,12 +225,15 @@ class BaseAppletRequest { Map? startParams; // iOS端打开小程序时是否显示动画,默认为true。 bool? animated; + // 是否以单进程模式运行,仅限android,默认为false + bool isSingleProcess; BaseAppletRequest({ - required this.apiServer, + required this.apiServer, required this.appletId, this.startParams, this.animated = true, + this.isSingleProcess = false, }); Map toMap() { @@ -238,7 +241,8 @@ class BaseAppletRequest { "apiServer": apiServer, "appletId": appletId, "startParams": startParams, - "animated": animated + "animated": animated, + "isSingleProcess": isSingleProcess, }; } } @@ -258,15 +262,18 @@ class RemoteAppletRequest { String? offlineFrameworkZipPath; // iOS端打开小程序时是否显示动画,默认为true。 bool animated; +// 是否以单进程模式运行,仅限android,默认为false + bool isSingleProcess; RemoteAppletRequest({ - required this.apiServer, + required this.apiServer, required this.appletId, this.startParams, this.sequence, this.offlineMiniprogramZipPath, this.offlineFrameworkZipPath, this.animated = true, + this.isSingleProcess = false, }); @override @@ -274,7 +281,8 @@ class RemoteAppletRequest { Map 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 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 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 params = {'info': info}; + Future scanOpenApplet(String info, {bool isSingleProcess = false}) async { + Map params = { + 'info': info, + 'isSingleProcess': isSingleProcess, + }; return await _channel.invokeMapMethod("scanOpenApplet", params); } @@ -533,8 +549,11 @@ class Mop { /// 通过二维码打开小程序 /// [qrcode] 二维码内容 /// - Future qrcodeOpenApplet(String qrcode) async { - Map params = {'qrcode': qrcode}; + Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async { + Map params = { + 'qrcode': qrcode, + 'isSingleProcess': isSingleProcess, + }; return await _channel.invokeMapMethod("qrcodeOpenApplet", params); } diff --git a/pubspec.lock b/pubspec.lock index 7d68fe5..f39f99b 100644 --- a/pubspec.lock +++ b/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" From 6da2bbc7a7a3cafcd918083d5f5ff16e280ff397 Mon Sep 17 00:00:00 2001 From: kangxuyao Date: Wed, 28 Sep 2022 17:05:11 +0800 Subject: [PATCH 2/4] =?UTF-8?q?currentApplet=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E6=A8=A1=E5=BC=8F=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/finogeeks/mop/api/mop/AppletManageModule.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletManageModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletManageModule.java index 818ecfe..0de62e1 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletManageModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletManageModule.java @@ -10,6 +10,7 @@ import com.finogeeks.lib.applet.anim.SlideFromLeftToRightAnim; 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.FinAppProcessClient; import com.finogeeks.lib.applet.db.entity.FinApplet; import com.finogeeks.lib.applet.interfaces.FinCallback; import com.finogeeks.lib.applet.rest.model.WechatLoginInfo; @@ -51,6 +52,7 @@ public class AppletManageModule extends BaseApi { res.put("description", applet.getDescription()); res.put("version", applet.getVersion()); res.put("thumbnail", applet.getThumbnail()); + res.put("isSingleProcess", FinAppProcessClient.INSTANCE.getAppletProcessActivity(applet.getId()) != null); Map wechatLoginInfo = new HashMap<>(3); WechatLoginInfo wechatLogin = applet.getWechatLoginInfo(); if (wechatLogin != null) { From 03a5b667a8761c013addacf82258d4089c492dbe Mon Sep 17 00:00:00 2001 From: kangxuyao Date: Wed, 28 Sep 2022 17:45:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0sdk=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 0c8e7ad..2e26099 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.38.0-alpha20220927v03' + implementation 'com.finogeeks.lib:finapplet:2.39.0-alpha20220928v01' implementation 'com.finogeeks.mop:plugins:2.38.1' } \ No newline at end of file From 7e8f0f7bd509da700d9cef70fe086d1721688d5e Mon Sep 17 00:00:00 2001 From: yangbingqiao Date: Wed, 12 Oct 2022 18:15:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=EF=BC=9A=E6=8F=90=E5=8D=87sdk=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 2e26099..37fd322 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.39.0-alpha20220928v01' + implementation 'com.finogeeks.lib:finapplet:2.39.0-alpha20221012v01' implementation 'com.finogeeks.mop:plugins:2.38.1' } \ No newline at end of file