diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt
index 36c1067a7..1f765a80e 100644
--- a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt
@@ -280,7 +280,7 @@ class PasswordActivity : StylishActivity() {
// Init FingerPrint elements
var fingerPrintInit = false
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- if (PreferencesUtil.isBiometricPromptEnable(this)) {
+ if (PreferencesUtil.isBiometricUnlockEnable(this)) {
advancedUnlockInfoView?.setOnClickListener {
FingerPrintExplanationDialog().show(supportFragmentManager, "fingerPrintExplanationDialog")
@@ -432,7 +432,7 @@ class PasswordActivity : StylishActivity() {
runOnUiThread {
// Recheck fingerprint if error
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- if (PreferencesUtil.isBiometricPromptEnable(this@PasswordActivity)) {
+ if (PreferencesUtil.isBiometricUnlockEnable(this@PasswordActivity)) {
// Stay with the same mode and init it
advancedUnlockedViewManager?.initBiometricMode()
}
@@ -529,7 +529,7 @@ class PasswordActivity : StylishActivity() {
val biometricCanAuthenticate = BiometricManager.from(this).canAuthenticate()
// fingerprintEducationPerformed
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
- && PreferencesUtil.isBiometricPromptEnable(applicationContext)
+ && PreferencesUtil.isBiometricUnlockEnable(applicationContext)
&& (biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED || biometricCanAuthenticate == BiometricManager.BIOMETRIC_SUCCESS)
&& advancedUnlockInfoView != null && advancedUnlockInfoView?.unlockIconImageView != null
&& passwordActivityEducation.checkAndPerformedFingerprintEducation(advancedUnlockInfoView?.unlockIconImageView!!)
diff --git a/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockedViewManager.kt b/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockedViewManager.kt
index b9b833b3b..79375f2c7 100644
--- a/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockedViewManager.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockedViewManager.kt
@@ -30,6 +30,8 @@ class AdvancedUnlockedViewManager(var context: FragmentActivity,
private var biometricHelper: BiometricHelper? = null
private var biometricMode: Mode = Mode.NOT_CONFIGURED
+ private var isBiometricPromptAutoOpenEnable = PreferencesUtil.isBiometricPromptAutoOpenEnable(context)
+
// makes it possible to store passwords per database
private val preferenceKeyValue: String
get() = PREF_KEY_VALUE_PREFIX + (databaseFileUri?.path ?: "")
@@ -70,7 +72,7 @@ class AdvancedUnlockedViewManager(var context: FragmentActivity,
// or manually disable
val biometricCanAuthenticate = BiometricManager.from(context).canAuthenticate()
- val newBiometricMode: Mode = if (!PreferencesUtil.isBiometricPromptEnable(context)
+ val newBiometricMode: Mode = if (!PreferencesUtil.isBiometricUnlockEnable(context)
|| biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE
|| biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE) {
@@ -148,8 +150,6 @@ class AdvancedUnlockedViewManager(var context: FragmentActivity,
}
private fun initPause() {
- showFingerPrintViews(true)
-
advancedUnlockInfoView?.setIconViewClickListener(null)
}
@@ -172,12 +172,14 @@ class AdvancedUnlockedViewManager(var context: FragmentActivity,
setAdvancedUnlockedView(R.string.open_biometric_prompt_store_credential)
biometricHelper?.initEncryptData { biometricPrompt, cryptoObject, promptInfo ->
- // Set listener to open the biometric dialog and save credential
- advancedUnlockInfoView?.setIconViewClickListener { _ ->
- cryptoObject?.let { crypto ->
+
+ cryptoObject?.let { crypto ->
+ // Set listener to open the biometric dialog and save credential
+ advancedUnlockInfoView?.setIconViewClickListener { _ ->
biometricPrompt?.authenticate(promptInfo, crypto)
}
}
+
}
}
@@ -188,12 +190,20 @@ class AdvancedUnlockedViewManager(var context: FragmentActivity,
if (biometricHelper != null) {
prefsNoBackup.getString(preferenceKeyIvSpec, null)?.let {
biometricHelper?.initDecryptData(it) { biometricPrompt, cryptoObject, promptInfo ->
- // Set listener to open the biometric dialog and check credential
- advancedUnlockInfoView?.setIconViewClickListener { _ ->
- cryptoObject?.let { crypto ->
+
+ cryptoObject?.let { crypto ->
+ // Set listener to open the biometric dialog and check credential
+ advancedUnlockInfoView?.setIconViewClickListener { _ ->
+ biometricPrompt?.authenticate(promptInfo, crypto)
+ }
+
+ // Auto open the biometric prompt
+ if (isBiometricPromptAutoOpenEnable) {
+ isBiometricPromptAutoOpenEnable = false
biometricPrompt?.authenticate(promptInfo, crypto)
}
}
+
}
}
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt
index da5252ef4..7465d7775 100644
--- a/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/settings/PreferencesUtil.kt
@@ -128,12 +128,18 @@ object PreferencesUtil {
context.resources.getBoolean(R.bool.lock_database_back_root_default))
}
- fun isBiometricPromptEnable(context: Context): Boolean {
+ fun isBiometricUnlockEnable(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.biometric_unlock_enable_key),
context.resources.getBoolean(R.bool.biometric_unlock_enable_default))
}
+ fun isBiometricPromptAutoOpenEnable(context: Context): Boolean {
+ val prefs = PreferenceManager.getDefaultSharedPreferences(context)
+ return prefs.getBoolean(context.getString(R.string.biometric_auto_open_prompt_key),
+ context.resources.getBoolean(R.bool.biometric_auto_open_prompt_default))
+ }
+
fun isFullFilePathEnable(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.full_file_path_enable_key),
diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml
index b0ffdb9b3..fb251c9f5 100644
--- a/app/src/main/res/values/donottranslate.xml
+++ b/app/src/main/res/values/donottranslate.xml
@@ -94,6 +94,8 @@
true
biometric_unlock_enable_key
false
+ biometric_auto_open_prompt_key
+ false
biometric_delete_all_key_key
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c2af0e75d..e7e48d383 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -272,6 +272,8 @@
Advanced unlock
Biometric unlocking
Lets you scan your fingerprint or other biometric to open the database
+ Auto open biometric prompt
+ Automatically open biometric prompt when a biometric key is defined for a database
Delete encryption keys
Delete all encryption keys related to biometric recognition
Are you sure you want to delete all keys related to biometric recognition?
diff --git a/app/src/main/res/xml/preferences_advanced_unlock.xml b/app/src/main/res/xml/preferences_advanced_unlock.xml
index 12d9f5362..763ac1c21 100644
--- a/app/src/main/res/xml/preferences_advanced_unlock.xml
+++ b/app/src/main/res/xml/preferences_advanced_unlock.xml
@@ -26,6 +26,11 @@
android:title="@string/biometric_unlock_enable_title"
android:summary="@string/biometric_unlock_enable_summary"
android:defaultValue="@bool/biometric_unlock_enable_default"/>
+