diff --git a/CHANGELOG.md b/CHANGELOG.md index 5965ead..edb50e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.3 + +* fix android result + ## 1.0.1 * Stable version diff --git a/README.md b/README.md index ce13cad..f2cc02a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![pub package](https://img.shields.io/badge/pub-1.0.2-brightgreen.svg)](https://pub.dartlang.org/packages/geetest_plugin) [![Build Status](https://travis-ci.com/cikichen/flutter_geetest_plugin.svg?branch=master)](https://travis-ci.com/cikichen/flutter_geetest_plugin) +[![pub package](https://img.shields.io/badge/pub-1.0.3-brightgreen.svg)](https://pub.dartlang.org/packages/geetest_plugin) [![Build Status](https://travis-ci.com/cikichen/flutter_geetest_plugin.svg?branch=master)](https://travis-ci.com/cikichen/flutter_geetest_plugin) # flutter_geetest_plugin @@ -20,7 +20,7 @@ Add this to your package's pubspec.yaml file: ``` dependencies: - flutter_geetest_plugin: ^1.0.2 + flutter_geetest_plugin: ^1.0.3 ``` ### 2. Install it diff --git a/android/src/main/java/me/ithome/flutter_geetest_plugin/FlutterGeetestPlugin.java b/android/src/main/java/me/ithome/flutter_geetest_plugin/FlutterGeetestPlugin.java index fd9ff58..2fd8ab6 100644 --- a/android/src/main/java/me/ithome/flutter_geetest_plugin/FlutterGeetestPlugin.java +++ b/android/src/main/java/me/ithome/flutter_geetest_plugin/FlutterGeetestPlugin.java @@ -1,5 +1,8 @@ package me.ithome.flutter_geetest_plugin; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Context; import android.os.AsyncTask; import android.text.TextUtils; import android.util.Log; @@ -10,6 +13,7 @@ import com.geetest.sdk.GT3Listener; import com.tencent.smtt.sdk.QbSdk; +import org.jetbrains.annotations.NotNull; import org.json.JSONObject; import io.flutter.plugin.common.MethodCall; @@ -25,11 +29,12 @@ public class FlutterGeetestPlugin implements MethodCallHandler { private static String validateURL = "https://www.geetest.com/demo/gt/validate-slide"; private GT3GeetestUtils gt3GeetestUtils; private GT3ConfigBean gt3ConfigBean; - private final Registrar mRegistrar; + // private final Registrar mRegistrar; private static final String TAG = "flutter_geetest"; + private Result flutterResult; private FlutterGeetestPlugin(Registrar registrar) { - this.mRegistrar = registrar; + // this.mRegistrar = registrar; QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() { @@ -89,6 +94,7 @@ public void onDialogReady(String duration) { @Override public void onDialogResult(String result) { Log.e(TAG, "GT3BaseListener-->onDialogResult-->" + result); + flutterResult.success(result); // 开启api2逻辑 new RequestAPI2().execute(result); } @@ -133,12 +139,13 @@ public static void registerWith(Registrar registrar) { } @Override - public void onMethodCall(MethodCall call, final Result result) { + public void onMethodCall(MethodCall call, @NotNull final Result result) { switch (call.method) { case "getPlatformVersion": result.success("Android " + android.os.Build.VERSION.RELEASE); break; case "getGeetest": + flutterResult = result; captchaURL = call.argument("api1"); validateURL = call.argument("api2"); // 开启验证 @@ -187,6 +194,7 @@ public void onMethodCall(MethodCall call, final Result result) { } /** 请求api1 */ + @SuppressLint("StaticFieldLeak") class RequestAPI1 extends AsyncTask { @Override @@ -215,6 +223,7 @@ protected void onPostExecute(JSONObject parmas) { } /** 请求api2 */ + @SuppressLint("StaticFieldLeak") class RequestAPI2 extends AsyncTask { @Override @@ -233,6 +242,7 @@ protected void onPostExecute(String result) { try { JSONObject jsonObject = new JSONObject(result); String status = jsonObject.getString("status"); + if ("success".equals(status)) { gt3GeetestUtils.showSuccessDialog(); } else { diff --git a/example/android/.idea/caches/build_file_checksums.ser b/example/android/.idea/caches/build_file_checksums.ser index ad2d3c5..7d3415b 100644 Binary files a/example/android/.idea/caches/build_file_checksums.ser and b/example/android/.idea/caches/build_file_checksums.ser differ diff --git a/example/android/.idea/caches/gradle_models.ser b/example/android/.idea/caches/gradle_models.ser index ac2bfa6..e585b33 100644 Binary files a/example/android/.idea/caches/gradle_models.ser and b/example/android/.idea/caches/gradle_models.ser differ diff --git a/example/android/.idea/markdown-navigator.xml b/example/android/.idea/markdown-navigator.xml deleted file mode 100644 index 4194dd2..0000000 --- a/example/android/.idea/markdown-navigator.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/example/android/.idea/misc.xml b/example/android/.idea/misc.xml index 17a1c3a..0934a29 100644 --- a/example/android/.idea/misc.xml +++ b/example/android/.idea/misc.xml @@ -6,6 +6,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/lib/main.dart b/example/lib/main.dart index e57f2c1..91e9dd2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -45,7 +45,7 @@ class _MyAppState extends State { // Platform messages may fail, so we use a try/catch PlatformException. try { result = await FlutterGeetestPlugin.getGeetest('https://www.geetest.com/demo/gt/register-slide', 'https://www.geetest.com/demo/gt/validate-slide'); - } on PlatformException { + } on Exception { // platformVersion = 'Failed to get platform version.'; } @@ -69,7 +69,7 @@ class _MyAppState extends State { body: new Center( child: Column( children: [ - new Text('Running on: $_platformVersion\n'), + new Text('$_platformVersion\n'), RaisedButton( onPressed: getGeetest, child: Text("geetest"), diff --git a/lib/flutter_geetest_plugin.dart b/lib/flutter_geetest_plugin.dart index 3a723d1..844f0a6 100644 --- a/lib/flutter_geetest_plugin.dart +++ b/lib/flutter_geetest_plugin.dart @@ -11,6 +11,7 @@ class FlutterGeetestPlugin { return version; } + ///一键验证 static Future getGeetest(String api1, String api2) async { final Map params = { 'api1': api1, diff --git a/pubspec.yaml b/pubspec.yaml index bbeb7aa..447bfd7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_geetest_plugin description: Geetest(GT3Captcha) Flutter plugin(极验 - a user-friendly CAPTCHA powered by AI. Protect your website and mobile apps against bot traffic. Start your free trial now!). -version: 1.0.2 +version: 1.0.3 author: SimonChen homepage: https://github.com/cikichen/flutter_geetest_plugin