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 0000000..db77bb4 Binary files /dev/null and b/android/src/main/res/mipmap-hdpi/ic_launcher.png differ 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 0000000..17987b7 Binary files /dev/null and b/android/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/android/src/main/res/mipmap-xhdpi/ic_launcher.png differ 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 0000000..d5f1c8d Binary files /dev/null and b/android/src/main/res/mipmap-xxhdpi/ic_launcher.png differ 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 0000000..4d6372e Binary files /dev/null and b/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ 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">