Feat/start applet

master
wanghualei 2022-07-29 14:31:56 +00:00
parent fc3dd3e550
commit ed0ba0b3c0
11 changed files with 233 additions and 36 deletions

View File

@ -91,6 +91,6 @@ kapt {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:2.37.4-alpha20220727v13'
implementation 'com.finogeeks.mop:plugins:2.37.1'
implementation 'com.finogeeks.lib:finapplet:2.37.3'
implementation 'com.finogeeks.mop:plugins:2.37.3'
}

View File

@ -91,6 +91,7 @@ public class AppletManageModule extends BaseApi {
FinAppClient.INSTANCE.getAppletApiManager().clearApplets();
callback.onSuccess(null);
} else if (event.equals("removeUsedApplet")) {
Log.d("MopPlugin", "removeUsedApplet:params:" + param);
if (param.containsKey("appId") && param.get("appId") instanceof String) {
String appId = (String) param.get("appId");
FinAppClient.INSTANCE.getAppletApiManager().removeUsedApplet(appId);

View File

@ -31,7 +31,7 @@ public class AppletModule extends BaseApi {
@Override
public String[] apis() {
return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet", "changeUserId"};
return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet", "changeUserId", "startApplet"};
}
@Override
@ -44,6 +44,8 @@ public class AppletModule extends BaseApi {
qrcodeOpenApplet(param,callback);
} else if ("changeUserId".equals(event)) {
changeUserId(param, callback);
} else if ("startApplet".equals(event)) {
startApplet(param, callback);
}
}
@ -118,6 +120,43 @@ public class AppletModule extends BaseApi {
callback.onSuccess(new HashMap());
}
private void startApplet(Map param, ICallback callback) {
if (param.get("appletId") == null) {
callback.onFail(new HashMap() {
{
put("info", "appId不能为空");
}
});
return;
}
Log.d("MopPlugin", "startApplet:params:" + param);
String appId = String.valueOf(param.get("appletId"));
Integer sequence = (Integer) param.get("sequence");
Map<String, String> params = (Map) param.get("startParams");
String apiServer = (String) param.get("apiServer");
String offlineMiniprogramZipPath = (String) param.get("offlineMiniprogramZipPath");
String offlineFrameworkZipPath = (String) param.get("offlineFrameworkZipPath");
Log.d("MopPlugin", "startApplet (appId=" + appId + ", sequence=" + sequence + " apiServer=" + apiServer + ")");
// mContextFlutterActivity
// Android 6.07.0contextmContext
// 使Application Context
Context context = mContext.getApplicationContext();
// String dir = context.getFilesDir();
// FinAppInfo.StartParams startParams = params == null ? null : new FinAppInfo.StartParams(params.get("path"), params.get("query"), params.get("scene"));
// Log.d(TAG, "openApplet:" + appId + "," + param + "," + apiServer);
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context,
IFinAppletRequest.Companion.fromAppId(apiServer, appId)
.setSequence(sequence)
.setStartParams(params)
.setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath),
null);
// request
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, IFinAppletRequest.Companion.fromAppId("apiServer", "appId")
// .setStartParams(params).setOfflinexxxx);
callback.onSuccess(new HashMap());
}
private void scanOpenApplet(Map param, ICallback callback) {
String info = String.valueOf(param.get("info"));
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info), null);

View File

@ -41,5 +41,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>

View File

@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0"
version: "1.16.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.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
@ -95,6 +95,13 @@ 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,14 +115,14 @@ packages:
path: ".."
relative: true
source: path
version: "2.36.3"
version: "2.37.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
@ -127,7 +134,7 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
@ -162,21 +169,14 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.2.3"

View File

@ -126,7 +126,7 @@
return;
}
// [[FATExtClient sharedClient] fat_prepareExtensionApis];
[[FATClient sharedClient].logManager initLogWithLogDir:nil logLevel:FATLogLevelVerbose consoleLog:YES];
[[FATClient sharedClient] setEnableLog:YES];

View File

