admin
2021-11-06 b29ed8536b5eaa5a8450eea9e7f0c4cd22284844
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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);
    }
 
 
 
 
    
}