mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add handler to fix password freeze #226
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.SharedPreferences
|
|||||||
import android.hardware.fingerprint.FingerprintManager
|
import android.hardware.fingerprint.FingerprintManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Handler
|
||||||
import android.support.annotation.RequiresApi
|
import android.support.annotation.RequiresApi
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -31,6 +32,9 @@ class FingerPrintViewsManager(var context: AppCompatActivity,
|
|||||||
private var fingerprintMustBeConfigured = true
|
private var fingerprintMustBeConfigured = true
|
||||||
private var fingerPrintMode: FingerPrintHelper.Mode = FingerPrintHelper.Mode.NOT_CONFIGURED_MODE
|
private var fingerPrintMode: FingerPrintHelper.Mode = FingerPrintHelper.Mode.NOT_CONFIGURED_MODE
|
||||||
|
|
||||||
|
private var checkboxListenerHandler = Handler()
|
||||||
|
private var checkboxListenerRunnable: Runnable? = null
|
||||||
|
|
||||||
// makes it possible to store passwords per database
|
// makes it possible to store passwords per database
|
||||||
private val preferenceKeyValue: String
|
private val preferenceKeyValue: String
|
||||||
get() = PREF_KEY_VALUE_PREFIX + (databaseFileUri?.path ?: "")
|
get() = PREF_KEY_VALUE_PREFIX + (databaseFileUri?.path ?: "")
|
||||||
@@ -59,6 +63,10 @@ class FingerPrintViewsManager(var context: AppCompatActivity,
|
|||||||
|
|
||||||
// Add a check listener to change fingerprint mode
|
// Add a check listener to change fingerprint mode
|
||||||
checkboxPasswordView?.setOnCheckedChangeListener { compoundButton, checked ->
|
checkboxPasswordView?.setOnCheckedChangeListener { compoundButton, checked ->
|
||||||
|
|
||||||
|
// New runnable to each change
|
||||||
|
checkboxListenerHandler.removeCallbacks(checkboxListenerRunnable)
|
||||||
|
checkboxListenerRunnable = Runnable {
|
||||||
if (!fingerprintMustBeConfigured) {
|
if (!fingerprintMustBeConfigured) {
|
||||||
// encrypt or decrypt mode based on how much input or not
|
// encrypt or decrypt mode based on how much input or not
|
||||||
if (checked) {
|
if (checked) {
|
||||||
@@ -72,6 +80,8 @@ class FingerPrintViewsManager(var context: AppCompatActivity,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
checkboxListenerHandler.post(checkboxListenerRunnable)
|
||||||
|
|
||||||
// Add old listener to enable the button, only be call here because of onCheckedChange bug
|
// Add old listener to enable the button, only be call here because of onCheckedChange bug
|
||||||
onCheckedPasswordChangeListener?.onCheckedChanged(compoundButton, checked)
|
onCheckedPasswordChangeListener?.onCheckedChanged(compoundButton, checked)
|
||||||
|
|||||||
Reference in New Issue
Block a user