Minor cleanup
(cherry picked from commit fcde6c2b84d83735675207144f1c0519070412d2) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt
This commit is contained in:
parent
d332f98b34
commit
f5a90d46ec
@ -36,31 +36,33 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onResume() {
|
fun onResume() {
|
||||||
val lockApp = preferences.useBiometricLock().get()
|
if (preferences.useBiometricLock().get()) {
|
||||||
if (lockApp && BiometricUtil.isSupported(activity)) {
|
if (BiometricUtil.isSupported(activity)) {
|
||||||
if (isAppLocked()) {
|
if (isAppLocked()) {
|
||||||
val intent = Intent(activity, BiometricUnlockActivity::class.java)
|
activity.startActivity(Intent(activity, BiometricUnlockActivity::class.java))
|
||||||
activity.startActivity(intent)
|
activity.overridePendingTransition(0, 0)
|
||||||
activity.overridePendingTransition(0, 0)
|
}
|
||||||
|
} else {
|
||||||
|
preferences.useBiometricLock().set(false)
|
||||||
}
|
}
|
||||||
} else if (lockApp) {
|
|
||||||
preferences.useBiometricLock().set(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
@OptIn(ExperimentalTime::class)
|
||||||
private fun isAppLocked(): Boolean {
|
private fun isAppLocked(): Boolean {
|
||||||
return locked &&
|
if (!locked) {
|
||||||
(
|
return false
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
companion object {
|
||||||
|
@ -298,7 +298,7 @@
|
|||||||
<string name="tapping_inverted_both">Both</string>
|
<string name="tapping_inverted_both">Both</string>
|
||||||
<string name="pref_reader_actions">Actions</string>
|
<string name="pref_reader_actions">Actions</string>
|
||||||
<string name="pref_read_with_long_tap">Show on long tap</string>
|
<string name="pref_read_with_long_tap">Show on long tap</string>
|
||||||
<string name="pref_create_folder_per_manga">Saves pages into separate folders</string>
|
<string name="pref_create_folder_per_manga">Save pages into separate folders</string>
|
||||||
<string name="pref_create_folder_per_manga_summary">Creates folders according to manga title</string>
|
<string name="pref_create_folder_per_manga_summary">Creates folders according to manga title</string>
|
||||||
<string name="pref_reader_theme">Background color</string>
|
<string name="pref_reader_theme">Background color</string>
|
||||||
<string name="white_background">White</string>
|
<string name="white_background">White</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user