Add biometric error message

This commit is contained in:
J-Jamet
2019-11-21 10:44:22 +01:00
parent 06320a7eba
commit 6b1b8c0f7b
3 changed files with 18 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import android.view.MenuInflater
import android.widget.CompoundButton
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.biometric.BiometricConstants
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricPrompt
import androidx.fragment.app.FragmentActivity
@@ -155,7 +156,7 @@ class AdvancedUnlockedManager(var context: FragmentActivity,
private fun initNotAvailable() {
showFingerPrintViews(false)
advancedUnlockInfoView?.setIconViewClickListener(null)
advancedUnlockInfoView?.setIconViewClickListener(false, null)
}
private fun initNotConfigured() {
@@ -173,7 +174,11 @@ class AdvancedUnlockedManager(var context: FragmentActivity,
setAdvancedUnlockedTitleView(R.string.no_credentials_stored)
setAdvancedUnlockedMessageView("")
advancedUnlockInfoView?.setIconViewClickListener(null)
advancedUnlockInfoView?.setIconViewClickListener(false) {
biometricAuthenticationCallback.onAuthenticationError(
BiometricConstants.ERROR_UNABLE_TO_PROCESS
, context.getString(R.string.credential_before_click_biometric_button))
}
}
private fun openBiometricPrompt(biometricPrompt: BiometricPrompt?,

View File

@@ -51,12 +51,18 @@ class AdvancedUnlockInfoView @JvmOverloads constructor(context: Context,
}
}
fun setIconViewClickListener(listener: ((view: View)->Unit)?) {
fun setIconViewClickListener(animation: Boolean = true,
listener: ((view: View)->Unit)?) {
var animateButton = animation
if (listener == null)
stopIconViewAnimation()
else
animateButton = false
if (animateButton) {
startIconViewAnimation()
unlockContainerView.alpha = if (listener == null) 0.8f else 1f
unlockContainerView.alpha = 1f
} else {
stopIconViewAnimation()
unlockContainerView.alpha = 0.8f
}
unlockIconImageView?.setOnClickListener(listener)
}

View File

@@ -261,6 +261,7 @@
<!--This problem could be with scanning, or something else.-->
<string name="biometric_scanning_error">Biometric error: %1$s</string>
<string name="no_credentials_stored">This database does not have stored credential yet.</string>
<string name="credential_before_click_biometric_button">Type the password before clicking the biometric button.</string>
<string name="database_history">History</string>
<string name="menu_appearance_settings">Appearance</string>
<string name="biometric">Biometric</string>