using System;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
|
namespace HDL_ON.UI
|
{
|
public partial class AppUnlockPasswordPage : FrameLayout
|
{
|
FrameLayout bodyView;
|
EditText etPassword;
|
|
string passwrod = "";
|
string oldPasswrod = "";
|
Action backAction;
|
public AppUnlockPasswordPage(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.SetDigitalPassword)).LoadTopView();
|
else
|
new TopViewDiv(bodyView, Language.StringByID(StringId.VerifyDigitalPassword)).LoadTopView();
|
}
|
|
var btnTipTitle = new Button()
|
{
|
Y = Application.GetRealWidth(186),
|
Height = Application.GetRealWidth(42),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = string.IsNullOrEmpty(oldPasswrod)? StringId.PlsEntryPassword : StringId.PlsRegisterRepeatPassword,
|
};
|
bodyView.AddChidren(btnTipTitle);
|
|
|
if (optionType == "2"|| optionType == "3")
|
{
|
btnTipTitle.TextID = StringId.PleaseEnterTheOriginalDigitalPassword;
|
}
|
if(optionType == "7")
|
{
|
btnTipTitle.TextID = StringId.PlsEntryPassword;
|
}
|
|
var btnTipIcon1 = new Button()
|
{
|
X = Application.GetRealWidth(132),
|
Y = Application.GetRealWidth(238),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
BorderColor = CSS_Color.FirstLevelTitleColor,
|
BorderWidth = (uint)Application.GetRealWidth(1),
|
Radius = (uint)Application.GetRealWidth(8),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
SelectedBackgroundColor = CSS_Color.FirstLevelTitleColor,
|
};
|
bodyView.AddChidren(btnTipIcon1);
|
|
|
var btnTipIcon2 = new Button()
|
{
|
X = btnTipIcon1.Right + Application.GetRealWidth(16),
|
Y = Application.GetRealWidth(238),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
BorderColor = CSS_Color.FirstLevelTitleColor,
|
BorderWidth = (uint)Application.GetRealWidth(1),
|
Radius = (uint)Application.GetRealWidth(8),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
SelectedBackgroundColor = CSS_Color.FirstLevelTitleColor,
|
};
|
bodyView.AddChidren(btnTipIcon2);
|
|
|
var btnTipIcon3 = new Button()
|
{
|
X = btnTipIcon2.Right + Application.GetRealWidth(16),
|
Y = Application.GetRealWidth(238),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
BorderColor = CSS_Color.FirstLevelTitleColor,
|
BorderWidth = (uint)Application.GetRealWidth(1),
|
Radius = (uint)Application.GetRealWidth(8),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
SelectedBackgroundColor = CSS_Color.FirstLevelTitleColor,
|
};
|
bodyView.AddChidren(btnTipIcon3);
|
|
|
var btnTipIcon4 = new Button()
|
{
|
X = btnTipIcon3.Right + Application.GetRealWidth(16),
|
Y = Application.GetRealWidth(238),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
BorderColor = CSS_Color.FirstLevelTitleColor,
|
BorderWidth = (uint)Application.GetRealWidth(1),
|
Radius = (uint)Application.GetRealWidth(8),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
SelectedBackgroundColor = CSS_Color.FirstLevelTitleColor,
|
};
|
bodyView.AddChidren(btnTipIcon4);
|
|
|
Button btnTipError = new Button()
|
{
|
Y = Application.GetRealWidth(258),
|
Height = Application.GetRealWidth(40),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.WarningColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
Visible = false,
|
};
|
bodyView.AddChidren(btnTipError);
|
|
|
etPassword = new EditText()
|
{
|
Y = Application.GetRealWidth(100),
|
Height = Application.GetRealWidth(0),
|
Foucs = true,
|
//Visible = false,
|
IsNumberKeyboardType = true,
|
};
|
bodyView.AddChidren(etPassword);
|
|
//etPassword.MouseUpEventHandler = (sender, e) => { };
|
|
etPassword.TextChangeEventHandler = (sender, e) => {
|
passwrod = etPassword.Text.Trim();
|
switch(etPassword.Text.Trim().Length)
|
{
|
case 0:
|
btnTipIcon1.IsSelected = false;
|
btnTipIcon2.IsSelected = false;
|
btnTipIcon3.IsSelected = false;
|
btnTipIcon4.IsSelected = false;
|
break;
|
case 1:
|
btnTipIcon1.IsSelected = true;
|
btnTipIcon2.IsSelected = false;
|
btnTipIcon3.IsSelected = false;
|
btnTipIcon4.IsSelected = false;
|
btnTipError.Visible = false;
|
break;
|
case 2:
|
btnTipIcon1.IsSelected = true;
|
btnTipIcon2.IsSelected = true;
|
btnTipIcon3.IsSelected = false;
|
btnTipIcon4.IsSelected = false;
|
break;
|
case 3:
|
btnTipIcon1.IsSelected = true;
|
btnTipIcon2.IsSelected = true;
|
btnTipIcon3.IsSelected = true;
|
btnTipIcon4.IsSelected = false;
|
break;
|
case 4:
|
btnTipIcon1.IsSelected = true;
|
btnTipIcon2.IsSelected = true;
|
btnTipIcon3.IsSelected = true;
|
btnTipIcon4.IsSelected = true;
|
Application.HideSoftInput();
|
if (string.IsNullOrEmpty(oldPasswrod))
|
{
|
//移除当前界面,每次返回都返回到最上级
|
this.RemoveFromParent();
|
var page = new AppUnlockPasswordPage(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 AppUnlockPasswordPage("", backAction);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage("1");
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
return;
|
}
|
|
if (optionType == "7")
|
{
|
if (passwrod == oldPasswrod)
|
{
|
//MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent();
|
this.RemoveFromParent();
|
backAction();
|
return;
|
}
|
else
|
{
|
btnTipError.TextID = StringId.AuthenticationFailedPasswordError;
|
etPassword.Text = "";
|
btnTipError.Visible = true;
|
}
|
return;
|
}
|
if (optionType == "3"|| optionType == "4")
|
{
|
if (passwrod == oldPasswrod)
|
{
|
if(optionType == "4")
|
{
|
backAction();
|
this.RemoveFromParent();
|
return;
|
}
|
if (OnAppConfig.Instance.appUnlockType.Contains("1"))
|
{
|
OnAppConfig.Instance.appUnlockType =new System.Collections.Generic.List<string>();//.Remove("1");
|
OnAppConfig.Instance.appUnlockPasswrod = "";
|
OnAppConfig.Instance.SaveUserConfig();
|
this.RemoveFromParent();
|
backAction();
|
}
|
}
|
else
|
{
|
btnTipError.TextID = StringId.AuthenticationFailedPasswordError;
|
etPassword.Text = "";
|
btnTipError.Visible = true;
|
}
|
return;
|
}
|
//关闭/开启指纹或者面容
|
if (optionType == "5" || optionType == "6")//|| optionType == "8" || optionType == "9")
|
{
|
if (passwrod == oldPasswrod)
|
{
|
if (optionType == "5")
|
{
|
if (OnAppConfig.Instance.appUnlockType.Contains("3"))
|
OnAppConfig.Instance.appUnlockType.Remove("3");
|
else
|
OnAppConfig.Instance.appUnlockType.Add("3");
|
|
OnAppConfig.Instance.SaveUserConfig();
|
this.RemoveFromParent();
|
}
|
if (optionType == "6")
|
{
|
if (OnAppConfig.Instance.appUnlockType.Contains("4"))
|
OnAppConfig.Instance.appUnlockType.Remove("4");
|
else
|
OnAppConfig.Instance.appUnlockType.Add("4");
|
|
OnAppConfig.Instance.SaveUserConfig();
|
this.RemoveFromParent();
|
}
|
backAction();
|
}
|
else
|
{
|
btnTipError.TextID = StringId.AuthenticationFailedPasswordError;
|
etPassword.Text = "";
|
btnTipError.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), "");
|
string tipMsg = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? Language.StringByID(StringId.TurnOnFingerprintUnlocking) :
|
Language.StringByID(StringId.TurnOnFaceIdUnlocking);
|
|
if (TouchIDUtils.getTouchIDSupperType() != TouchIDUtils.TouchIDSupperType.None)
|
{
|
var unlockType = TouchIDUtils.getTouchIDSupperType() == TouchIDUtils.TouchIDSupperType.TouchID ? "3" : "4";
|
Action<bool> action = (result) =>
|
{
|
if (result)
|
{
|
if (!OnAppConfig.Instance.appUnlockType.Contains(unlockType))
|
{
|
OnAppConfig.Instance.appUnlockType.Add(unlockType);
|
}
|
}
|
else
|
{
|
if (OnAppConfig.Instance.appUnlockType.Contains(unlockType))
|
{
|
OnAppConfig.Instance.appUnlockType.Remove(unlockType);
|
}
|
}
|
backAction();
|
OnAppConfig.Instance.SaveUserConfig();
|
};
|
page.AdditionalOperations(tipMsg, action);
|
}
|
if (!OnAppConfig.Instance.appUnlockType.Contains("1"))
|
{
|
OnAppConfig.Instance.appUnlockType.Add("1");
|
}
|
OnAppConfig.Instance.appUnlockPasswrod = passwrod;
|
OnAppConfig.Instance.SaveUserConfig();
|
backAction();
|
}
|
else
|
{
|
btnTipError.TextID = StringId.IncorrectRepeatPassword;
|
etPassword.Text = "";
|
btnTipError.Visible = true;
|
}
|
}
|
break;
|
}
|
};
|
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
|
etPassword.Foucs = true;
|
};
|
bodyView.MouseUpEventHandler = eventHandler;
|
btnTipIcon1.MouseUpEventHandler = eventHandler;
|
btnTipIcon2.MouseUpEventHandler = eventHandler;
|
btnTipIcon3.MouseUpEventHandler = eventHandler;
|
btnTipIcon4.MouseUpEventHandler = eventHandler;
|
|
etPassword.Foucs = true;
|
|
|
if (optionType == "3" || optionType == "5" || optionType == "6" || optionType == "7")
|
{
|
Button btnLoginAccountVerify = new Button()
|
{
|
Y = Application.GetRealHeight(517),
|
Height = Application.GetRealHeight(60),
|
TextAlignment = TextAlignment.Center,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.MainColor,
|
TextID = StringId.EnterLoginPasswordVerification,
|
};
|
bodyView.AddChidren(btnLoginAccountVerify);
|
|
btnLoginAccountVerify.MouseUpEventHandler = (sender, e) =>
|
{
|
if (optionType == "7")
|
{
|
MainPage.GoLoginPage(MainPage.LoginUser);
|
}
|
else
|
{
|
Action<string> action = (pw) => {
|
var loginResult = new DAL.Server.HttpServerRequest().LoginByPassword(MainPage.LoginUser.accountString, pw);
|
if (loginResult.StateCode.ToUpper() == "SUCCESS")
|
{
|
OnAppConfig.Instance.appUnlockPasswrod = "";
|
OnAppConfig.Instance.appUnlockType = new System.Collections.Generic.List<string>();
|
OnAppConfig.Instance.SaveUserConfig();
|
this.RemoveFromParent();
|
backAction();
|
}
|
//登录失败
|
else
|
{
|
string tipStr = "Sever erorr";
|
switch (loginResult.StateCode)
|
{
|
case "ValidCodeAndPhoneNoEqual":
|
tipStr = Language.StringByID(StringId.VerificationCodeError);
|
break;
|
case "USERNAMEORPWDERROR":
|
tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError);
|
break;
|
case "ACCOUNTNOEXISTS":
|
tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS);
|
break;
|
case "NoRecord":
|
tipStr = Language.StringByID(StringId.PlsGetTheVerificationCode);
|
break;
|
case "Self:Net_Error":
|
tipStr = Language.StringByID(StringId.NetworkAnomaly);
|
break;
|
}
|
//账号或者密码错误
|
Application.RunOnMainThread(() =>
|
{
|
//提示原因
|
var tip = new Tip()
|
{
|
Text = tipStr,
|
CloseTime = 1,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(bodyView);
|
});
|
}
|
|
};
|
new PublicAssmebly().LoadDialog_EditParater(StringId.EnterLoginPasswordVerification, "", action, StringId.PlsEntryPassword, 0, new System.Collections.Generic.List<string>(), true);
|
}
|
};
|
}
|
|
}
|
}
|
}
|