diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt index 7425bc708..30a532f4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt @@ -36,31 +36,33 @@ class SecureActivityDelegate(private val activity: FragmentActivity) { } fun onResume() { - val lockApp = preferences.useBiometricLock().get() - if (lockApp && BiometricUtil.isSupported(activity)) { - if (isAppLocked()) { - val intent = Intent(activity, BiometricUnlockActivity::class.java) - activity.startActivity(intent) - activity.overridePendingTransition(0, 0) + if (preferences.useBiometricLock().get()) { + if (BiometricUtil.isSupported(activity)) { + if (isAppLocked()) { + activity.startActivity(Intent(activity, BiometricUnlockActivity::class.java)) + activity.overridePendingTransition(0, 0) + } + } else { + preferences.useBiometricLock().set(false) } - } else if (lockApp) { - preferences.useBiometricLock().set(false) } } @OptIn(ExperimentalTime::class) private fun isAppLocked(): Boolean { - return locked && - ( - preferences.lockAppAfter().get() <= 0 || - Date().time >= preferences.lastAppUnlock().get() + 60 * 1000 * preferences.lockAppAfter().get() - ) && preferences.biometricTimeRanges().get().mapNotNull { TimeRange.fromPreferenceString(it) }.let { timeRanges -> - if (timeRanges.isNotEmpty()) { - val today: Calendar = Calendar.getInstance() - val now = today.get(Calendar.HOUR_OF_DAY).hours + today.get(Calendar.MINUTE).minutes - timeRanges.any { now in it.startTime..it.endTime } - } else true + if (!locked) { + return false } + + return preferences.lockAppAfter().get() <= 0 || + Date().time >= preferences.lastAppUnlock().get() + 60 * 1000 * preferences.lockAppAfter().get() && + preferences.biometricTimeRanges().get().mapNotNull { TimeRange.fromPreferenceString(it) }.let { timeRanges -> + if (timeRanges.isNotEmpty()) { + val today: Calendar = Calendar.getInstance() + val now = today.get(Calendar.HOUR_OF_DAY).hours + today.get(Calendar.MINUTE).minutes + timeRanges.any { now in it.startTime..it.endTime } + } else true + } } companion object { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2bea9d3ce..dcbbd305f 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -298,7 +298,7 @@ Both Actions Show on long tap - Saves pages into separate folders + Save pages into separate folders Creates folders according to manga title Background color White