add android interface

master
developer 2020-02-27 22:59:31 +08:00
parent e1420716b5
commit e8be3294a0
39 changed files with 794 additions and 143 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
.idea
publish.sh
.DS_Store .DS_Store
.dart_tool/ .dart_tool/

View File

@ -1,19 +0,0 @@
<component name="libraryTable">
<library name="Dart SDK">
<CLASSES>
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/async" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/collection" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/convert" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/core" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/developer" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/html" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/io" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/isolate" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/math" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/mirrors" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/typed_data" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Flutter for Android">
<CLASSES>
<root url="jar:///opt/flutter/bin/cache/artifacts/engine/android-arm/flutter.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/mop.iml" filepath="$PROJECT_DIR$/mop.iml" />
<module fileurl="file://$PROJECT_DIR$/android/mop_android.iml" filepath="$PROJECT_DIR$/android/mop_android.iml" />
<module fileurl="file://$PROJECT_DIR$/example/android/mop_example_android.iml" filepath="$PROJECT_DIR$/example/android/mop_example_android.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="example/lib/main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="filePath" value="$PROJECT_DIR$/example/lib/main.dart" />
<method />
</configuration>
</component>

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="mop.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/mop.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="ToolWindowManager">
<editor active="true" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
</layout>
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
</navigator>
<panes>
<pane id="ProjectPane">
<option name="show-excluded-files" value="false" />
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
</project>

View File

@ -1,3 +1,10 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
group 'com.finogeeks.mop' group 'com.finogeeks.mop'
version '1.0' version '1.0'
@ -5,10 +12,21 @@ buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
maven {
url "https://gradle.finogeeks.club/repository/finogeeks/"
credentials {
username "xiaoyu"
password "xy123456"
}
}
maven { url "https://jitpack.io" }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.60"
} }
} }
@ -16,19 +34,50 @@ rootProject.allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
maven {
url "https://gradle.finogeeks.club/repository/finogeeks/"
credentials {
username "xiaoyu"
password "xy123456"
}
}
maven { url "https://jitpack.io" }
} }
} }
apply plugin: 'com.android.library'
android { android {
compileSdkVersion 28 compileSdkVersion 28
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
} }
lintOptions { lintOptions {
disable 'InvalidPackage' disable 'InvalidPackage'
} }
} }
kapt {
arguments {
arg("moduleName", project.getName())
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:2.0.51'
implementation 'org.greenrobot:greendao:3.2.2'
}

View File

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View File

5
android/proguard-rules.pro vendored 100644
View File

@ -0,0 +1,5 @@
-keep class com.finogeeks.** {*;}
# tbs
-keep class com.tencent.smtt.** {*;}
-keep class com.tencent.tbs.** {*;}

View File

@ -0,0 +1,29 @@
package com.finogeeks.mop;
import java.util.HashMap;
import java.util.Map;
import io.flutter.plugin.common.EventChannel;
public class MopEventStream implements EventChannel.StreamHandler {
EventChannel.EventSink mEventSlink;
@Override
public void onListen(Object o, EventChannel.EventSink eventSink) {
mEventSlink = eventSink;
}
@Override
public void onCancel(Object o) {
mEventSlink = null;
}
public void send(String channel,String event,Object body) {
if (mEventSlink != null) {
Map<String,Object> map = new HashMap<>();
map.put("channel",channel);
map.put("event",event);
map.put("body",body);
mEventSlink.success(map);
}
}
}

View File

@ -1,25 +1,99 @@
package com.finogeeks.mop; package com.finogeeks.mop;
import android.content.Intent;
import android.util.Log;
import com.finogeeks.mop.interfaces.Event;
import com.finogeeks.mop.interfaces.FlutterInterface;
import com.finogeeks.mop.interfaces.ICallback;
import com.finogeeks.mop.service.MopPluginService;
import java.util.HashMap;
import java.util.Map;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar; import io.flutter.plugin.common.PluginRegistry.Registrar;
/** MopPlugin */ /** MopPlugin */
public class MopPlugin implements MethodCallHandler { public class MopPlugin implements MethodCallHandler {
/** Plugin registration. */ private static final String LOG_TAG = MopPlugin.class.getSimpleName();
private static final String CHANNEL = "mop";
private PluginRegistry.Registrar registrar;
private FlutterInterface flutterInterface;
private MopPluginDelegate delegate;
/**
* Plugin registration.
*/
public static void registerWith(Registrar registrar) { public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "mop"); final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL);
channel.setMethodCallHandler(new MopPlugin()); final MopPluginDelegate delegate = new MopPluginDelegate(registrar.activity());
final MopPlugin instance = new MopPlugin(registrar,delegate);
channel.setMethodCallHandler(instance);
final EventChannel eventChannel=new EventChannel(registrar.messenger(),"plugins.mop.finogeeks.com/mop_event");
MopEventStream mopEventStream = new MopEventStream();
eventChannel.setStreamHandler(mopEventStream);
MopPluginService.getInstance().initialize(registrar.activity(),mopEventStream);
}
MopPlugin(PluginRegistry.Registrar registrar,MopPluginDelegate delegate) {
this.registrar = registrar;
this.flutterInterface = new FlutterInterface();
this.delegate = delegate;
} }
@Override @Override
public void onMethodCall(MethodCall call, Result result) { public void onMethodCall(MethodCall call, final Result result) {
if (call.method.equals("getPlatformVersion")) { registrar.addActivityResultListener(delegate);
result.success("Android " + android.os.Build.VERSION.RELEASE); ICallback callback = new ICallback<Object>() {
} else { @Override
public void onSuccess(Object data) {
Map<String,Object> obj = new HashMap<String,Object>();
obj.put("success",true);
if (data != null)
obj.put("data",data);
obj.put("retMsg","ok");
result.success(obj);
}
@Override
public void onFail(Object error) {
Map<String,Object> obj = new HashMap<String,Object>();
obj.put("success",false);
obj.put("retMsg",error==null?"":error);
result.success(obj);
}
@Override
public void onCancel(Object cancel) {
result.notImplemented(); result.notImplemented();
} }
@Override
public void startActivityForResult(Intent intent, int requestCode) {
} }
};
Log.d(LOG_TAG,"mopplugin: invoke " + call.method);
Event event= new Event(call.method,call.arguments,callback);
delegate.setEvent(event);
this.flutterInterface.invokeHandler(event);
// if (call.method.equals("getPlatformVersion")) {
// result.success("Android " + android.os.Build.VERSION.RELEASE);
// } else {
// result.notImplemented();
// }
}
} }

