From b89f3906e972ae4612ea0d6329d0f22a10d285ae Mon Sep 17 00:00:00 2001 From: DDoSolitary Date: Sat, 27 Jul 2019 13:22:42 +0800 Subject: [PATCH] Restore cursor position after switching password visibility. --- src/keepass2android/CreateDatabaseActivity.cs | 3 ++- src/keepass2android/EntryEditActivity.cs | 2 ++ src/keepass2android/PasswordActivity.cs | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/keepass2android/CreateDatabaseActivity.cs b/src/keepass2android/CreateDatabaseActivity.cs index fef1d7b5..1e1d7614 100644 --- a/src/keepass2android/CreateDatabaseActivity.cs +++ b/src/keepass2android/CreateDatabaseActivity.cs @@ -150,6 +150,7 @@ namespace keepass2android { TextView password = (TextView)FindViewById(Resource.Id.entry_password); TextView confpassword = (TextView)FindViewById(Resource.Id.entry_confpassword); + int selStart = password.SelectionStart, selEnd = password.SelectionEnd; if (_showPassword) { password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword; @@ -161,7 +162,7 @@ namespace keepass2android password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; confpassword.Visibility = ViewStates.Visible; } - + password.SetSelection(selStart, selEnd); } private void CreateDatabase(bool makeCurrent) diff --git a/src/keepass2android/EntryEditActivity.cs b/src/keepass2android/EntryEditActivity.cs index 34b7a1e3..26c3c007 100644 --- a/src/keepass2android/EntryEditActivity.cs +++ b/src/keepass2android/EntryEditActivity.cs @@ -393,6 +393,7 @@ namespace keepass2android { TextView password = (TextView) FindViewById(Resource.Id.entry_password); TextView confpassword = (TextView) FindViewById(Resource.Id.entry_confpassword); + int selStart = password.SelectionStart, selEnd = password.SelectionEnd; if (State.ShowPassword) { password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword; @@ -403,6 +404,7 @@ namespace keepass2android password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; confpassword.Visibility = ViewStates.Visible; } + password.SetSelection(selStart, selEnd); } void SaveEntry() diff --git a/src/keepass2android/PasswordActivity.cs b/src/keepass2android/PasswordActivity.cs index 8f0261d1..38230e37 100644 --- a/src/keepass2android/PasswordActivity.cs +++ b/src/keepass2android/PasswordActivity.cs @@ -1498,6 +1498,7 @@ namespace keepass2android private void MakePasswordMaskedOrVisible() { TextView password = (TextView) FindViewById(Resource.Id.password_edit); + int selStart = password.SelectionStart, selEnd = password.SelectionEnd; if (_showPassword) { password.InputType = InputTypes.ClassText | InputTypes.TextVariationVisiblePassword; @@ -1507,7 +1508,7 @@ namespace keepass2android { password.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; } - + password.SetSelection(selStart, selEnd); } protected override void OnPause()