HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-28 8b4d79ca03495e522a1953e04ca17527f33c853a
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
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 手势密码验证界面
    /// </summary>
    public class GesturePswSecirityForm : DialogCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_TouchText">Touch ID验证的显示文本</param>
        /// <param name="i_PasswordText">密码验证的显示文本</param>
        /// <param name="i_GestureText">手势验证的显示文本</param>
        /// <param name="SuccessAction">验证成功后的回调函数,如果不成功,不会调用这个东西</param>
        public void ShowForm(string i_TouchText, string i_PasswordText, string i_GestureText, Action SuccessAction)
        {
            //初始化中部信息
            this.InitMiddleFrame(i_TouchText, i_PasswordText, i_GestureText, SuccessAction);
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        /// <param name="i_TouchText">Touch ID验证的显示文本</param>
        /// <param name="i_PasswordText">密码验证的显示文本</param>
        /// <param name="i_GestureText">手势验证的显示文本</param>
        /// <param name="SuccessAction">验证成功后的回调函数,如果不成功,不会调用这个东西</param>
        private void InitMiddleFrame(string i_TouchText, string i_PasswordText, string i_GestureText, Action SuccessAction)
        {
            var frameBack = new FrameLayout();
            frameBack.Y = Application.GetRealHeight(239);
            frameBack.Gravity = Gravity.CenterHorizontal;
            frameBack.Width = Application.GetRealWidth(965);
            frameBack.Height = Application.GetRealHeight(1486);
            frameBack.BackgroundColor = UserCenterColor.Current.White;
            frameBack.Radius = (uint)Application.GetMinRealAverage(6);
            bodyFrameLayout.AddChidren(frameBack);
 
 
 
 
            //Touch ID开锁
            var btnTouch = new NormalClickButton(frameBack.Width / 2, Application.GetRealHeight(127));
            btnTouch.BackgroundColor = 0xfff5f6fa;
            btnTouch.oldBackgroundColor = 0xfff5f6fa;
            btnTouch.Gravity = Gravity.BottomLeft;
            btnTouch.Text = i_TouchText;
            btnTouch.TextColor = UserCenterColor.Current.TextColor1;
            frameBack.AddChidren(btnTouch);
            if (UserCenterResourse.Option.FingerprintAuthentication == false)
            {
                //没有启用Touch ID
                btnTouch.CanClick = false;
            }
            btnTouch.ButtonClickEvent += (sender, e) =>
            {
                //二次检测
                TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                if (type != TouchIDUtils.TouchIDSupperType.TouchID)
                {
                    return;
                }
 
                //界面关闭
                this.CloseForm();
 
                TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent += (sender2, e2) =>
                {
                    if (e2 == TouchIDUtils.TouchIDState.Success)
                    {
                        TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null;
                        //TouchID验证成功
                        SuccessAction?.Invoke();
                        SuccessAction = null;
                    }
                    else if (e2 == TouchIDUtils.TouchIDState.InputPassword)
                    {
                        TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null;
 
                        //密码验证
                        if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false)
                        {
                            var form = new SecondaryPswSecurityForm();
                            this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction);
                        }
                        //手势验证
                        else if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false)
                        {
                            var form = new GesturePswSecirityForm();
                            this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction);
                        }
                        else
                        {
                            //没有设置密码验证
                            this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uPasswordAuthenticationNotSettion));
                        }
                    }
                };
                TouchIDUtils.Instance.showTouchIDWithDescribe(null, null);
            };
 
            //密码开锁
            var btnPsw = new NormalClickButton(frameBack.Width / 2, Application.GetRealHeight(127));
            btnPsw.BackgroundColor = 0xff232323;
            btnPsw.oldBackgroundColor = 0xfff5f6fa;
            btnPsw.Text = i_PasswordText;
            btnPsw.TextColor = UserCenterColor.Current.White;
            btnPsw.Gravity = Gravity.BottomRight;
            frameBack.AddChidren(btnPsw);
            if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true)
            {
                //没有启用密码开锁
                btnPsw.CanClick = false;
            }
            btnPsw.ButtonClickEvent += (sender, e) =>
            {
                var form = new SecondaryPswSecurityForm();
                this.AddFromAndRemoveNowForm(form, i_TouchText, i_PasswordText, i_GestureText, SuccessAction);
            };
        }
 
        #endregion
 
        #region ■ 界面关闭___________________________
 
        public override void CloseForm()
        {
            //取消事件
            TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null;
 
            base.CloseForm();
        }
 
        #endregion
    }
}