View File

@ -0,0 +1,40 @@
package com.finogeeks.mop;
import android.app.Activity;
import android.content.Intent;
import com.finogeeks.mop.constants.Constants;
import com.finogeeks.mop.interfaces.Event;
import com.finogeeks.mop.service.MopPluginService;
import io.flutter.plugin.common.PluginRegistry;
public class MopPluginDelegate implements PluginRegistry.ActivityResultListener {
private Event mEvent;
private final Activity activity;
public Event getEvent() {
return mEvent;
}
public void setEvent(Event event) {
this.mEvent = event;
}
public MopPluginDelegate(final Activity activity) {
this.activity = activity;
}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == Constants.REQUEST_CODE_CHOOSE
|| requestCode == Constants.REQUEST_CODE_LOCATION_CHOOSE
) {
MopPluginService.getInstance().getApisManager().getApiInstance(mEvent).onActivityResult(requestCode, resultCode, data, mEvent.getCallback());
}
return true;
}
}

View File

@ -0,0 +1,36 @@
package com.finogeeks.mop.api;
import android.content.Intent;
import com.finogeeks.mop.interfaces.IApi;
import com.finogeeks.mop.interfaces.ICallback;
public abstract class AbsApi implements IApi {
@Override
public void onCreate() {
}
@Override
public void onDestroy() {
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data, ICallback callback) {
}
@Override
public void onNewIntent(Intent intent) {
}
@Override
public void onResume() {
}
@Override
public void onPause() {
}
}