@ -0,0 +1,24 @@
//
// MOP_openApplet.h
// mop
//
// Created by on 2020/2/27.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_startApplet : MOPBaseApi
@property (nonatomic, copy) NSString *appletId;
@property (nonatomic, copy) NSString *apiServer;
@property (nonatomic, copy) NSString *sequence;
@property (nonatomic, copy) NSDictionary *startParams;
@property (nonatomic, copy) NSString *offlineMiniprogramZipPath;
@property (nonatomic, copy) NSString *offlineFrameworkZipPath;
@property (nonatomic, strong) NSString *animated;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,40 @@
//
// MOP_openApplet.m
// mop
//
// Created by on 2020/2/27.
//
#import "MOP_startApplet.h"
#import "MOPTools.h"
#import <FinApplet/FinApplet.h>
@implementation MOP_startApplet
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
UIViewController *currentVC = [MOPTools topViewController];
FATAppletRequest *request = [[FATAppletRequest alloc] init];
request.appletId = self.appletId;
request.apiServer = self.apiServer;
request.startParams = self.startParams;
if (self.sequence){
request.sequence = @([self.sequence intValue]);
}
request.offlineMiniprogramZipPath = self.offlineMiniprogramZipPath;
request.offlineFrameworkZipPath = self.offlineFrameworkZipPath;
request.animated = [self.animated boolValue];
//
[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:currentVC completion:^(BOOL result, NSError *error) {
if (result){
success(@{});
} else {
failure(error.description);
}
} closeCompletion:^(void) {
}];
}
@end

View File

@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk.
s.dependency 'Flutter'
s.ios.deployment_target = '9.0'
s.dependency 'FinApplet' , '2.37.3'
s.dependency 'FinAppletExt' , '2.37.3'
s.dependency 'FinApplet' , '2.37.4-alpha20220729v13'
s.dependency 'FinAppletExt' , '2.37.4-alpha20220729v13'
end

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:ffi';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
@ -217,6 +216,91 @@ class FloatWindowConfig {
}
}
class BaseAppletRequest {
//
String apiServer;
// id
String appletId;
//
Map<String, String>? startParams;
// iOStrue
bool? animated;
BaseAppletRequest({
required this.apiServer,
required this.appletId,
this.startParams,
this.animated = true,
});
Map<String, dynamic> toMap() {
return {
"apiServer": apiServer,
"appletId": appletId,
"startParams": startParams,
"animated": animated
};
}
}
class RemoteAppletRequest {
//
String apiServer;
// id
String appletId;
//
Map<String, String>? startParams;
//
int? sequence;
// 线
String? offlineMiniprogramZipPath;
// 线
String? offlineFrameworkZipPath;
// iOStrue
bool animated;
RemoteAppletRequest({
required this.apiServer,
required this.appletId,
this.startParams,
this.sequence,
this.offlineMiniprogramZipPath,
this.offlineFrameworkZipPath,
this.animated = true,
});
@override
Map<String, dynamic> toMap() {
Map<String, dynamic> result = {
"apiServer": apiServer,
"appletId": appletId,
"animated": animated
};
if (startParams != null) result["startParams"] = startParams;
if (offlineMiniprogramZipPath != null) result["offlineMiniprogramZipPath"] = offlineMiniprogramZipPath;
if (offlineFrameworkZipPath != null) result["offlineFrameworkZipPath"] = offlineFrameworkZipPath;
if (sequence != null) result["sequence"] = sequence;
return result;
}
}
class QRCodeAppletRequest {
//
String qrCode;
//
bool animated = true;
QRCodeAppletRequest(this.qrCode);
Map<String, dynamic> toMap() {
return {
"apiServer": qrCode,
"animated": animated
};
}
}
enum Anim {
SlideFromLeftToRightAnim,
SlideFromRightToLeftAnim,
@ -376,6 +460,13 @@ class Mop {
return ret;
}
Future<Map> startApplet(RemoteAppletRequest request) async {
Map<String, dynamic> params = request.toMap();
final Map ret = await _channel.invokeMethod('startApplet', params);
return ret;
}
///
/// get current using applet
/// 使

View File

@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
@ -88,6 +88,13 @@ 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:
@ -101,7 +108,7 @@ packages:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
@ -113,7 +120,7 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
@ -148,21 +155,14 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.2.3"