mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 21:18:56 +01:00
Full Compose settings (#8201)
* Uses Voyager for navigation. * Replaces every screen inside settings except category editor screen since it's called from several places.
This commit is contained in:
@@ -10,6 +10,9 @@ import androidx.biometric.auth.AuthPromptCallback
|
||||
import androidx.biometric.auth.startClass2BiometricOrCredentialAuthentication
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import eu.kanade.tachiyomi.R
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
object AuthenticatorUtil {
|
||||
|
||||
@@ -43,6 +46,45 @@ object AuthenticatorUtil {
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun FragmentActivity.authenticate(
|
||||
title: String,
|
||||
subtitle: String? = getString(R.string.confirm_lock_change),
|
||||
): Boolean = suspendCancellableCoroutine { cont ->
|
||||
if (!isAuthenticationSupported()) {
|
||||
cont.resume(true)
|
||||
return@suspendCancellableCoroutine
|
||||
}
|
||||
|
||||
startAuthentication(
|
||||
title,
|
||||
subtitle,
|
||||
callback = object : AuthenticationCallback() {
|
||||
override fun onAuthenticationSucceeded(
|
||||
activity: FragmentActivity?,
|
||||
result: BiometricPrompt.AuthenticationResult,
|
||||
) {
|
||||
super.onAuthenticationSucceeded(activity, result)
|
||||
cont.resume(true)
|
||||
}
|
||||
|
||||
override fun onAuthenticationError(
|
||||
activity: FragmentActivity?,
|
||||
errorCode: Int,
|
||||
errString: CharSequence,
|
||||
) {
|
||||
super.onAuthenticationError(activity, errorCode, errString)
|
||||
activity?.toast(errString.toString())
|
||||
cont.resume(false)
|
||||
}
|
||||
|
||||
override fun onAuthenticationFailed(activity: FragmentActivity?) {
|
||||
super.onAuthenticationFailed(activity)
|
||||
cont.resume(false)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if Class 2 biometric or credential lock is set and available to use
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user