View File

@ -0,0 +1,76 @@
package com.finogeeks.mop.api;
import android.app.Activity;
import android.text.TextUtils;
import com.finogeeks.mop.api.mop.AppletModule;
import com.finogeeks.mop.api.mop.BaseModule;
import com.finogeeks.mop.interfaces.Event;
import com.finogeeks.mop.interfaces.IApi;
import java.util.HashMap;
import java.util.Map;
public class ApisManager {
private final static String TAG = ApisManager.class.getSimpleName();
public static final int SUCCESS = 0x10;
public static final int FAIL = 0x11;
public static final int CANCEL = 0x12;
public static final int PENDING = 0x13;
private final IApi EMPTY_API = new EmptyApi();
private final Map<String, IApi> APIS = new HashMap<>();
private Activity mActivity;
public ApisManager(Activity activity) {
mActivity = activity;
initSdkApi(activity);
}
/**
* api
*
* @param event apiid
*/
public IApi getApiInstance(Event event) {
IApi api = APIS.get(event.getName());
if (api != null) {
return api;
}
return null;
}
/**
* api
*
* @param event apiid
*/
public void invoke(Event event) {
IApi api = APIS.get(event.getName());
if (api != null) {
api.invoke(event.getName(), event.getParam(), event.getCallback());
return;
}
}
private void initSdkApi(Activity activity) {
add(new BaseModule(activity));
add(new AppletModule(activity));
}
private void add(IApi api) {
if (api != null && api.apis() != null && api.apis().length > 0) {
String[] apiNames = api.apis();
for (String name : apiNames) {
if (!TextUtils.isEmpty(name)) {
APIS.put(name, api);
}
}
}
}
}

View File

@ -0,0 +1,23 @@
package com.finogeeks.mop.api;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
public abstract class BaseApi extends AbsApi {
protected static final String TAG = "InnerApi";
protected static final Handler HANDLER = new Handler(Looper.getMainLooper());
private Context mContext;
public BaseApi(Context context) {
mContext = context;
}
public Context getContext() {
return mContext;
}
}

View File

@ -0,0 +1,49 @@
package com.finogeeks.mop.api;
import android.content.Intent;
import com.finogeeks.mop.interfaces.IApi;
import com.finogeeks.mop.interfaces.ICallback;
import java.util.Map;
public class EmptyApi implements IApi {
@Override
public void onCreate() {
}
@Override
public void onDestroy() {
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data, ICallback callback) {
}
@Override
public void onNewIntent(Intent data) {
}
@Override
public void onResume() {
}
@Override
public void onPause() {
}
@Override
public String[] apis() {
return null;
}
@Override
public void invoke(String event, Map param, ICallback callback) {
}
}

View File

@ -0,0 +1,50 @@
package com.finogeeks.mop.api.mop;
import android.content.Context;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.interfaces.ICallback;
import java.util.HashMap;
import java.util.Map;
public class AppletModule extends BaseApi {
private final static String TAG = AppletModule.class.getSimpleName();
private Context mContext;
public AppletModule(Context context) {
super(context);
mContext = context;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public String[] apis() {
return new String[]{"openApplet"};
}
@Override
public void invoke(String event, Map param, ICallback callback) {
System.out.println("AppletModule");
if (param.get("appId") == null) {
callback.onFail(new HashMap(){
{
put("info","appId不能为空");
}
});
return;
}
String appId = String.valueOf(param.get("appId"));
Map<String,String> params = (Map)param.get("params");
if (params == null) {
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId);
} else {
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, params);
}
callback.onSuccess(new HashMap());
}
}

View File

