Restore cursor position after switching password visibility.

This commit is contained in:
DDoSolitary
2019-07-27 13:22:42 +08:00
parent e5dbd86eb3
commit b89f3906e9
3 changed files with 6 additions and 2 deletions

View File

@@ -150,6 +150,7 @@ namespace keepass2android
{ {
TextView password = (TextView)FindViewById(Resource.Id.entry_password); TextView password = (TextView)FindViewById(Resource.Id.entry_password);
TextView confpassword = (TextView)FindViewById(Resource.Id.entry_confpassword); TextView confpassword = (TextView)FindViewById(Resource.Id.entry_confpassword);
int selStart = password.SelectionStart, selEnd = password.SelectionEnd;
if (_showPassword) if (_showPassword)
{ {
password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword; password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
@@ -161,7 +162,7 @@ namespace keepass2android
password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
confpassword.Visibility = ViewStates.Visible; confpassword.Visibility = ViewStates.Visible;
} }
password.SetSelection(selStart, selEnd);
} }
private void CreateDatabase(bool makeCurrent) private void CreateDatabase(bool makeCurrent)

View File

@@ -393,6 +393,7 @@ namespace keepass2android
{ {
TextView password = (TextView) FindViewById(Resource.Id.entry_password); TextView password = (TextView) FindViewById(Resource.Id.entry_password);
TextView confpassword = (TextView) FindViewById(Resource.Id.entry_confpassword); TextView confpassword = (TextView) FindViewById(Resource.Id.entry_confpassword);
int selStart = password.SelectionStart, selEnd = password.SelectionEnd;
if (State.ShowPassword) if (State.ShowPassword)
{ {
password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword; password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
@@ -403,6 +404,7 @@ namespace keepass2android
password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
confpassword.Visibility = ViewStates.Visible; confpassword.Visibility = ViewStates.Visible;
} }
password.SetSelection(selStart, selEnd);
} }
void SaveEntry() void SaveEntry()

View File

@@ -1498,6 +1498,7 @@ namespace keepass2android
private void MakePasswordMaskedOrVisible() private void MakePasswordMaskedOrVisible()
{ {
TextView password = (TextView) FindViewById(Resource.Id.password_edit); TextView password = (TextView) FindViewById(Resource.Id.password_edit);
int selStart = password.SelectionStart, selEnd = password.SelectionEnd;
if (_showPassword) if (_showPassword)
{ {
password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword; password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword;
@@ -1507,7 +1508,7 @@ namespace keepass2android
{ {
password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
} }
password.SetSelection(selStart, selEnd);
} }
protected override void OnPause() protected override void OnPause()