From ef2123422c5e90524c0e339ea45b75135d1a538b Mon Sep 17 00:00:00 2001 From: Marco Dalla Libera Date: Mon, 12 Aug 2019 15:09:13 +0200 Subject: [PATCH 1/4] IMPROVED UNDERSCREEN FINGERPRINT, ISSUE #831 Improved underscreen fingerprint as request in issue #831 by giving the users the ability to disable the sensor in the PasswordActivity. Now pressing the fingerprint icon opens up a dialog that has the option to enable/disable the sensor. I added two new strings to the resources (enable sensor - disable sensor) and already translated them to italian. --- src/keepass2android/PasswordActivity.cs | 28 +++++++++++++++---- .../Resources/values-it/strings.xml | 2 ++ .../Resources/values/strings.xml | 4 ++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/keepass2android/PasswordActivity.cs b/src/keepass2android/PasswordActivity.cs index 12777d88..69eab3e2 100644 --- a/src/keepass2android/PasswordActivity.cs +++ b/src/keepass2android/PasswordActivity.cs @@ -904,10 +904,28 @@ namespace keepass2android AlertDialog.Builder b = new AlertDialog.Builder(this); b.SetTitle(Resource.String.fingerprint_prefs); b.SetMessage(btn.Tag.ToString()); - b.SetPositiveButton(Android.Resource.String.Ok, (o, eventArgs) => ((Dialog)o).Dismiss()); + + if (_fingerprintDec != null) + { + b.SetPositiveButton(Android.Resource.String.Ok, (o, eventArgs) => ((Dialog)o).Dismiss()); + b.SetNegativeButton(Resource.String.disable_sensor, (senderAlert, alertArgs) => + { + btn.SetImageResource(Resource.Drawable.ic_fingerprint_error); + _fingerprintDec?.StopListening(); + _fingerprintDec = null; + }); + } + else + { + b.SetPositiveButton(Android.Resource.String.Ok, (o, eventArgs) => ((Dialog)o).Dismiss()); + b.SetNegativeButton(Resource.String.enable_sensor, (senderAlert, alertArgs) => + { + InitFingerprintUnlock(); + }); + } b.Show(); }; - _fingerprintPermissionGranted = true; + _fingerprintPermissionGranted = true; } } @@ -919,7 +937,7 @@ namespace keepass2android edit.Commit(); } - + public void OnFingerprintError(string message) { var btn = FindViewById(Resource.Id.fingerprintbtn); @@ -999,7 +1017,7 @@ namespace keepass2android if (_appnameclickCount == 7) { - throw new Exception("this is an easter egg crash (to test uncaught exceptions."); + throw new Exception("this is an easter egg crash (to test uncaught exceptions.)"); } @@ -1112,7 +1130,7 @@ namespace keepass2android var changeDbButton = FindViewById