Fix always-on app lock on cold start (#8018)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/App.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/base/delegate/SecureActivityDelegate.kt
This commit is contained in:
Ivan Iskandar 2022-09-16 19:34:46 +07:00 committed by Jobobby04
parent a27b25f7c6
commit 5d5cc22020
2 changed files with 13 additions and 0 deletions

View File

@ -210,6 +210,10 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
}.build()
}
override fun onCreate(owner: LifecycleOwner) {
SecureActivityDelegate.onApplicationCreated()
}
private fun addAnalytics() {
if (syDebugVersion != "0") {
Firebase.analytics.setUserProperty("preview_version", syDebugVersion)

View File

@ -46,6 +46,15 @@ interface SecureActivityDelegate {
const val LOCK_ALL_DAYS = 0x7F
// SY <--
fun onApplicationCreated() {
val lockDelay = Injekt.get<PreferencesHelper>().lockAppAfter().get()
if (lockDelay == 0) {
// Restore always active app lock
// Delayed lock will be restored later on activity resume
lockState = LockState.ACTIVE
}
}
fun onApplicationStopped() {
val preferences = Injekt.get<PreferencesHelper>()
if (!preferences.useAuthenticator().get()) return