package com.yeshi.location.plugins;
|
|
import android.app.Activity;
|
import android.graphics.Color;
|
import android.widget.ImageView;
|
|
import com.mobile.auth.gatewayauth.AuthUIConfig;
|
import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper;
|
import com.mobile.auth.gatewayauth.TokenResultListener;
|
|
import io.flutter.plugin.common.BinaryMessenger;
|
import io.flutter.plugin.common.MethodCall;
|
import io.flutter.plugin.common.MethodChannel;
|
|
public class FlutterAliyunPhoneNumberAuthPlugins implements MethodChannel.MethodCallHandler {
|
public static String CHANNEL = "com.yeshi.location/aliyunOneKeyLogin"; // 分析1
|
|
static MethodChannel channel;
|
private Activity activity;
|
|
private PhoneNumberAuthHelper mPhoneNumberAuthHelper;
|
|
private FlutterAliyunPhoneNumberAuthPlugins(Activity activity) {
|
this.activity = activity;
|
}
|
|
public static void registerWith(Activity activity, BinaryMessenger messager) {
|
channel = new MethodChannel(messager, CHANNEL);
|
FlutterAliyunPhoneNumberAuthPlugins instance = new FlutterAliyunPhoneNumberAuthPlugins(activity);
|
channel.setMethodCallHandler(instance);
|
}
|
|
@Override
|
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { // 分析 2
|
String method = methodCall.method;
|
switch (method) {
|
case "init":
|
initOneKeyLogin();
|
result.success(true);
|
break;
|
default:
|
result.notImplemented();
|
}
|
}
|
|
|
private void initOneKeyLogin() {
|
sdkInit("");
|
initUI();
|
}
|
|
|
|
private void initUI() {
|
|
int width = DimenUtils.getScreenWidth(this);
|
int widthDP = DimenUtils.px2dip(this, width);
|
AuthUIConfig uiCOnfig = new AuthUIConfig.Builder()
|
.setPageBackgroundPath("shape_login_onkey_bg")
|
|
.setNavText("")
|
.setNavColor(Color.WHITE)
|
.setNavHidden(false)
|
.setNavReturnImgPath("ic_login_close")
|
.setNavReturnImgWidth(22)
|
.setNavReturnImgHeight(22)
|
.setNavReturnScaleType(ImageView.ScaleType.FIT_XY)
|
.setWebNavColor(Color.BLACK)
|
.setWebNavReturnImgPath("ic_back_two")
|
.setWebViewStatusBarColor(Color.WHITE)
|
.setStatusBarColor(Color.WHITE)
|
|
.setLogoWidth(147)
|
.setLogoHeight(36)
|
.setLogoImgPath("ic_login_logo")
|
.setLogoOffsetY(24 - 10)
|
|
.setSloganOffsetY(171 - 10)
|
.setSloganTextSize(12)
|
.setSloganTextColor(Color.parseColor("#F804F5"))
|
|
.setLogBtnText("⼀键登录")
|
.setLogBtnTextSize(17)
|
.setLogBtnTextColor(Color.parseColor("#F4DE4A"))
|
.setLogBtnBackgroundPath("shape_login_btn")
|
.setLogBtnOffsetY(229 - 10)
|
.setLogBtnHeight(44)
|
|
|
.setDialogWidth(305 * widthDP / 375)
|
.setDialogHeight(454)
|
.setNavColor(Color.RED)
|
.setSwitchAccHidden(true)
|
.setNumberColor(Color.parseColor("#0052F6"))
|
.setNumberSize(36)
|
.setNumFieldOffsetY(128 - 10)
|
|
.setAppPrivacyOne("《用户服务协议》", BeibeiConstant.USER_AGREEMENT)
|
.setAppPrivacyTwo("《隐私政策》", BeibeiConstant.PRIVACY_POLICY)
|
.setAppPrivacyColor(Color.parseColor("#B3B8D3"), Color.parseColor("#51B3FF"))
|
.setPrivacyBefore("登录即表示同意")
|
.setPrivacyEnd("")
|
.setCheckedImgPath("ic_login_privacy_checked")
|
.setPrivacyTextSize(11)
|
.setPrivacyState(false)
|
.setVendorPrivacyPrefix("《")
|
.setVendorPrivacySuffix("》")
|
.create();
|
|
mPhoneNumberAuthHelper.setAuthUIConfig(uiCOnfig);
|
}
|
private void sdkInit(String secretInfo) {
|
mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity.getApplicationContext(), new TokenResultListener(){
|
|
@Override
|
public void onTokenSuccess(String s) {
|
|
}
|
|
@Override
|
public void onTokenFailed(String s) {
|
|
}
|
});
|
mPhoneNumberAuthHelper.getReporter().setLoggerEnable(true);
|
mPhoneNumberAuthHelper.setAuthSDKInfo(secretInfo);
|
}
|
|
|
|
|
|
}
|