using System;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
namespace HDL_ON.UI
|
{
|
public class AppUnlockGesturePage : FrameLayout
|
{
|
FrameLayout bodyView;
|
|
string passwrod = "";
|
string oldPasswrod = "";
|
Action backAction;
|
public AppUnlockGesturePage(string pw, Action action)
|
{
|
bodyView = this;
|
oldPasswrod = pw;
|
backAction = action;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="optionType">
|
/// 操作方式:
|
/// 1:设置密码;2:验证密码;3:关闭密码;4:关闭解锁设置;
|
/// 5:关闭指纹ID;6:关闭面容ID;7:解锁验证
|
/// </param>
|
public void LoadPage(string optionType)
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
//解锁验证无法后退,必须验证
|
if (optionType != "7")
|
{
|
if (oldPasswrod == "")
|
new TopViewDiv(bodyView, Language.StringByID(StringId.SetGesturePassword)).LoadTopView();
|
else
|
new TopViewDiv(bodyView, Language.StringByID(StringId.VerifyGesturePassword)).LoadTopView();
|
}
|
Button btnGestureIcon = new Button()
|
{
|
Y = Application.GetRealHeight(96),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(64),
|
Height = Application.GetRealWidth(64),
|
//UnSelectedImagePath = "PersonalCenter/AppUnlockSetting/GestureGrayIcon.png",
|
};
|
bodyView.AddChidren(btnGestureIcon);
|
|
Button btnTipTitle = new Button()
|
{
|
Y = Application.GetRealHeight(4) + btnGestureIcon.Bottom,
|
TextAlignment = TextAlignment.Center,
|
Height = Application.GetRealHeight(36),
|
IsBold = true,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
|
TextID = StringId.SetGesturePassword,
|
};
|
bodyView.AddChidren(btnTipTitle);
|
|
Button btnTipMsg = new Button()
|
{
|
Y = btnTipTitle.Bottom,
|
TextAlignment = TextAlignment.Center,
|
Height = Application.GetRealHeight(36),
|
IsBold = true,
|
TextColor = CSS_Color.TextualColor,
|
SelectedTextColor = CSS_Color.WarningColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = string.IsNullOrEmpty(oldPasswrod) ? StringId.DrawUnlockPattern : StringId.DrawUnlockPatternAgain,
|
};
|
bodyView.AddChidren(btnTipMsg);
|
|
|
if (optionType == "7")
|
{
|
btnTipTitle.TextID = StringId.DrawUnlockPattern;
|
}
|
|
GestureLockView mGestureLockView = new GestureLockView
|
{
|
Y = Application.GetRealHeight(260),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(215),
|
Height = Application.GetRealWidth(215),
|
LockViewCorrectColor = CSS_Color.MainColor,//0xFF00FF00,//默认和正确 时显示的颜色
|
LockViewErrorColor = 0xFFFF0000, //错误时 显示的颜色
|
BackgroundColor = CSS_Color.BackgroundColor,
|
};
|
bodyView.AddChidren(mGestureLockView);
|
|
//滑动结束 回调密码结果和密码长度
|
mGestureLockView.OnLockVerifyEvent += (selectNumStr, selectCount) =>
|
{
|
//自行验证密码,提示正确或者错误 false为显示红色错误, 自行选择调用时机
|
mGestureLockView.showCorrectStatus(false);
|
if (selectCount < 4)
|
{
|
btnTipMsg.Text = Language.StringByID(StringId.DrawingLengthError);
|
btnTipMsg.TextColor = CSS_Color.WarningColor;
|
return;
|
}
|
|
passwrod = selectNumStr;
|
|
if (string.IsNullOrEmpty(oldPasswrod))
|
{
|
this.RemoveFromParent();
|
var page = new AppUnlockGesturePage(passwrod, backAction);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage(optionType);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
}
|
else
|
{
|
if (optionType == "2")
|
{
|
//移除当前界面,每次返回都返回到最上级
|
this.RemoveFromParent();
|
var page = new AppUnlockGesturePage("", backAction);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage("1");
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
return;
|
}
|
if(optionType == "7")
|
{
|
if (passwrod == oldPasswrod)
|
{
|
this.RemoveFromParent();
|
backAction();
|
}
|
else
|
{
|
btnTipMsg.TextID = StringId.AuthenticationFailedGestureError;
|
btnTipMsg.IsSelected = true;
|
btnTipMsg.Visible = true;
|
}
|
return;
|
}
|
if (optionType == "3" || optionType == "4")
|
{
|
if (passwrod == oldPasswrod)
|
{
|
if (optionType == "4")
|
{
|
backAction();
|
this.RemoveFromParent();
|
return;
|
}
|
if (MainPage.LoginUser.appUnlockType.Contains("2"))
|
{
|
MainPage.LoginUser.appUnlockType.Remove("2");
|
MainPage.LoginUser.appUnlockPasswrod = "";
|
MainPage.LoginUser.SaveUserInfo();
|
this.RemoveFromParent();
|
backAction();
|
}
|
}
|
else
|
{
|
btnTipMsg.TextID = StringId.AuthenticationFailedGestureError;
|
btnTipMsg.IsSelected = true;
|
btnTipMsg.Visible = true;
|
}
|
return;
|
}
|
if (optionType == "5" || optionType == "6"|| optionType == "8" || optionType == "9")
|
{
|
if (passwrod == oldPasswrod)
|
{
|
if (optionType == "5" && MainPage.LoginUser.appUnlockType.Contains("3"))
|
{
|
MainPage.LoginUser.appUnlockType.Remove("3");
|
MainPage.LoginUser.SaveUserInfo();
|
this.RemoveFromParent();
|
}
|
if (MainPage.LoginUser.appUnlockType.Contains("4") && optionType == "6")
|
{
|
MainPage.LoginUser.appUnlockType.Remove("4");
|
MainPage.LoginUser.SaveUserInfo();
|
this.RemoveFromParent();
|
}
|
if (optionType == "8" && !MainPage.LoginUser.appUnlockType.Contains("3"))
|
{
|
MainPage.LoginUser.appUnlockType.Add("3");
|
MainPage.LoginUser.SaveUserInfo();
|
this.RemoveFromParent();
|
}
|
if (!MainPage.LoginUser.appUnlockType.Contains("4") && optionType == "9")
|
{
|
MainPage.LoginUser.appUnlockType.Remove("4");
|
MainPage.LoginUser.SaveUserInfo();
|
this.RemoveFromParent();
|
}
|
backAction();
|
}
|
else
|
{
|
btnTipMsg.TextID = StringId.AuthenticationFailedGestureError;
|
btnTipMsg.IsSelected = true;
|
btnTipMsg.Visible = true;
|
}
|
return;
|
}
|
if (passwrod == oldPasswrod)
|
{
|
this.RemoveFromParent();
|
var page = new OperationResultDisPalyPage();
|
page.Show();
|
page.LoadPage(true, Language.StringByID(StringId.SetSuccessfully), Language.StringByID(StringId.SetSuccessfully), "");
|
//page.LoadPage(true, Language.StringByID(StringId.SetSuccessfully), Language.StringByID(StringId.SetSuccessfully), "");
|
string tipMsg = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? Language.StringByID(StringId.TurnOnFingerprintUnlocking) :
|
Language.StringByID(StringId.TurnOnFaceIdUnlocking);
|
if (TouchIDUtils.getTouchIDSupperType() != TouchIDUtils.TouchIDSupperType.None)
|
{
|
Action<bool> action = (result) =>
|
{
|
var unlockType = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? "3" : "4";
|
if (result)
|
{
|
if (!MainPage.LoginUser.appUnlockType.Contains(unlockType))
|
{
|
MainPage.LoginUser.appUnlockType.Add(unlockType);
|
}
|
}
|
else
|
{
|
if (MainPage.LoginUser.appUnlockType.Contains(unlockType))
|
{
|
MainPage.LoginUser.appUnlockType.Remove(unlockType);
|
}
|
}
|
MainPage.LoginUser.SaveUserInfo();
|
backAction();
|
};
|
page.AdditionalOperations(tipMsg, action);
|
}
|
if (!MainPage.LoginUser.appUnlockType.Contains("2"))
|
{
|
MainPage.LoginUser.appUnlockType.Add("2");
|
}
|
MainPage.LoginUser.appUnlockPasswrod = passwrod;
|
MainPage.LoginUser.SaveUserInfo();
|
backAction();
|
}
|
else
|
{
|
btnTipMsg.Text = Language.StringByID(StringId.DrawingInconsistencyError);
|
btnTipMsg.IsSelected = true;
|
}
|
}
|
|
};
|
|
|
}
|
}
|
}
|