remove biometrics confirmation when toggling on/off the setting

yeah i tried a face unlock can you tell?
This commit is contained in:
Jays2Kings 2023-10-17 21:47:51 -07:00
parent cea490be3a
commit 0b37080e47
3 changed files with 5 additions and 0 deletions

View file

@ -202,6 +202,7 @@ fun SwitchPreferenceCompat.requireAuthentication(
activity: FragmentActivity?,
title: String,
subtitle: String? = null,
confirmationRequired: Boolean = true,
) {
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
newValue as Boolean
@ -209,6 +210,7 @@ fun SwitchPreferenceCompat.requireAuthentication(
activity.startAuthentication(
title,
subtitle,
confirmationRequired,
callback = object : AuthenticatorUtil.AuthenticationCallback() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)

View file

@ -22,6 +22,7 @@ class SettingsSecurityController : SettingsController() {
requireAuthentication(
activity as? FragmentActivity,
context.getString(R.string.lock_with_biometrics),
confirmationRequired = false,
)
}
intListPreference(activity) {

View file

@ -27,6 +27,7 @@ object AuthenticatorUtil {
fun FragmentActivity.startAuthentication(
title: String,
subtitle: String? = null,
confirmationRequired: Boolean = true,
callback: AuthenticationCallback,
) {
isAuthenticating = true
@ -41,6 +42,7 @@ object AuthenticatorUtil {
.setTitle(title)
.setSubtitle(subtitle)
.setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL or BiometricManager.Authenticators.BIOMETRIC_WEAK)
.setConfirmationRequired(confirmationRequired)
.build()
biometricPrompt.authenticate(promptInfo)