/// <summary> /// Evenement lorsque l'Edit Text du password de la page CreateAccount change /// </summary> private void OnPasswordTextChanged(object sender, EventArgs e) { App.Locator.Login.UserPassword = PasswordEditText.Text; if (PasswordEditText.Text.Length < 8) { PasswordEditText.SetError(Resources.GetString(Resource.String.login_password_error), null); if (timer != null) { timer.Cancel(); } } else { PasswordEditText.SetError(string.Empty, null); switch ((int)PasswordComplexityHelper.CheckStrength(PasswordEditText.Text)) { case (int)PasswordComplexityHelper.PasswordScore.Weak: var spanString0 = Resources.GetString(Resource.String.login_password_weak); var spanText0 = string.Format(spanString0, Resources.GetString(Resource.String.login_weak)); var resultTuple0 = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(spanString0, Resources.GetString(Resource.String.login_weak)); var formattedinfoText0 = new SpannableString(spanText0); formattedinfoText0.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.Red)), resultTuple0.Item1, resultTuple0.Item2, 0); PasswordEditText.SetError(formattedinfoText0, null); break; case (int)PasswordComplexityHelper.PasswordScore.Medium: var spanString = Resources.GetString(Resource.String.login_password_medium); var spanText = string.Format(spanString, Resources.GetString(Resource.String.login_medium)); var resultTuple = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(spanString, Resources.GetString(Resource.String.login_medium)); var formattedinfoText = new SpannableString(spanText); formattedinfoText.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.Orange)), resultTuple.Item1, resultTuple.Item2, 0); PasswordEditText.SetError(formattedinfoText, null); break; case (int)PasswordComplexityHelper.PasswordScore.Strong: case (int)PasswordComplexityHelper.PasswordScore.VeryStrong: var spanString1 = Resources.GetString(Resource.String.login_password_strong); var spanText1 = string.Format(spanString1, Resources.GetString(Resource.String.login_strong)); var resultTuple1 = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(spanString1, Resources.GetString(Resource.String.login_strong)); var formattedinfoText1 = new SpannableString(spanText1); formattedinfoText1.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.MainColor)), resultTuple1.Item1, resultTuple1.Item2, 0); PasswordEditText.SetError(formattedinfoText1, null); break; } LaunchTimerToHideError(); } if (string.IsNullOrEmpty(PasswordEditText.Text)) { PasswordEditText.Error = null; } }
/// <summary> /// Handle the display of the SetError overlay for the popup change password /// </summary> private void NewPasswordTextView_TextChanged(object sender, TextChangedEventArgs e) { var editText = sender as EditText; if (editText.Text.Length < 8) { editText.SetError(Resources.GetString(Resource.String.login_password_error), null); if (_timer != null) { _timer.Cancel(); } } else { editText.SetError(string.Empty, null); switch ((int)PasswordComplexityHelper.CheckStrength(editText.Text)) { case (int)PasswordComplexityHelper.PasswordScore.Weak: SetPasswordError(editText , Resources.GetString(Resource.String.login_password_weak) , Resources.GetString(Resource.String.login_weak), App.Red); break; case (int)PasswordComplexityHelper.PasswordScore.Medium: SetPasswordError(editText , Resources.GetString(Resource.String.login_password_medium) , Resources.GetString(Resource.String.login_medium), App.Orange); break; case (int)PasswordComplexityHelper.PasswordScore.Strong: case (int)PasswordComplexityHelper.PasswordScore.VeryStrong: SetPasswordError(editText , Resources.GetString(Resource.String.login_password_strong) , Resources.GetString(Resource.String.login_strong), App.MainColor); break; } if (_timer == null) { _timer = new MyTimer(2000, 2000, editText); } _timer.Cancel(); _timer.Start(); } if (string.IsNullOrEmpty(editText.Text)) { editText.Error = null; } }