@ -0,0 +1,82 @@
package com.finogeeks.mop.api.mop;
import android.content.Context;
import android.widget.Toast;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
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 java.util.HashMap;
import java.util.Map;
public class BaseModule extends BaseApi {
private final static String TAG = BaseModule.class.getSimpleName();
public BaseModule(Context context) {
super(context);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public String[] apis() {
return new String[]{"initialize"};
}
@Override
public void invoke(String event, Map param, final ICallback callback) {
if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) {
// 小程序进程不执行任何初始化操作
return;
}
String appkey = String.valueOf(param.get("appkey"));
String secret = String.valueOf(param.get("secret"));
String apiServer = "https://mp.finogeeks.com";
String apiPrefix = "/api/v1/mop/";
if (param.get("apiServer") != null) {
apiServer = String.valueOf(param.get("apiServer"));
}
if (param.get("apiPrefix") != null) {
apiPrefix = String.valueOf(param.get("apiPrefix"));
}
FinAppConfig config = new FinAppConfig.Builder()
.setAppKey(appkey)
.setAppSecret(secret)
.setApiUrl(apiServer)
.setApiPrefix(apiPrefix)
.setGlideWithJWT(false)
.build();
// SDK初始化结果回调用于接收SDK初始化状态
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);
// Toast.makeText(MopPluginService.getInstance().getContext(), "SDK初始化失败", Toast.LENGTH_SHORT).show();
}
@Override
public void onProgress(int status, String error) {
}
};
FinAppClient.INSTANCE.init(MopPluginService.getInstance().getActivity().getApplication(), config, cb);
}
}

View File

@ -0,0 +1,11 @@
package com.finogeeks.mop.constants;
/**
*
*/
public class Constants {
public static final int REQUEST_CODE_CHOOSE = 0x1000000;
public static final int REQUEST_CODE_LOCATION_CHOOSE = 0x1000001;
public static final int REQUEST_CODE_LOCATION_PREVIEW = 0x1000002;
public static final int REQUEST_CODE_SELECT_DOCUMENT = 0x1000003;
}

View File

@ -0,0 +1,35 @@
package com.finogeeks.mop.interfaces;
import java.util.Map;
public final class Event {
private String name;
private Object param;
private ICallback callback;
public Event(String name, Object param, ICallback callback) {
this.name = name;
this.param = param;
this.callback = callback;
}
public String getName() {
return name;
}
public Map getParam() {
if (param instanceof Map) {
return (Map)param;
}
return null;
}
public ICallback getCallback() {
return callback;
}
}

View File

@ -0,0 +1,23 @@
package com.finogeeks.mop.interfaces;
import android.os.Handler;
import android.os.Looper;
import com.finogeeks.mop.service.MopPluginService;
public class FlutterInterface {
private static final String TAG = FlutterInterface.class.getSimpleName();
private Handler mHandler = new Handler(Looper.getMainLooper());
public void invokeHandler(final Event event) {
mHandler.post(new Runnable() {
@Override
public void run() {
MopPluginService.getInstance().getApisManager().invoke(event);
}
});
}
}

View File

@ -0,0 +1,23 @@
package com.finogeeks.mop.interfaces;
import java.util.Map;
/**
* ApiApi
*/
public interface IApi extends ILifecycle {
/**
* @return api
*/
String[] apis();
/**
* apiapi
*
* @param event api
* @param param
* @param callback
*/
void invoke(String event, Map param, ICallback callback);
}

View File

@ -0,0 +1,35 @@
package com.finogeeks.mop.interfaces;
import android.content.Intent;
/**
* Api
*/
public interface ICallback<T> {
/**
* Api
*
* @param data Api
*/
void onSuccess(T data);
/**
* Api
*/
void onFail(T error);
/**
* Api
*/
void onCancel(T cancel);
/**
* {@link android.app.Activity#startActivityForResult(Intent, int)}
*
* @param intent
* @param requestCode
*/
void startActivityForResult(Intent intent, int requestCode);
}

View File

@ -0,0 +1,39 @@
package com.finogeeks.mop.interfaces;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
/**
* {@link Activity}
*/
public interface ILifecycle {
/**
* {@link Activity#onCreate(Bundle)}.
*/
void onCreate();
/**
* {@link Activity#onDestroy()}.
*/
void onDestroy();
/**
* {@link Activity#onActivityResult(int, int, Intent)}.
*/
void onActivityResult(int requestCode, int resultCode, Intent data, ICallback callback);
/**
* {@link Activity#onNewIntent(Intent)}.
*/
void onNewIntent(Intent intent);
/**
* {@link Activity#onResume()}.
*/
void onResume();
/**
* {@link Activity#onResume()}.
*/
void onPause();
}

