Rename some biometrics things since it's no longer specifically for biometric auth
(cherry picked from commit c741920ec0e698da28469f96b2c5ecc6cbf36f5e) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt # app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt
This commit is contained in:
parent
2b075b5a39
commit
d8ee654a65
@ -84,7 +84,7 @@
|
|||||||
android:resource="@xml/s_pen_actions"/>
|
android:resource="@xml/s_pen_actions"/>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.security.BiometricUnlockActivity"
|
android:name=".ui.security.UnlockActivity"
|
||||||
android:theme="@style/Theme.Base" />
|
android:theme="@style/Theme.Base" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.webview.WebViewActivity"
|
android:name=".ui.webview.WebViewActivity"
|
||||||
|
@ -15,10 +15,6 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val hideBottomBar = "pref_hide_bottom_bar_on_scroll"
|
const val hideBottomBar = "pref_hide_bottom_bar_on_scroll"
|
||||||
|
|
||||||
const val hideUpdatesButton = "pref_hide_updates_button"
|
|
||||||
|
|
||||||
const val hideHistoryButton = "pref_hide_history_button"
|
|
||||||
|
|
||||||
const val enableTransitionsPager = "pref_enable_transitions_pager_key"
|
const val enableTransitionsPager = "pref_enable_transitions_pager_key"
|
||||||
|
|
||||||
const val enableTransitionsWebtoon = "pref_enable_transitions_webtoon_key"
|
const val enableTransitionsWebtoon = "pref_enable_transitions_webtoon_key"
|
||||||
@ -164,7 +160,7 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val startScreen = "start_screen"
|
const val startScreen = "start_screen"
|
||||||
|
|
||||||
const val useBiometricLock = "use_biometric_lock"
|
const val useAuthenticator = "use_biometric_lock"
|
||||||
|
|
||||||
const val lockAppAfter = "lock_app_after"
|
const val lockAppAfter = "lock_app_after"
|
||||||
|
|
||||||
@ -355,7 +351,7 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val allowLocalSourceHiddenFolders = "allow_local_source_hidden_folders"
|
const val allowLocalSourceHiddenFolders = "allow_local_source_hidden_folders"
|
||||||
|
|
||||||
const val biometricTimeRanges = "biometric_time_ranges"
|
const val authenticatorTimeRanges = "biometric_time_ranges"
|
||||||
|
|
||||||
const val sortTagsForLibrary = "sort_tags_for_library"
|
const val sortTagsForLibrary = "sort_tags_for_library"
|
||||||
|
|
||||||
@ -374,4 +370,8 @@ object PreferenceKeys {
|
|||||||
const val readerBottomButtons = "reader_bottom_buttons"
|
const val readerBottomButtons = "reader_bottom_buttons"
|
||||||
|
|
||||||
const val bottomBarLabels = "pref_show_bottom_bar_labels"
|
const val bottomBarLabels = "pref_show_bottom_bar_labels"
|
||||||
|
|
||||||
|
const val hideUpdatesButton = "pref_hide_updates_button"
|
||||||
|
|
||||||
|
const val hideHistoryButton = "pref_hide_history_button"
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,7 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true)
|
fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true)
|
||||||
|
|
||||||
fun hideUpdatesButton() = flowPrefs.getBoolean(Keys.hideUpdatesButton, false)
|
fun useAuthenticator() = flowPrefs.getBoolean(Keys.useAuthenticator, false)
|
||||||
|
|
||||||
fun hideHistoryButton() = flowPrefs.getBoolean(Keys.hideHistoryButton, false)
|
|
||||||
|
|
||||||
fun bottomBarLabels() = flowPrefs.getBoolean(Keys.bottomBarLabels, true)
|
|
||||||
|
|
||||||
fun useBiometricLock() = flowPrefs.getBoolean(Keys.useBiometricLock, false)
|
|
||||||
|
|
||||||
fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0)
|
fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0)
|
||||||
|
|
||||||
@ -472,7 +466,7 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun allowLocalSourceHiddenFolders() = flowPrefs.getBoolean(Keys.allowLocalSourceHiddenFolders, false)
|
fun allowLocalSourceHiddenFolders() = flowPrefs.getBoolean(Keys.allowLocalSourceHiddenFolders, false)
|
||||||
|
|
||||||
fun biometricTimeRanges() = flowPrefs.getStringSet(Keys.biometricTimeRanges, mutableSetOf())
|
fun authenticatorTimeRanges() = flowPrefs.getStringSet(Keys.authenticatorTimeRanges, mutableSetOf())
|
||||||
|
|
||||||
fun sortTagsForLibrary() = flowPrefs.getStringSet(Keys.sortTagsForLibrary, mutableSetOf())
|
fun sortTagsForLibrary() = flowPrefs.getStringSet(Keys.sortTagsForLibrary, mutableSetOf())
|
||||||
|
|
||||||
@ -489,4 +483,10 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun leftVerticalSeekbar() = flowPrefs.getBoolean(Keys.leftVerticalSeekbar, false)
|
fun leftVerticalSeekbar() = flowPrefs.getBoolean(Keys.leftVerticalSeekbar, false)
|
||||||
|
|
||||||
fun readerBottomButtons() = flowPrefs.getStringSet(Keys.readerBottomButtons, ReaderBottomButton.BUTTONS_DEFAULTS)
|
fun readerBottomButtons() = flowPrefs.getStringSet(Keys.readerBottomButtons, ReaderBottomButton.BUTTONS_DEFAULTS)
|
||||||
|
|
||||||
|
fun bottomBarLabels() = flowPrefs.getBoolean(Keys.bottomBarLabels, true)
|
||||||
|
|
||||||
|
fun hideUpdatesButton() = flowPrefs.getBoolean(Keys.hideUpdatesButton, false)
|
||||||
|
|
||||||
|
fun hideHistoryButton() = flowPrefs.getBoolean(Keys.hideHistoryButton, false)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
|
|||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
super.onCreate(savedState)
|
super.onCreate(savedState)
|
||||||
|
|
||||||
preferences.biometricTimeRanges().asFlow().onEach { prefTimeRanges ->
|
preferences.authenticatorTimeRanges().asFlow().onEach { prefTimeRanges ->
|
||||||
timeRanges = prefTimeRanges.toList()
|
timeRanges = prefTimeRanges.toList()
|
||||||
.mapNotNull { TimeRange.fromPreferenceString(it) }.onEach { xLogD(it) }
|
.mapNotNull { TimeRange.fromPreferenceString(it) }.onEach { xLogD(it) }
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
|
|||||||
|
|
||||||
xLogD(timeRange)
|
xLogD(timeRange)
|
||||||
|
|
||||||
preferences.biometricTimeRanges() += timeRange.toPreferenceString()
|
preferences.authenticatorTimeRanges() += timeRange.toPreferenceString()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +68,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
|
|||||||
* @param timeRanges The list of categories to delete.
|
* @param timeRanges The list of categories to delete.
|
||||||
*/
|
*/
|
||||||
fun deleteTimeRanges(timeRanges: List<TimeRange>) {
|
fun deleteTimeRanges(timeRanges: List<TimeRange>) {
|
||||||
preferences.biometricTimeRanges().set(
|
preferences.authenticatorTimeRanges().set(
|
||||||
this.timeRanges.filterNot { it in timeRanges }.map { it.toPreferenceString() }.toSet()
|
this.timeRanges.filterNot { it in timeRanges }.map { it.toPreferenceString() }.toSet()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import androidx.fragment.app.FragmentActivity
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.category.biometric.TimeRange
|
import eu.kanade.tachiyomi.ui.category.biometric.TimeRange
|
||||||
import eu.kanade.tachiyomi.util.system.BiometricUtil
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -36,14 +36,14 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onResume() {
|
fun onResume() {
|
||||||
if (preferences.useBiometricLock().get()) {
|
if (preferences.useAuthenticator().get()) {
|
||||||
if (BiometricUtil.isSupported(activity)) {
|
if (AuthenticatorUtil.isSupported(activity)) {
|
||||||
if (isAppLocked()) {
|
if (isAppLocked()) {
|
||||||
activity.startActivity(Intent(activity, BiometricUnlockActivity::class.java))
|
activity.startActivity(Intent(activity, UnlockActivity::class.java))
|
||||||
activity.overridePendingTransition(0, 0)
|
activity.overridePendingTransition(0, 0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
preferences.useBiometricLock().set(false)
|
preferences.useAuthenticator().set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
|
|||||||
|
|
||||||
return preferences.lockAppAfter().get() <= 0 ||
|
return preferences.lockAppAfter().get() <= 0 ||
|
||||||
Date().time >= preferences.lastAppUnlock().get() + 60 * 1000 * preferences.lockAppAfter().get() &&
|
Date().time >= preferences.lastAppUnlock().get() + 60 * 1000 * preferences.lockAppAfter().get() &&
|
||||||
preferences.biometricTimeRanges().get().mapNotNull { TimeRange.fromPreferenceString(it) }.let { timeRanges ->
|
preferences.authenticatorTimeRanges().get().mapNotNull { TimeRange.fromPreferenceString(it) }.let { timeRanges ->
|
||||||
if (timeRanges.isNotEmpty()) {
|
if (timeRanges.isNotEmpty()) {
|
||||||
val today: Calendar = Calendar.getInstance()
|
val today: Calendar = Calendar.getInstance()
|
||||||
val now = today.get(Calendar.HOUR_OF_DAY).hours + today.get(Calendar.MINUTE).minutes
|
val now = today.get(Calendar.HOUR_OF_DAY).hours + today.get(Calendar.MINUTE).minutes
|
||||||
|
@ -4,7 +4,7 @@ import android.os.Bundle
|
|||||||
import androidx.biometric.BiometricPrompt
|
import androidx.biometric.BiometricPrompt
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseThemedActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseThemedActivity
|
||||||
import eu.kanade.tachiyomi.util.system.BiometricUtil
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
@ -12,7 +12,7 @@ import java.util.concurrent.Executors
|
|||||||
/**
|
/**
|
||||||
* Blank activity with a BiometricPrompt.
|
* Blank activity with a BiometricPrompt.
|
||||||
*/
|
*/
|
||||||
class BiometricUnlockActivity : BaseThemedActivity() {
|
class UnlockActivity : BaseThemedActivity() {
|
||||||
|
|
||||||
private val executor = Executors.newSingleThreadExecutor()
|
private val executor = Executors.newSingleThreadExecutor()
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ class BiometricUnlockActivity : BaseThemedActivity() {
|
|||||||
|
|
||||||
var promptInfo = BiometricPrompt.PromptInfo.Builder()
|
var promptInfo = BiometricPrompt.PromptInfo.Builder()
|
||||||
.setTitle(getString(R.string.unlock_app))
|
.setTitle(getString(R.string.unlock_app))
|
||||||
.setAllowedAuthenticators(BiometricUtil.getSupportedAuthenticators(this))
|
.setAllowedAuthenticators(AuthenticatorUtil.getSupportedAuthenticators(this))
|
||||||
.setConfirmationRequired(false)
|
.setConfirmationRequired(false)
|
||||||
|
|
||||||
if (!BiometricUtil.isDeviceCredentialAllowed(this)) {
|
if (!AuthenticatorUtil.isDeviceCredentialAllowed(this)) {
|
||||||
promptInfo = promptInfo.setNegativeButtonText(getString(R.string.action_cancel))
|
promptInfo = promptInfo.setNegativeButtonText(getString(R.string.action_cancel))
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.util.preference.preference
|
|||||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||||
import eu.kanade.tachiyomi.util.system.BiometricUtil
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
|
|
||||||
@ -21,9 +21,9 @@ class SettingsSecurityController : SettingsController() {
|
|||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||||
titleRes = R.string.pref_category_security
|
titleRes = R.string.pref_category_security
|
||||||
|
|
||||||
if (BiometricUtil.isSupported(context)) {
|
if (AuthenticatorUtil.isSupported(context)) {
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.useBiometricLock
|
key = Keys.useAuthenticator
|
||||||
titleRes = R.string.lock_with_biometrics
|
titleRes = R.string.lock_with_biometrics
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ class SettingsSecurityController : SettingsController() {
|
|||||||
defaultValue = "0"
|
defaultValue = "0"
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
preferences.useBiometricLock().asImmediateFlow { isVisible = it }
|
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,10 +62,10 @@ class SettingsSecurityController : SettingsController() {
|
|||||||
key = "pref_edit_lock_times"
|
key = "pref_edit_lock_times"
|
||||||
titleRes = R.string.action_edit_biometric_lock_times
|
titleRes = R.string.action_edit_biometric_lock_times
|
||||||
|
|
||||||
val timeRanges = preferences.biometricTimeRanges().get().count()
|
val timeRanges = preferences.authenticatorTimeRanges().get().count()
|
||||||
summary = context.resources.getQuantityString(R.plurals.num_lock_times, timeRanges, timeRanges)
|
summary = context.resources.getQuantityString(R.plurals.num_lock_times, timeRanges, timeRanges)
|
||||||
|
|
||||||
preferences.useBiometricLock().asImmediateFlow { isVisible = it }
|
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
onClick {
|
onClick {
|
||||||
|
@ -5,7 +5,7 @@ import android.os.Build
|
|||||||
import androidx.biometric.BiometricManager
|
import androidx.biometric.BiometricManager
|
||||||
import androidx.biometric.BiometricManager.Authenticators
|
import androidx.biometric.BiometricManager.Authenticators
|
||||||
|
|
||||||
object BiometricUtil {
|
object AuthenticatorUtil {
|
||||||
|
|
||||||
fun getSupportedAuthenticators(context: Context): Int {
|
fun getSupportedAuthenticators(context: Context): Int {
|
||||||
if (isLegacySecured(context)) {
|
if (isLegacySecured(context)) {
|
Loading…
x
Reference in New Issue
Block a user