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:
arkon 2021-05-22 12:39:47 -04:00 committed by Jobobby04
parent 2b075b5a39
commit d8ee654a65
8 changed files with 35 additions and 35 deletions

View File

@ -84,7 +84,7 @@
android:resource="@xml/s_pen_actions"/>
</activity>
<activity
android:name=".ui.security.BiometricUnlockActivity"
android:name=".ui.security.UnlockActivity"
android:theme="@style/Theme.Base" />
<activity
android:name=".ui.webview.WebViewActivity"

View File

@ -15,10 +15,6 @@ object PreferenceKeys {
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 enableTransitionsWebtoon = "pref_enable_transitions_webtoon_key"
@ -164,7 +160,7 @@ object PreferenceKeys {
const val startScreen = "start_screen"
const val useBiometricLock = "use_biometric_lock"
const val useAuthenticator = "use_biometric_lock"
const val lockAppAfter = "lock_app_after"
@ -355,7 +351,7 @@ object PreferenceKeys {
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"
@ -374,4 +370,8 @@ object PreferenceKeys {
const val readerBottomButtons = "reader_bottom_buttons"
const val bottomBarLabels = "pref_show_bottom_bar_labels"
const val hideUpdatesButton = "pref_hide_updates_button"
const val hideHistoryButton = "pref_hide_history_button"
}

View File

@ -66,13 +66,7 @@ class PreferencesHelper(val context: Context) {
fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true)
fun hideUpdatesButton() = flowPrefs.getBoolean(Keys.hideUpdatesButton, false)
fun hideHistoryButton() = flowPrefs.getBoolean(Keys.hideHistoryButton, false)
fun bottomBarLabels() = flowPrefs.getBoolean(Keys.bottomBarLabels, true)
fun useBiometricLock() = flowPrefs.getBoolean(Keys.useBiometricLock, false)
fun useAuthenticator() = flowPrefs.getBoolean(Keys.useAuthenticator, false)
fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0)
@ -472,7 +466,7 @@ class PreferencesHelper(val context: Context) {
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())
@ -489,4 +483,10 @@ class PreferencesHelper(val context: Context) {
fun leftVerticalSeekbar() = flowPrefs.getBoolean(Keys.leftVerticalSeekbar, false)
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)
}

View File

@ -34,7 +34,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
override fun onCreate(savedState: Bundle?) {
super.onCreate(savedState)
preferences.biometricTimeRanges().asFlow().onEach { prefTimeRanges ->
preferences.authenticatorTimeRanges().asFlow().onEach { prefTimeRanges ->
timeRanges = prefTimeRanges.toList()
.mapNotNull { TimeRange.fromPreferenceString(it) }.onEach { xLogD(it) }
@ -59,7 +59,7 @@ class BiometricTimesPresenter : BasePresenter<BiometricTimesController>() {
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.
*/
fun deleteTimeRanges(timeRanges: List<TimeRange>) {
preferences.biometricTimeRanges().set(
preferences.authenticatorTimeRanges().set(
this.timeRanges.filterNot { it in timeRanges }.map { it.toPreferenceString() }.toSet()
)
}

View File

@ -6,7 +6,7 @@ import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
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.onEach
import uy.kohesive.injekt.injectLazy
@ -36,14 +36,14 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
}
fun onResume() {
if (preferences.useBiometricLock().get()) {
if (BiometricUtil.isSupported(activity)) {
if (preferences.useAuthenticator().get()) {
if (AuthenticatorUtil.isSupported(activity)) {
if (isAppLocked()) {
activity.startActivity(Intent(activity, BiometricUnlockActivity::class.java))
activity.startActivity(Intent(activity, UnlockActivity::class.java))
activity.overridePendingTransition(0, 0)
}
} else {
preferences.useBiometricLock().set(false)
preferences.useAuthenticator().set(false)
}
}
}
@ -56,7 +56,7 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
return preferences.lockAppAfter().get() <= 0 ||
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()) {
val today: Calendar = Calendar.getInstance()
val now = today.get(Calendar.HOUR_OF_DAY).hours + today.get(Calendar.MINUTE).minutes

View File

@ -4,7 +4,7 @@ import android.os.Bundle
import androidx.biometric.BiometricPrompt
import eu.kanade.tachiyomi.R
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 java.util.Date
import java.util.concurrent.Executors
@ -12,7 +12,7 @@ import java.util.concurrent.Executors
/**
* Blank activity with a BiometricPrompt.
*/
class BiometricUnlockActivity : BaseThemedActivity() {
class UnlockActivity : BaseThemedActivity() {
private val executor = Executors.newSingleThreadExecutor()
@ -40,10 +40,10 @@ class BiometricUnlockActivity : BaseThemedActivity() {
var promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle(getString(R.string.unlock_app))
.setAllowedAuthenticators(BiometricUtil.getSupportedAuthenticators(this))
.setAllowedAuthenticators(AuthenticatorUtil.getSupportedAuthenticators(this))
.setConfirmationRequired(false)
if (!BiometricUtil.isDeviceCredentialAllowed(this)) {
if (!AuthenticatorUtil.isDeviceCredentialAllowed(this)) {
promptInfo = promptInfo.setNegativeButtonText(getString(R.string.action_cancel))
}

View File

@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.util.preference.preference
import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference
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 eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
@ -21,9 +21,9 @@ class SettingsSecurityController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
titleRes = R.string.pref_category_security
if (BiometricUtil.isSupported(context)) {
if (AuthenticatorUtil.isSupported(context)) {
switchPreference {
key = Keys.useBiometricLock
key = Keys.useAuthenticator
titleRes = R.string.lock_with_biometrics
defaultValue = false
}
@ -42,7 +42,7 @@ class SettingsSecurityController : SettingsController() {
defaultValue = "0"
summary = "%s"
preferences.useBiometricLock().asImmediateFlow { isVisible = it }
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
.launchIn(viewScope)
}
}
@ -62,10 +62,10 @@ class SettingsSecurityController : SettingsController() {
key = "pref_edit_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)
preferences.useBiometricLock().asImmediateFlow { isVisible = it }
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
.launchIn(viewScope)
onClick {

View File

@ -5,7 +5,7 @@ import android.os.Build
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricManager.Authenticators
object BiometricUtil {
object AuthenticatorUtil {
fun getSupportedAuthenticators(context: Context): Int {
if (isLegacySecured(context)) {