View File

@ -0,0 +1,51 @@
package com.finogeeks.mop.service;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import com.finogeeks.mop.MopEventStream;
import com.finogeeks.mop.api.ApisManager;
public class MopPluginService {
private final static String TAG = MopPluginService.class.getSimpleName();
private static volatile MopPluginService _instance = null;
private ApisManager apisManager;
private MopEventStream mopEventStream;
private Context mContext;
private Activity mActivity;
MopPluginService() {
}
public static MopPluginService getInstance() {
if (_instance == null) {
synchronized (MopPluginService.class) {
if (_instance == null) {
_instance = new MopPluginService();
}
}
}
return _instance;
}
public ApisManager getApisManager() { return this.apisManager;}
public MopEventStream getMopEventStream() {return this.mopEventStream;}
public void initialize(Activity activity, MopEventStream mopEventStream) {
this.mopEventStream = mopEventStream;
this.mContext = activity.getApplicationContext();
this.apisManager = new ApisManager(activity);
this.mActivity = activity;
}
public Context getContext() {
return mContext;
}
public Activity getActivity() {
return mActivity;
}
}

View File

@ -33,12 +33,12 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.finogeeks.mop_example" applicationId "com.finogeeks.mopexample"
minSdkVersion 16 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@ -56,6 +56,6 @@ flutter {
dependencies { dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
} }

View File

@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/
package com.finogeeks.mop_example;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}

View File

@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/
package com.finogeeks.mop_example;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}

View File

@ -1,6 +1,7 @@
package com.finogeeks.mop_example; package com.finogeeks.mop_example;
import android.os.Bundle; import android.os.Bundle;
import io.flutter.app.FlutterActivity; import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.plugins.GeneratedPluginRegistrant;
@ -9,5 +10,7 @@ public class MainActivity extends FlutterActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this); GeneratedPluginRegistrant.registerWith(this);
} }
} }

View File

@ -1,3 +1,4 @@
buildscript { buildscript {
repositories { repositories {
google() google()
@ -5,7 +6,8 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.60"
} }
} }

View File

@ -1,2 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View File

@ -0,0 +1,5 @@
-keep class com.finogeeks.** {*;}
# tbs
-keep class com.tencent.smtt.** {*;}
-keep class com.tencent.tbs.** {*;}

View File

@ -20,17 +20,17 @@ class _MyAppState extends State<MyApp> {
// Platform messages are asynchronous, so we initialize in an async method. // Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async { Future<void> initPlatformState() async {
String platformVersion; // String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException. // // Platform messages may fail, so we use a try/catch PlatformException.
try { // try {
platformVersion = await Mop.instance.platformVersion; // platformVersion = await Mop.instance.platformVersion;
print(platformVersion); // print(platformVersion);
} on PlatformException { // } on PlatformException {
platformVersion = 'Failed to get platform version.'; // platformVersion = 'Failed to get platform version.';
} // }
final res = await Mop.instance.initialize( final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6', '22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1'); apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/');
print(res); print(res);
// If the widget was removed from the tree while the asynchronous platform // If the widget was removed from the tree while the asynchronous platform

View File

@ -66,7 +66,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.0.1" version: "0.0.2"
path: path:
dependency: transitive dependency: transitive
description: description:

19
mop.iml
View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
</component>
</module>

View File

@ -1,8 +1,9 @@
name: mop name: mop
description: A new flutter plugin project. description: A new flutter plugin project.
version: 0.0.1 version: 0.0.2
author: authors:
homepage: - finogeeks <finogeeks.mop@gmail.com>
homepage: https://github.com/finogeeks/flutter-mop-plugin
environment: environment:
sdk: '>=2.1.0 <3.0.0' sdk: '>=2.1.0 <3.0.0'