From f83ba0a4d4c3104d0581ee4bc7d2c8275b693c7f Mon Sep 17 00:00:00 2001 From: "23028876916@qq.com" Date: Fri, 9 Apr 2021 10:15:12 +0800 Subject: [PATCH] =?UTF-8?q?0409=20=20=E5=8D=87=E7=BA=A7android=E7=AB=AF?= =?UTF-8?q?=E7=99=BE=E5=B7=9Dsdk=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 76 ++++-- android/gradle.properties | 1 + .../flutter_alibc/FlutterAlibcHandle.java | 248 +++++++++++++----- .../flutter_alibc/FlutterAlibcPlugin.java | 2 + .../com/wxwx/flutter_alibc/PluginUtil.java | 49 ++-- .../com/wxwx/flutter_alibc/WebActivity.java | 50 ++-- .../flutter_alibc/web/WebViewActivity.java | 34 +-- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes example/.flutter-plugins-dependencies | 2 +- example/android/app/build.gradle | 4 +- .../android/app/src/main/AndroidManifest.xml | 2 +- example/android/build.gradle | 5 +- example/android/gradle.properties | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- .../ios/Flutter/flutter_export_environment.sh | 15 +- example/lib/main.dart | 30 ++- example/pubspec.lock | 108 +++----- lib/flutter_alibc.dart | 17 ++ pubspec.lock | 104 +++----- 23 files changed, 436 insertions(+), 319 deletions(-) create mode 100644 android/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 android/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 android/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 android/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 android/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/android/build.gradle b/android/build.gradle index ffa57ef..030397f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.2' } } @@ -32,7 +32,8 @@ android { defaultConfig { buildConfigField "boolean", "LOG_DEBUG", "true" minSdkVersion 16 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + multiDexEnabled true + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } lintOptions { disable 'InvalidPackage' @@ -45,26 +46,57 @@ android { dependencies{ -//登陆 - implementation 'com.ali.auth.sdk:alibabauth_core:2.0.0.11@aar' - implementation 'com.ali.auth.sdk:alibabauth_ui:2.0.0.11@aar' - implementation 'com.ali.auth.sdk:alibabauth_ext:2.0.0.11@aar' - //安全组件 - implementation 'com.taobao.android:securityguardaar3:5.4.171@aar' - implementation 'com.taobao.android:securitybodyaar3:5.4.99@aar' - implementation 'com.taobao.android:avmpaar3:5.4.36@aar' - implementation 'com.taobao.android:sgmiddletieraar3:5.4.9@aar' - //Mtop - implementation 'com.taobao.android:mtopsdk_allinone_open:3.1.2.5@jar' - //applink - implementation 'com.alibaba.sdk.android:alibc_link_partner:4.1.15@aar' - //ut - implementation 'com.taobao.android:utdid4all:1.5.2' - implementation 'com.alibaba.mtl:app-monitor-sdk:2.6.4.5_for_bc' +////登陆 +// implementation 'com.ali.auth.sdk:alibabauth_core:2.0.0.11@aar' +// implementation 'com.ali.auth.sdk:alibabauth_ui:2.0.0.11@aar' +// implementation 'com.ali.auth.sdk:alibabauth_ext:2.0.0.11@aar' +// //安全组件 +// implementation 'com.taobao.android:securityguardaar3:5.4.171@aar' +// implementation 'com.taobao.android:securitybodyaar3:5.4.99@aar' +// implementation 'com.taobao.android:avmpaar3:5.4.36@aar' +// implementation 'com.taobao.android:sgmiddletieraar3:5.4.9@aar' +// //Mtop +// implementation 'com.taobao.android:mtopsdk_allinone_open:3.1.2.5@jar' +// //applink +// implementation 'com.alibaba.sdk.android:alibc_link_partner:4.1.15@aar' +// //ut +// implementation 'com.taobao.android:utdid4all:1.5.2' +// implementation 'com.alibaba.mtl:app-monitor-sdk:2.6.4.5_for_bc' +// // 电商基础组件 +// implementation 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.16@aar' +// implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.16@aar' +// implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.16@aar' +// implementation 'com.alibaba:fastjson:1.2.52@jar' + + implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' + implementation 'androidx.cardview:cardview:1.0.0' + // 登陆 + implementation 'com.alibaba.baichuan.sdk:alibclogin:5.0.0.13' + // applink + implementation 'com.alibaba.baichuan.sdk:alibcapplink:5.0.0.13' + // 广告SDK + implementation 'com.alibaba.baichuan.sdk:alibcad:5.0.0.13' + // 小程序 + implementation 'com.alibaba.baichuan.sdk:alibctriver:5.0.0.13' + // c++基础库(如果工程中没有接入该so包:libc++_shared.so,需要接入该sdk) + implementation "llvm.stl:cpp_shared:0.0.3@aar" + // 直播 + implementation 'com.alibaba.baichuan.sdk:alibctriver_live:5.0.0.13' + // webview容器 + implementation 'com.alibaba.baichuan.sdk:alibcwebview:5.0.0.13' // 电商基础组件 - implementation 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.16@aar' - implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.16@aar' - implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.16@aar' - implementation 'com.alibaba:fastjson:1.2.52@jar' + implementation 'com.alibaba.baichuan.sdk:alibctradecommon:5.0.0.13' + implementation 'com.alibaba.baichuan.sdk:alibcnbtrade:5.0.0.13' + implementation 'com.alibaba.baichuan.sdk:alibcprotocol:5.0.0.13' + // 辅助排查工具(可选) + implementation "com.alibaba.baichuan.sdk:alibctools:5.0.0.13" + // 安全保镖v5版本(根据实际情况,v5和v6版本选择其一) + implementation 'com.taobao.android:securityguardaar3:5.0.0.9-v5@aar' + implementation 'com.taobao.android:securitybodyaar3:5.0.0.9-v5@aar' + implementation 'com.taobao.android:avmpaar3:5.0.0.9-v5@aar' + implementation 'com.taobao.android:sgmiddletieraar3:5.0.0.9-v5@aar' + + implementation 'com.alibaba:fastjson:1.1.71.android' } diff --git a/android/gradle.properties b/android/gradle.properties index 2bd6f4f..cd64a71 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,2 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +#android.enableR8=true diff --git a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java index 9345d93..332463e 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java @@ -1,5 +1,6 @@ package com.wxwx.flutter_alibc; +import android.text.TextUtils; import android.util.Log; import android.webkit.WebChromeClient; import android.webkit.WebViewClient; @@ -7,23 +8,7 @@ import android.widget.Toast; import android.content.Intent; import com.ali.auth.third.core.model.Session; -import com.alibaba.baichuan.trade.biz.context.AlibcResultType; -import com.alibaba.baichuan.android.trade.AlibcTrade; -import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback; -import com.alibaba.baichuan.android.trade.model.AlibcShowParams; -import com.alibaba.baichuan.android.trade.model.OpenType; -import com.alibaba.baichuan.android.trade.page.AlibcBasePage; -import com.alibaba.baichuan.android.trade.page.AlibcDetailPage; -import com.alibaba.baichuan.android.trade.page.AlibcMyCartsPage; -import com.alibaba.baichuan.android.trade.page.AlibcShopPage; -import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; -import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; -import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; -import com.alibaba.baichuan.trade.biz.login.AlibcLogin; -import com.alibaba.baichuan.trade.biz.login.AlibcLoginCallback; -import com.alibaba.baichuan.android.trade.AlibcTradeSDK; -import com.alibaba.baichuan.android.trade.callback.AlibcTradeInitCallback; -import com.alibaba.baichuan.trade.common.utils.AlibcLogger; + import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugin.common.PluginRegistry.Registrar; @@ -37,6 +22,19 @@ import android.app.AlertDialog; import static com.wxwx.flutter_alibc.PluginConstants.*; import static com.wxwx.flutter_alibc.PluginUtil.*; +import com.ali.auth.third.login.LoginServiceImpl; +import com.alibaba.alibclogin.AlibcLogin; +import com.alibaba.alibcprotocol.callback.AlibcLoginCallback; +import com.alibaba.alibcprotocol.callback.AlibcTradeCallback; +import com.alibaba.alibcprotocol.param.AlibcBizParams; +import com.alibaba.alibcprotocol.param.AlibcShowParams; +import com.alibaba.alibcprotocol.param.AlibcTaokeParams; +import com.alibaba.alibcprotocol.route.proxy.IAlibcLoginProxy; +import com.baichuan.nb_trade.AlibcTrade; +import com.baichuan.nb_trade.auth.TopAuth; +import com.baichuan.nb_trade.callback.AlibcTradeInitCallback; +import com.baichuan.nb_trade.callback.AuthCallback; +import com.baichuan.nb_trade.core.AlibcTradeSDK; import com.wxwx.flutter_alibc.web.WebViewActivity; import java.util.Map; @@ -51,7 +49,7 @@ public class FlutterAlibcHandle { private static FlutterAlibcHandle handle; private static Registrar register; private static boolean isFirst = true; - private static Result result; + private static Result result; //第一次调用getInstance register不能为空 public static FlutterAlibcHandle getInstance(Registrar register) { @@ -70,7 +68,7 @@ public class FlutterAlibcHandle { * @param result */ public void initAlibc(MethodCall call, Result result) { - AlibcTradeSDK.asyncInit(register.activity().getApplication(), new AlibcTradeInitCallback() { + AlibcTradeSDK.asyncInit(register.activity().getApplication(), new HashMap<>(), new AlibcTradeInitCallback() { @Override public void onSuccess() { result.success(PluginResponse.success(null).toMap()); @@ -89,9 +87,10 @@ public class FlutterAlibcHandle { * @param result */ public void loginTaoBao(Result result) { - final AlibcLogin alibcLogin = AlibcLogin.getInstance(); + final IAlibcLoginProxy alibcLogin = AlibcLogin.getInstance(); if (alibcLogin.isLogin()) { - Session session = AlibcLogin.getInstance().getSession(); +// Session session = AlibcLogin.getInstance().getSession(); + Session session = new LoginServiceImpl().getSession(); Map userInfo = new HashMap<>(); userInfo.put("nick", session.nick); userInfo.put("avatarUrl", session.avatarUrl); @@ -103,10 +102,24 @@ public class FlutterAlibcHandle { return; } alibcLogin.showLogin(new AlibcLoginCallback() { +// @Override +// public void onSuccess(int loginResult, String openId, String userNick) { +// Map userInfo = new HashMap<>(); +// Session session = AlibcLogin.getInstance().getSession(); +// userInfo.put("nick", session.nick); +// userInfo.put("avatarUrl", session.avatarUrl); +// userInfo.put("openId", session.openId); +// userInfo.put("openSid", session.openSid); +// userInfo.put("topAccessToken", session.topAccessToken); +// userInfo.put("topAuthCode", session.topAuthCode); +// result.success(PluginResponse.success(userInfo).toMap()); +// } + @Override - public void onSuccess(int loginResult, String openId, String userNick) { + public void onSuccess(String s, String s1) { Map userInfo = new HashMap<>(); - Session session = AlibcLogin.getInstance().getSession(); +// Session session = AlibcLogin.getInstance().getSession(); + Session session = new LoginServiceImpl().getSession(); userInfo.put("nick", session.nick); userInfo.put("avatarUrl", session.avatarUrl); userInfo.put("openId", session.openId); @@ -130,10 +143,15 @@ public class FlutterAlibcHandle { * @param result */ public void loginOut(Result result) { - AlibcLogin alibcLogin = AlibcLogin.getInstance(); + IAlibcLoginProxy alibcLogin = AlibcLogin.getInstance(); alibcLogin.logout(new AlibcLoginCallback() { +// @Override +// public void onSuccess(int loginResult, String openId, String userNick) { +// } + @Override - public void onSuccess(int loginResult, String openId, String userNick) { + public void onSuccess(String s, String s1) { + } @Override @@ -172,6 +190,67 @@ public class FlutterAlibcHandle { intent.putExtra("url", url); intent.putExtra("arguments", map); register.activity().startActivity(intent); + } + + /** + * 淘宝授权登陆 获取access_token + * + * @param call + * @param result + */ + public void taoKeLoginNew(MethodCall call, Result result) { +// String icon = call.argument("icon"); + String name = call.argument("name"); + String alibcAppKey = call.argument("alibcAppKey"); + if (!AlibcLogin.getInstance().isLogin()) { + AlibcLogin.getInstance().showLogin(new AlibcLoginCallback() { + @Override + public void onSuccess(String s, String s1) { + TopAuth.showAuthDialog(register.activity(), R.mipmap.ic_launcher, name, alibcAppKey, new AuthCallback() { + @Override + public void onSuccess(String accessToken, String expireTime) { + Map resMap = new HashMap(); + resMap.put("accessToken", accessToken); + resMap.put("expireTime", expireTime); + result.success(resMap); + } + + @Override + public void onError(String code, String msg) { + Map resMap = new HashMap(); + resMap.put("accessToken", ""); + resMap.put("code", code); + resMap.put("msg", msg); + result.success(resMap); + } + }); + } + + @Override + public void onFailure(int i, String s) { + Log.d("阿里百川授权失败", s); + } + }); + } else { + TopAuth.showAuthDialog(register.activity(), R.mipmap.ic_launcher, name, alibcAppKey, new AuthCallback() { + @Override + public void onSuccess(String accessToken, String expireTime) { + Map resMap = new HashMap(); + resMap.put("accessToken", accessToken); + resMap.put("expireTime", expireTime); + result.success(resMap); + } + + @Override + public void onError(String code, String msg) { + Map resMap = new HashMap(); + resMap.put("accessToken", ""); + resMap.put("code", code); + resMap.put("msg", msg); + result.success(resMap); + } + }); + } } @@ -184,14 +263,14 @@ public class FlutterAlibcHandle { public void openByUrl(MethodCall call, Result result) { AlibcShowParams showParams = new AlibcShowParams(); AlibcTaokeParams taokeParams = new AlibcTaokeParams("", "", ""); - FlutterAlibcHandle.result=result; + FlutterAlibcHandle.result = result; showParams.setBackUrl(call.argument(key_BackUrl)); ///渠道授权 if ((Boolean) call.argument(login_And_Auth)) { ///先APP授权 - if(isFirst){ - isFirst=false; + if (isFirst) { + isFirst = false; register.addActivityResultListener(new PluginRegistry.ActivityResultListener() { @Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) { @@ -217,13 +296,22 @@ public class FlutterAlibcHandle { if (!AlibcLogin.getInstance().isLogin()) { AlibcLogin.getInstance().showLogin(new AlibcLoginCallback() { - @Override - public void onSuccess(int i, String s, String s1) { - Log.d("阿里百川打开WebView", "webview"); - Intent intent = new Intent(register.context(), WebActivity.class); - intent.putExtra("url", (String) call.argument("url")); - register.activity().startActivityForResult(intent, 1111); +// @Override +// public void onSuccess(int i, String s, String s1) { +// Log.d("阿里百川打开WebView", "webview"); +// Intent intent = new Intent(register.context(), WebActivity.class); +// intent.putExtra("url", (String) call.argument("url")); +// register.activity().startActivityForResult(intent, 1111); +// +// } + @Override + public void onSuccess(String s, String s1) { +// Log.d("阿里百川打开WebView", "webview"); +// Intent intent = new Intent(register.context(), WebActivity.class); +// intent.putExtra("url", (String) call.argument("url")); +// register.activity().startActivityForResult(intent, 1111); + taoKeLoginNew(call, result); } @Override @@ -233,9 +321,10 @@ public class FlutterAlibcHandle { }); } else { Log.d("阿里百川打开WebView", "webview"); - Intent intent = new Intent(register.context(), WebActivity.class); - intent.putExtra("url", (String) call.argument("url")); - register.activity().startActivityForResult(intent, 1111); +// Intent intent = new Intent(register.context(), WebActivity.class); +// intent.putExtra("url", (String) call.argument("url")); +// register.activity().startActivityForResult(intent, 1111); + taoKeLoginNew(call, result); } ///后渠道信息 return; @@ -261,19 +350,24 @@ public class FlutterAlibcHandle { Map trackParams = new HashMap<>(); String url = call.argument("url"); // 以显示传入url的方式打开页面(第二个参数是套件名称) - AlibcTrade.openByUrl(register.activity(), "", url, null, - new WebViewClient(), new WebChromeClient(), showParams, + AlibcTrade.openByUrl(register.activity(), url, showParams, taokeParams, trackParams, new AlibcTradeCallback() { +// @Override +// public void onTradeSuccess(AlibcTradeResult tradeResult) { +// Map results = new HashMap<>(); +// if (AlibcResultType.TYPECART == tradeResult.resultType) { +// results.put("type", 1); +// } else if (AlibcResultType.TYPEPAY == tradeResult.resultType) { +// results.put("type", 0); +// results.put("payFailedOrders", tradeResult.payResult.payFailedOrders); +// results.put("paySuccessOrders", tradeResult.payResult.paySuccessOrders); +// } +// result.success(PluginResponse.success(results).toMap()); +// } + @Override - public void onTradeSuccess(AlibcTradeResult tradeResult) { + public void onSuccess(int i) { Map results = new HashMap<>(); - if (AlibcResultType.TYPECART == tradeResult.resultType) { - results.put("type", 1); - } else if (AlibcResultType.TYPEPAY == tradeResult.resultType) { - results.put("type", 0); - results.put("payFailedOrders", tradeResult.payResult.payFailedOrders); - results.put("paySuccessOrders", tradeResult.payResult.paySuccessOrders); - } result.success(PluginResponse.success(results).toMap()); } @@ -293,8 +387,8 @@ public class FlutterAlibcHandle { * @param result */ public void openShop(MethodCall call, Result result) { - AlibcBasePage page = new AlibcShopPage(call.argument("shopId")); - openByBizCode(page, "shop", call, result); +// AlibcBasePage page = new AlibcShopPage(call.argument("shopId")); +// openByBizCode(page, "shop", call, result); } /** @@ -303,8 +397,8 @@ public class FlutterAlibcHandle { * @param result */ public void openCart(MethodCall call, Result result) { - AlibcBasePage page = new AlibcMyCartsPage(); - openByBizCode(page, "cart", call, result); +// AlibcBasePage page = new AlibcMyCartsPage(); +// openByBizCode(page, "cart", call, result); } /** @@ -314,11 +408,11 @@ public class FlutterAlibcHandle { * @param result */ public void openItemDetail(MethodCall call, Result result) { - AlibcBasePage page = new AlibcDetailPage(call.argument("itemID")); - openByBizCode(page, "detail", call, result); +// AlibcBasePage page = new AlibcDetailPage(call.argument("itemID")); + openByBizCode(call.argument("itemID"), "detail", call, result); } - private void openByBizCode(AlibcBasePage page, String type, MethodCall call, Result result) { + private void openByBizCode(String page, String type, MethodCall call, Result result) { AlibcShowParams showParams = new AlibcShowParams(); AlibcTaokeParams taokeParams = new AlibcTaokeParams("", "", ""); @@ -334,26 +428,38 @@ public class FlutterAlibcHandle { taokeParams = getTaokeParams(call.argument("taokeParams")); } - if ("false".equals(call.argument("isNeedCustomNativeFailMode"))) { - showParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeNONE); - } else if (call.argument(key_NativeFailMode) != null) { - showParams.setNativeOpenFailedMode(getFailModeType("" + call.argument(key_NativeFailMode))); - } +// if ("false".equals(call.argument("isNeedCustomNativeFailMode"))) { +// showParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeNONE); +// } else if (call.argument(key_NativeFailMode) != null) { +// showParams.n(getFailModeType("" + call.argument(key_NativeFailMode))); +// } Map trackParams = new HashMap<>(); - AlibcTrade.openByBizCode(register.activity(), page, null, new WebViewClient(), - new WebChromeClient(), type, showParams, taokeParams, + AlibcTrade.openByCode(register.activity(), page, new AlibcBizParams(), showParams, taokeParams, trackParams, new AlibcTradeCallback() { +// @Override +// public void onTradeSuccess(AlibcTradeResult tradeResult) { +// Map results = new HashMap<>(); +// if (AlibcResultType.TYPECART == tradeResult.resultType) { +// results.put("type", 1); +// } else if (AlibcResultType.TYPEPAY == tradeResult.resultType) { +// results.put("type", 0); +// results.put("payFailedOrders", tradeResult.payResult.payFailedOrders); +// results.put("paySuccessOrders", tradeResult.payResult.paySuccessOrders); +// } +// result.success(PluginResponse.success(results).toMap()); +// } + @Override - public void onTradeSuccess(AlibcTradeResult tradeResult) { + public void onSuccess(int i) { Map results = new HashMap<>(); - if (AlibcResultType.TYPECART == tradeResult.resultType) { - results.put("type", 1); - } else if (AlibcResultType.TYPEPAY == tradeResult.resultType) { - results.put("type", 0); - results.put("payFailedOrders", tradeResult.payResult.payFailedOrders); - results.put("paySuccessOrders", tradeResult.payResult.paySuccessOrders); - } +// if (AlibcResultType.TYPECART == tradeResult.resultType) { +// results.put("type", 1); +// } else if (AlibcResultType.TYPEPAY == tradeResult.resultType) { +// results.put("type", 0); +// results.put("payFailedOrders", tradeResult.payResult.payFailedOrders); +// results.put("paySuccessOrders", tradeResult.payResult.paySuccessOrders); +// } result.success(PluginResponse.success(results).toMap()); } @@ -371,7 +477,7 @@ public class FlutterAlibcHandle { * @param call */ public void syncForTaoke(MethodCall call) { - AlibcTradeSDK.setSyncForTaoke(call.argument("isSync")); +// AlibcTradeSDK.setSyncForTaoke(call.argument("isSync")); } /** @@ -380,7 +486,7 @@ public class FlutterAlibcHandle { * @param call */ public void useAlipayNative(MethodCall call) { - AlibcTradeSDK.setShouldUseAlipay(call.argument("isNeed")); +// AlibcTradeSDK.setShouldUseAlipay(call.argument("isNeed")); } diff --git a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java index 4a6701d..8173bae 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java @@ -29,6 +29,8 @@ public class FlutterAlibcPlugin implements MethodCallHandler { handle.loginTaoBao(result); } else if (call.method.equals("taoKeLogin")){ handle.taoKeLogin(call, result); + } else if (call.method.equals("taoKeLoginNew")){ + handle.taoKeLoginNew(call, result); } else if (call.method.equals("loginOut")){ handle.loginOut(result); }else if (call.method.equals("openByUrl")){ diff --git a/android/src/main/java/com/wxwx/flutter_alibc/PluginUtil.java b/android/src/main/java/com/wxwx/flutter_alibc/PluginUtil.java index 5de3d6b..97d371d 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/PluginUtil.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/PluginUtil.java @@ -1,9 +1,10 @@ package com.wxwx.flutter_alibc; +import com.alibaba.alibcprotocol.param.AlibcTaokeParams; +import com.alibaba.alibcprotocol.param.OpenType; + import static com.wxwx.flutter_alibc.PluginConstants.*; -import com.alibaba.baichuan.android.trade.model.OpenType; -import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; -import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; + import java.util.Map; @@ -11,40 +12,40 @@ import java.util.Map; * @Author karedem * @Date 2019/9/10 11:42 * @Description 映射返回对应值 -**/ + **/ public class PluginUtil { - public static OpenType getOpenType(String open){ - if (Auto_OpenType.equals(open)){ + public static OpenType getOpenType(String open) { + if (Auto_OpenType.equals(open)) { return OpenType.Auto; - }else { - return OpenType.Native; + } else { + return OpenType.Native; } } - public static String getClientType(String client){ - if (client.equals(Tmall_ClientType)){ + public static String getClientType(String client) { + if (client.equals(Tmall_ClientType)) { return "tmall"; - }else { + } else { return "taobao"; } } - public static AlibcFailModeType getFailModeType(String mode){ - if (JumpH5_FailMode.equals(mode)){ - return AlibcFailModeType.AlibcNativeFailModeJumpH5; - }else if (JumpDownloadPage_FailMode.equals(mode)){ - return AlibcFailModeType.AlibcNativeFailModeJumpDOWNLOAD; - }else { - return AlibcFailModeType.AlibcNativeFailModeNONE; - } - } - - public static AlibcTaokeParams getTaokeParams(Map taokePar){ +// public static AlibcFailModeType getFailModeType(String mode) { +// if (JumpH5_FailMode.equals(mode)) { +// return AlibcFailModeType.AlibcNativeFailModeJumpH5; +// } else if (JumpDownloadPage_FailMode.equals(mode)) { +// return AlibcFailModeType.AlibcNativeFailModeJumpDOWNLOAD; +// } else { +// return AlibcFailModeType.AlibcNativeFailModeNONE; +// } +// } + + public static AlibcTaokeParams getTaokeParams(Map taokePar) { String pid = (String) taokePar.get("pid"); AlibcTaokeParams taokeParams = new AlibcTaokeParams("", "", ""); - if (pid != null){ - taokeParams.setPid(pid); + if (pid != null) { + taokeParams.pid = pid; } Object extParams = taokePar.get("extParams"); //TODO 其他参数待添加 diff --git a/android/src/main/java/com/wxwx/flutter_alibc/WebActivity.java b/android/src/main/java/com/wxwx/flutter_alibc/WebActivity.java index dfaa325..30232fc 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/WebActivity.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/WebActivity.java @@ -1,6 +1,7 @@ package com.wxwx.flutter_alibc; import android.annotation.SuppressLint; + import android.app.Activity; import android.content.ComponentName; import android.content.Intent; @@ -24,13 +25,13 @@ import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.Toast; -import com.alibaba.baichuan.android.trade.AlibcTrade; -import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback; -import com.alibaba.baichuan.android.trade.model.AlibcShowParams; -import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; -import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; -import com.alibaba.baichuan.trade.biz.login.AlibcLogin; -import com.alibaba.baichuan.trade.biz.login.AlibcLoginCallback; + +import com.alibaba.alibclogin.AlibcLogin; +import com.alibaba.alibcprotocol.callback.AlibcLoginCallback; +import com.alibaba.alibcprotocol.callback.AlibcTradeCallback; +import com.alibaba.alibcprotocol.param.AlibcShowParams; +import com.alibaba.alibcprotocol.param.AlibcTaokeParams; +import com.baichuan.nb_trade.AlibcTrade; import java.util.HashMap; import java.util.Map; @@ -68,11 +69,15 @@ public class WebActivity extends Activity { // alibcTaokeParams.extraParams.put("taokeAppkey", SPUtils.getPrefString(mActivity, Pkey.APP_alliance_appkey, "")); AlibcShowParams showParams = new AlibcShowParams(); showParams.setBackUrl("alisdk://"); - AlibcTrade.openByUrl(WebActivity.this, "", url, - mainWeb, new MyBaichuanWebClient(), new MyWebChromeClient(), showParams, + AlibcTrade.openByUrl(WebActivity.this, url, showParams, new AlibcTaokeParams("", "", ""), exParams, new AlibcTradeCallback() { +// @Override +// public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { +// +// } + @Override - public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { + public void onSuccess(int i) { } @@ -103,12 +108,16 @@ public class WebActivity extends Activity { Map exParams = new HashMap<>();//yhhpass参数 AlibcShowParams showParams = new AlibcShowParams(); showParams.setBackUrl("alisdk://"); - AlibcTrade.openByUrl(WebActivity.this, "", url, - mainWeb, new MyBaichuanWebClient(), new MyWebChromeClient(), showParams, + AlibcTrade.openByUrl(WebActivity.this, url,showParams, new AlibcTaokeParams("", "", ""), exParams, new AlibcTradeCallback() { +// @Override +// public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { +// Log.d("cg", alibcTradeResult.toString()); +// } + @Override - public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { - Log.d("cg", alibcTradeResult.toString()); + public void onSuccess(int i) { + } @Override @@ -336,10 +345,15 @@ public class WebActivity extends Activity { // alibcTaokeParams.extraParams.put("taokeAppkey", SPUtils.getPrefString(mActivity, Pkey.APP_alliance_appkey, "")); AlibcShowParams showParams = new AlibcShowParams(); showParams.setBackUrl("alisdk://"); - AlibcTrade.openByUrl(WebActivity.this, "", url, mainWeb, new MyBaichuanWebClient(), new MyWebChromeClient(), showParams, + AlibcTrade.openByUrl(WebActivity.this, url, showParams, new AlibcTaokeParams("", "", ""), exParams, new AlibcTradeCallback() { +// @Override +// public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { +// +// } + @Override - public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { + public void onSuccess(int i) { } @@ -440,8 +454,10 @@ public class WebActivity extends Activity { // } if (url.contains("maliprod.alipay.com") && !url.contains("confirmGoods.do")) { AlibcLogin.getInstance().showLogin(new AlibcLoginCallback() { + + @Override - public void onSuccess(int i, String s, String s1) { + public void onSuccess(String s, String s1) { } diff --git a/android/src/main/java/com/wxwx/flutter_alibc/web/WebViewActivity.java b/android/src/main/java/com/wxwx/flutter_alibc/web/WebViewActivity.java index ba7e930..c9f1c76 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/web/WebViewActivity.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/web/WebViewActivity.java @@ -10,19 +10,18 @@ import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; -import com.alibaba.baichuan.android.trade.AlibcTrade; -import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback; -import com.alibaba.baichuan.android.trade.model.AlibcShowParams; -import com.alibaba.baichuan.android.trade.model.OpenType; -import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; -import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; -import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; + +import com.alibaba.alibcprotocol.callback.AlibcTradeCallback; +import com.alibaba.alibcprotocol.param.AlibcShowParams; +import com.alibaba.alibcprotocol.param.AlibcTaokeParams; import com.alibaba.baichuan.trade.common.utils.AlibcLogger; import java.util.HashMap; import java.util.Map; import static com.wxwx.flutter_alibc.PluginConstants.*; import static com.wxwx.flutter_alibc.PluginUtil.*; + +import com.baichuan.nb_trade.AlibcTrade; import com.wxwx.flutter_alibc.R; import java.net.URLDecoder; @@ -85,11 +84,11 @@ public class WebViewActivity extends Activity { if (argument.get("taokeParams") != null){ taokeParams = getTaokeParams((HashMap)argument.get("taokeParams")); } - if ("false".equals(argument.get("isNeedCustomNativeFailMode"))){ - showParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeNONE); - }else if (argument.get(key_NativeFailMode) != null){ - showParams.setNativeOpenFailedMode(getFailModeType(String.valueOf(argument.get(key_NativeFailMode)))); - } +// if ("false".equals(argument.get("isNeedCustomNativeFailMode"))){ +// showParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeNONE); +// }else if (argument.get(key_NativeFailMode) != null){ +// showParams.setNativeOpenFailedMode(getFailModeType(String.valueOf(argument.get(key_NativeFailMode)))); +// } Map trackParams = new HashMap<>(); @@ -114,11 +113,16 @@ public class WebViewActivity extends Activity { } }; - AlibcTrade.openByUrl(WebViewActivity.this, "", url, webView, - client, new WebChromeClient(), + AlibcTrade.openByUrl(WebViewActivity.this, url, showParams, taokeParams, trackParams, new AlibcTradeCallback() { +// @Override +// public void onTradeSuccess(AlibcTradeResult tradeResult) {}//不会回调 + @Override - public void onTradeSuccess(AlibcTradeResult tradeResult) {}//不会回调 + public void onSuccess(int i) { + + } + @Override public void onFailure(int code, String msg) {}//不会回调 }); diff --git a/android/src/main/res/mipmap-hdpi/ic_launcher.png b/android/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-mdpi/ic_launcher.png b/android/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 1c2143d..f90cd46 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_alibc","dependencies":[]}]} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_alibc","path":"D:\\\\zy_project\\\\zhiying_flutter_alibc\\\\","dependencies":[]}],"android":[{"name":"flutter_alibc","path":"D:\\\\zy_project\\\\zhiying_flutter_alibc\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_alibc","dependencies":[]}],"date_created":"2021-04-09 09:35:59.437953","version":"1.22.1"} \ No newline at end of file diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 543a2ad..36127cc 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -36,6 +36,7 @@ android { applicationId "wxwx.com.flutter_alibc_example" minSdkVersion 16 targetSdkVersion 28 + multiDexEnabled true versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -73,5 +74,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' - implementation 'com.android.support:support-v4:28.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 46874e7..6679005 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:launchMode="singleTop" - android:theme="@style/LaunchTheme" + android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:windowSoftInputMode="adjustResize">