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:
Ivan Iskandar
2022-10-15 22:38:01 +07:00
committed by GitHub
parent 3fdcd636d7
commit 890f1a3c7b
42 changed files with 4904 additions and 80 deletions

View File

@@ -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
*/