Add handler to fix password freeze #226

This commit is contained in:
J-Jamet
2019-08-07 11:27:11 +02:00
parent bca777a97e
commit ced6a77819

View File

@@ -5,6 +5,7 @@ import android.content.SharedPreferences
import android.hardware.fingerprint.FingerprintManager
import android.net.Uri
import android.os.Build
import android.os.Handler
import android.support.annotation.RequiresApi
import android.support.v7.app.AppCompatActivity
import android.util.Log
@@ -31,6 +32,9 @@ class FingerPrintViewsManager(var context: AppCompatActivity,
private var fingerprintMustBeConfigured = true
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
private val preferenceKeyValue: String
get() = PREF_KEY_VALUE_PREFIX + (databaseFileUri?.path ?: "")
@@ -59,6 +63,10 @@ class FingerPrintViewsManager(var context: AppCompatActivity,
// Add a check listener to change fingerprint mode
checkboxPasswordView?.setOnCheckedChangeListener { compoundButton, checked ->
// New runnable to each change
checkboxListenerHandler.removeCallbacks(checkboxListenerRunnable)
checkboxListenerRunnable = Runnable {
if (!fingerprintMustBeConfigured) {
// encrypt or decrypt mode based on how much input or not
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
onCheckedPasswordChangeListener?.onCheckedChanged(compoundButton, checked)