Fix logic of app unlock (#7569)

(cherry picked from commit 8ea05e852efd621ee987c7e45d6db64a083eeffd)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/App.kt
(cherry picked from commit 09e5bcaec1916f4a2e846fc622749b092b10e994)
This commit is contained in:
AntsyLich 2022-07-22 08:23:59 +06:00 committed by Jobobby04
parent 06f0817bec
commit d52511d5ce
4 changed files with 4 additions and 4 deletions

View File

@ -72,6 +72,7 @@ import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File
import java.security.Security import java.security.Security
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale import java.util.Locale
import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.days
@ -182,6 +183,7 @@ open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
} }
override fun onStop(owner: LifecycleOwner) { override fun onStop(owner: LifecycleOwner) {
preferences.lastAppClosed().set(Date().time)
if (!AuthenticatorUtil.isAuthenticating && preferences.lockAppAfter().get() >= 0) { if (!AuthenticatorUtil.isAuthenticating && preferences.lockAppAfter().get() >= 0) {
SecureActivityDelegate.locked = true SecureActivityDelegate.locked = true
} }

View File

@ -59,7 +59,7 @@ class PreferencesHelper(val context: Context) {
fun lockAppAfter() = flowPrefs.getInt("lock_app_after", 0) fun lockAppAfter() = flowPrefs.getInt("lock_app_after", 0)
fun lastAppUnlock() = flowPrefs.getLong("last_app_unlock", 0) fun lastAppClosed() = flowPrefs.getLong("last_app_closed", 0)
fun secureScreen() = flowPrefs.getEnum("secure_screen_v2", Values.SecureScreenMode.INCOGNITO) fun secureScreen() = flowPrefs.getEnum("secure_screen_v2", Values.SecureScreenMode.INCOGNITO)

View File

@ -119,6 +119,6 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
// SY <-- // SY <--
return preferences.lockAppAfter().get() <= 0 || return preferences.lockAppAfter().get() <= 0 ||
Date().time >= preferences.lastAppUnlock().get() + 60 * 1000 * preferences.lockAppAfter().get() Date().time >= preferences.lastAppClosed().get() + 60 * 1000 * preferences.lockAppAfter().get()
} }
} }

View File

@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.startAuthentication import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.startAuthentication
import eu.kanade.tachiyomi.util.system.logcat import eu.kanade.tachiyomi.util.system.logcat
import logcat.LogPriority import logcat.LogPriority
import java.util.Date
/** /**
* Blank activity with a BiometricPrompt. * Blank activity with a BiometricPrompt.
@ -39,7 +38,6 @@ class UnlockActivity : BaseActivity() {
) { ) {
super.onAuthenticationSucceeded(activity, result) super.onAuthenticationSucceeded(activity, result)
SecureActivityDelegate.locked = false SecureActivityDelegate.locked = false
preferences.lastAppUnlock().set(Date().time)
finish() finish()
} }
}, },