Split security preferences from PrefrencesHelper (#8030)
(cherry picked from commit b668364afbfdde9e91fda6621c80c96262c6492a) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt # app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt # app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt
This commit is contained in:
parent
bffecf3833
commit
f40477cf6e
@ -19,6 +19,7 @@ import eu.kanade.data.listOfStringsAndAdapter
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.cache.PagePreviewCache
|
||||
@ -169,6 +170,9 @@ class PreferenceModule(val application: Application) : InjektModule {
|
||||
addSingletonFactory {
|
||||
SourcePreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
SecurityPreferences(get())
|
||||
}
|
||||
addSingletonFactory {
|
||||
PreferencesHelper(
|
||||
context = application,
|
||||
|
@ -5,6 +5,7 @@ import android.os.Build
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED
|
||||
@ -41,6 +42,7 @@ object Migrations {
|
||||
preferences: PreferencesHelper,
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
securityPreferences: SecurityPreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.lastVersionCode().get()
|
||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||
@ -257,7 +259,7 @@ object Migrations {
|
||||
if (oldVersion < 75) {
|
||||
val oldSecureScreen = prefs.getBoolean("secure_screen", false)
|
||||
if (oldSecureScreen) {
|
||||
preferences.secureScreen().set(PreferenceValues.SecureScreenMode.ALWAYS)
|
||||
securityPreferences.secureScreen().set(SecurityPreferences.SecureScreenMode.ALWAYS)
|
||||
}
|
||||
if (DeviceUtil.isMiui && preferences.extensionInstaller().get() == PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER) {
|
||||
preferences.extensionInstaller().set(PreferenceValues.ExtensionInstaller.LEGACY)
|
||||
|
@ -5,9 +5,9 @@ import android.graphics.BitmapFactory
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.notificationBuilder
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
class BackupNotifier(private val context: Context) {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val preferences: SecurityPreferences by injectLazy()
|
||||
|
||||
private val progressNotificationBuilder = context.notificationBuilder(Notifications.CHANNEL_BACKUP_RESTORE_PROGRESS) {
|
||||
setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher))
|
||||
|
@ -5,11 +5,11 @@ import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import androidx.core.app.NotificationCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationHandler
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.lang.chop
|
||||
import eu.kanade.tachiyomi.util.system.notificationBuilder
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
@ -23,7 +23,7 @@ import java.util.regex.Pattern
|
||||
*/
|
||||
internal class DownloadNotifier(private val context: Context) {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val preferences: SecurityPreferences by injectLazy()
|
||||
|
||||
private val progressNotificationBuilder by lazy {
|
||||
context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER_PROGRESS) {
|
||||
|
@ -16,11 +16,11 @@ import coil.transform.CircleCropTransformation
|
||||
import eu.kanade.domain.chapter.model.Chapter
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.download.Downloader
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationHandler
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.util.lang.chop
|
||||
@ -34,7 +34,7 @@ import java.text.DecimalFormatSymbols
|
||||
|
||||
class LibraryUpdateNotifier(private val context: Context) {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val preferences: SecurityPreferences by injectLazy()
|
||||
|
||||
/**
|
||||
* Pending intent of action that cancels the library update
|
||||
|
@ -39,8 +39,6 @@ object PreferenceKeys {
|
||||
|
||||
const val librarySortingMode = "library_sorting_mode"
|
||||
|
||||
const val hideNotificationContent = "hide_notification_content"
|
||||
|
||||
const val autoUpdateMetadata = "auto_update_metadata"
|
||||
|
||||
const val autoUpdateTrackers = "auto_update_trackers"
|
||||
|
@ -79,12 +79,6 @@ object PreferenceValues {
|
||||
SHIZUKU(R.string.ext_installer_shizuku),
|
||||
}
|
||||
|
||||
enum class SecureScreenMode(val titleResId: Int) {
|
||||
ALWAYS(R.string.lock_always),
|
||||
INCOGNITO(R.string.pref_incognito_mode),
|
||||
NEVER(R.string.lock_never),
|
||||
}
|
||||
|
||||
// SY -->
|
||||
enum class GroupLibraryMode {
|
||||
GLOBAL,
|
||||
|
@ -49,20 +49,6 @@ class PreferencesHelper(
|
||||
|
||||
fun sideNavIconAlignment() = this.preferenceStore.getInt("pref_side_nav_icon_alignment", 0)
|
||||
|
||||
fun useAuthenticator() = this.preferenceStore.getBoolean("use_biometric_lock", false)
|
||||
|
||||
fun lockAppAfter() = this.preferenceStore.getInt("lock_app_after", 0)
|
||||
|
||||
/**
|
||||
* For app lock. Will be set when there is a pending timed lock.
|
||||
* Otherwise this pref should be deleted.
|
||||
*/
|
||||
fun lastAppClosed() = this.preferenceStore.getLong("last_app_closed", 0)
|
||||
|
||||
fun secureScreen() = this.preferenceStore.getEnum("secure_screen_v2", Values.SecureScreenMode.INCOGNITO)
|
||||
|
||||
fun hideNotificationContent() = this.preferenceStore.getBoolean(Keys.hideNotificationContent, false)
|
||||
|
||||
fun autoUpdateMetadata() = this.preferenceStore.getBoolean(Keys.autoUpdateMetadata, false)
|
||||
|
||||
fun autoUpdateTrackers() = this.preferenceStore.getBoolean(Keys.autoUpdateTrackers, false)
|
||||
@ -439,10 +425,6 @@ class PreferencesHelper(
|
||||
|
||||
fun allowLocalSourceHiddenFolders() = this.preferenceStore.getBoolean("allow_local_source_hidden_folders", false)
|
||||
|
||||
fun authenticatorTimeRanges() = this.preferenceStore.getStringSet("biometric_time_ranges", mutableSetOf())
|
||||
|
||||
fun authenticatorDays() = this.preferenceStore.getInt("biometric_days", 0x7F)
|
||||
|
||||
fun sortTagsForLibrary() = this.preferenceStore.getStringSet("sort_tags_for_library", mutableSetOf())
|
||||
|
||||
fun extensionRepos() = this.preferenceStore.getStringSet("extension_repos", emptySet())
|
||||
|
@ -46,7 +46,7 @@ import coil.transform.RoundedCornersTransformation
|
||||
import eu.kanade.data.DatabaseHandler
|
||||
import eu.kanade.domain.manga.model.MangaCover
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
@ -61,7 +61,7 @@ import java.util.Date
|
||||
|
||||
class UpdatesGridGlanceWidget : GlanceAppWidget() {
|
||||
private val app: Application by injectLazy()
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val preferences: SecurityPreferences by injectLazy()
|
||||
|
||||
private val coroutineScope = MainScope()
|
||||
|
||||
|
@ -5,7 +5,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate.Companion.LOCK_ALL_DAYS
|
||||
import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate.Companion.LOCK_FRIDAY
|
||||
@ -47,7 +47,7 @@ interface SecureActivityDelegate {
|
||||
// SY <--
|
||||
|
||||
fun onApplicationCreated() {
|
||||
val lockDelay = Injekt.get<PreferencesHelper>().lockAppAfter().get()
|
||||
val lockDelay = Injekt.get<SecurityPreferences>().lockAppAfter().get()
|
||||
if (lockDelay == 0) {
|
||||
// Restore always active app lock
|
||||
// Delayed lock will be restored later on activity resume
|
||||
@ -56,7 +56,7 @@ interface SecureActivityDelegate {
|
||||
}
|
||||
|
||||
fun onApplicationStopped() {
|
||||
val preferences = Injekt.get<PreferencesHelper>()
|
||||
val preferences = Injekt.get<SecurityPreferences>()
|
||||
if (!preferences.useAuthenticator().get()) return
|
||||
if (lockState != LockState.ACTIVE) {
|
||||
preferences.lastAppClosed().set(Date().time)
|
||||
@ -72,7 +72,7 @@ interface SecureActivityDelegate {
|
||||
|
||||
fun unlock() {
|
||||
lockState = LockState.INACTIVE
|
||||
Injekt.get<PreferencesHelper>().lastAppClosed().delete()
|
||||
Injekt.get<SecurityPreferences>().lastAppClosed().delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -90,6 +90,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
private lateinit var activity: AppCompatActivity
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val securityPreferences: SecurityPreferences by injectLazy()
|
||||
|
||||
override fun registerSecureActivity(activity: AppCompatActivity) {
|
||||
this.activity = activity
|
||||
@ -105,31 +106,31 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
}
|
||||
|
||||
private fun setSecureScreen() {
|
||||
val secureScreenFlow = preferences.secureScreen().changes()
|
||||
val secureScreenFlow = securityPreferences.secureScreen().changes()
|
||||
val incognitoModeFlow = preferences.incognitoMode().changes()
|
||||
combine(secureScreenFlow, incognitoModeFlow) { secureScreen, incognitoMode ->
|
||||
secureScreen == PreferenceValues.SecureScreenMode.ALWAYS ||
|
||||
secureScreen == PreferenceValues.SecureScreenMode.INCOGNITO && incognitoMode
|
||||
secureScreen == SecurityPreferences.SecureScreenMode.ALWAYS ||
|
||||
secureScreen == SecurityPreferences.SecureScreenMode.INCOGNITO && incognitoMode
|
||||
}
|
||||
.onEach { activity.window.setSecureScreen(it) }
|
||||
.launchIn(activity.lifecycleScope)
|
||||
}
|
||||
|
||||
private fun setAppLock() {
|
||||
if (!preferences.useAuthenticator().get()) return
|
||||
if (!securityPreferences.useAuthenticator().get()) return
|
||||
if (activity.isAuthenticationSupported()) {
|
||||
updatePendingLockStatus()
|
||||
if (!isAppLocked()) return
|
||||
activity.startActivity(Intent(activity, UnlockActivity::class.java))
|
||||
activity.overridePendingTransition(0, 0)
|
||||
} else {
|
||||
preferences.useAuthenticator().set(false)
|
||||
securityPreferences.useAuthenticator().set(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePendingLockStatus() {
|
||||
val lastClosedPref = preferences.lastAppClosed()
|
||||
val lockDelay = 60000 * preferences.lockAppAfter().get()
|
||||
val lastClosedPref = securityPreferences.lastAppClosed()
|
||||
val lockDelay = 60000 * securityPreferences.lockAppAfter().get()
|
||||
if (lastClosedPref.isSet() && lockDelay > 0) {
|
||||
// Restore pending status in case app was killed
|
||||
lockState = LockState.PENDING
|
||||
@ -146,7 +147,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
private fun isAppLocked(): Boolean {
|
||||
// SY -->
|
||||
val today: Calendar = Calendar.getInstance()
|
||||
val timeRanges = preferences.authenticatorTimeRanges().get()
|
||||
val timeRanges = securityPreferences.authenticatorTimeRanges().get()
|
||||
.mapNotNull { TimeRange.fromPreferenceString(it) }
|
||||
if (timeRanges.isNotEmpty()) {
|
||||
val now = today.get(Calendar.HOUR_OF_DAY).hours + today.get(Calendar.MINUTE).minutes
|
||||
@ -156,7 +157,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
|
||||
}
|
||||
}
|
||||
|
||||
val lockedDays = preferences.authenticatorDays().get()
|
||||
val lockedDays = securityPreferences.authenticatorDays().get()
|
||||
val lockedToday = lockedDays == LOCK_ALL_DAYS || when (today.get(Calendar.DAY_OF_WEEK)) {
|
||||
Calendar.SUNDAY -> (lockedDays and LOCK_SUNDAY) == LOCK_SUNDAY
|
||||
Calendar.MONDAY -> (lockedDays and LOCK_MONDAY) == LOCK_MONDAY
|
||||
|
@ -4,7 +4,7 @@ import android.app.Application
|
||||
import android.os.Bundle
|
||||
import eu.kanade.presentation.category.BiometricTimesState
|
||||
import eu.kanade.presentation.category.BiometricTimesStateImpl
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
@ -19,10 +19,9 @@ import uy.kohesive.injekt.api.get
|
||||
*/
|
||||
class BiometricTimesPresenter(
|
||||
private val state: BiometricTimesStateImpl = BiometricTimesState() as BiometricTimesStateImpl,
|
||||
private val preferences: SecurityPreferences = Injekt.get(),
|
||||
) : BasePresenter<BiometricTimesController>(), BiometricTimesState by state {
|
||||
|
||||
val preferences: PreferencesHelper = Injekt.get()
|
||||
|
||||
private val _events: Channel<Event> = Channel(Int.MAX_VALUE)
|
||||
val events = _events.consumeAsFlow()
|
||||
|
||||
|
@ -143,6 +143,7 @@ class MainActivity : BaseActivity() {
|
||||
preferences = preferences,
|
||||
networkPreferences = Injekt.get(),
|
||||
sourcePreferences = sourcePreferences,
|
||||
securityPreferences = Injekt.get(),
|
||||
)
|
||||
} else {
|
||||
false
|
||||
|
@ -8,14 +8,12 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
||||
import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate
|
||||
import eu.kanade.tachiyomi.ui.category.biometric.BiometricTimesController
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.infoPreference
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@ -31,16 +29,17 @@ import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupport
|
||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.startAuthentication
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
|
||||
class SettingsSecurityController : SettingsController() {
|
||||
|
||||
private val securityPreferences: SecurityPreferences by injectLazy()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||
titleRes = R.string.pref_category_security
|
||||
|
||||
if (context.isAuthenticationSupported()) {
|
||||
switchPreference {
|
||||
bindTo(preferences.useAuthenticator())
|
||||
bindTo(securityPreferences.useAuthenticator())
|
||||
titleRes = R.string.lock_with_biometrics
|
||||
|
||||
requireAuthentication(
|
||||
@ -51,7 +50,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
}
|
||||
|
||||
intListPreference {
|
||||
bindTo(preferences.lockAppAfter())
|
||||
bindTo(securityPreferences.lockAppAfter())
|
||||
titleRes = R.string.lock_when_idle
|
||||
val values = arrayOf("0", "1", "2", "5", "10", "-1")
|
||||
entries = values.mapNotNull {
|
||||
@ -91,22 +90,21 @@ class SettingsSecurityController : SettingsController() {
|
||||
false
|
||||
}
|
||||
|
||||
visibleIf(preferences.useAuthenticator()) { it }
|
||||
visibleIf(securityPreferences.useAuthenticator()) { it }
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.hideNotificationContent
|
||||
bindTo(securityPreferences.hideNotificationContent())
|
||||
titleRes = R.string.hide_notification_content
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
listPreference {
|
||||
bindTo(preferences.secureScreen())
|
||||
bindTo(securityPreferences.secureScreen())
|
||||
titleRes = R.string.secure_screen
|
||||
summary = "%s"
|
||||
entriesRes = PreferenceValues.SecureScreenMode.values().map { it.titleResId }.toTypedArray()
|
||||
entryValues = PreferenceValues.SecureScreenMode.values().map { it.name }.toTypedArray()
|
||||
entriesRes = SecurityPreferences.SecureScreenMode.values().map { it.titleResId }.toTypedArray()
|
||||
entryValues = SecurityPreferences.SecureScreenMode.values().map { it.name }.toTypedArray()
|
||||
}
|
||||
|
||||
// SY -->
|
||||
@ -114,10 +112,10 @@ class SettingsSecurityController : SettingsController() {
|
||||
key = "pref_edit_lock_times"
|
||||
titleRes = R.string.action_edit_biometric_lock_times
|
||||
|
||||
val timeRanges = preferences.authenticatorTimeRanges().get().size
|
||||
val timeRanges = securityPreferences.authenticatorTimeRanges().get().size
|
||||
summary = context.resources.getQuantityString(R.plurals.num_lock_times, timeRanges, timeRanges)
|
||||
|
||||
visibleIf(preferences.useAuthenticator()) { it }
|
||||
visibleIf(securityPreferences.useAuthenticator()) { it }
|
||||
|
||||
onClick {
|
||||
router.pushController(BiometricTimesController())
|
||||
@ -128,7 +126,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
titleRes = R.string.biometric_lock_days
|
||||
summaryRes = R.string.biometric_lock_days_summary
|
||||
|
||||
visibleIf(preferences.useAuthenticator()) { it }
|
||||
visibleIf(securityPreferences.useAuthenticator()) { it }
|
||||
|
||||
onClick {
|
||||
SetLockedDaysDialog().showDialog(router)
|
||||
@ -141,7 +139,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
|
||||
// SY -->
|
||||
class SetLockedDaysDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
val preferences: PreferencesHelper by injectLazy()
|
||||
val securityPreferences: SecurityPreferences by injectLazy()
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
@ -157,7 +155,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
.map { activity.getString(it) }
|
||||
.toTypedArray()
|
||||
|
||||
val lockDays = preferences.authenticatorDays().get()
|
||||
val lockDays = securityPreferences.authenticatorDays().get()
|
||||
val selection = BooleanArray(7) {
|
||||
when (it) {
|
||||
0 -> (lockDays and SecureActivityDelegate.LOCK_SUNDAY) == SecureActivityDelegate.LOCK_SUNDAY
|
||||
@ -195,7 +193,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
preferences.authenticatorDays().set(flags)
|
||||
securityPreferences.authenticatorDays().set(flags)
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
|
@ -20,6 +20,7 @@ import eu.kanade.domain.source.interactor.InsertFeedSavedSearch
|
||||
import eu.kanade.domain.source.interactor.InsertSavedSearch
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
@ -95,6 +96,7 @@ object EXHMigrations {
|
||||
preferences: PreferencesHelper,
|
||||
networkPreferences: NetworkPreferences,
|
||||
sourcePreferences: SourcePreferences,
|
||||
securityPreferences: SecurityPreferences,
|
||||
): Boolean {
|
||||
val oldVersion = preferences.ehLastVersionCode().get()
|
||||
try {
|
||||
@ -354,7 +356,7 @@ object EXHMigrations {
|
||||
if (oldVersion under 27) {
|
||||
val oldSecureScreen = prefs.getBoolean("secure_screen", false)
|
||||
if (oldSecureScreen) {
|
||||
preferences.secureScreen().set(PreferenceValues.SecureScreenMode.ALWAYS)
|
||||
securityPreferences.secureScreen().set(SecurityPreferences.SecureScreenMode.ALWAYS)
|
||||
}
|
||||
if (DeviceUtil.isMiui && preferences.extensionInstaller().get() == PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER) {
|
||||
preferences.extensionInstaller().set(PreferenceValues.ExtensionInstaller.LEGACY)
|
||||
|
@ -11,6 +11,7 @@ import eu.kanade.domain.manga.interactor.GetSearchMetadata
|
||||
import eu.kanade.domain.manga.interactor.InsertFlatMetadata
|
||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
@ -34,6 +35,7 @@ object DebugFunctions {
|
||||
val prefs: PreferencesHelper by injectLazy()
|
||||
val networkPrefs: NetworkPreferences by injectLazy()
|
||||
val sourcePrefs: SourcePreferences by injectLazy()
|
||||
val securityPrefs: SecurityPreferences by injectLazy()
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
val updateManga: UpdateManga by injectLazy()
|
||||
val getFavorites: GetFavorites by injectLazy()
|
||||
@ -45,12 +47,12 @@ object DebugFunctions {
|
||||
|
||||
fun forceUpgradeMigration() {
|
||||
prefs.ehLastVersionCode().set(1)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs, securityPrefs)
|
||||
}
|
||||
|
||||
fun forceSetupJobs() {
|
||||
prefs.ehLastVersionCode().set(0)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs)
|
||||
EXHMigrations.upgrade(app, prefs, networkPrefs, sourcePrefs, securityPrefs)
|
||||
}
|
||||
|
||||
fun resetAgedFlagInEXHManga() {
|
||||
|
@ -0,0 +1,37 @@
|
||||
package eu.kanade.tachiyomi.core.security
|
||||
|
||||
import eu.kanade.tachiyomi.core.R
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||
|
||||
class SecurityPreferences(
|
||||
private val preferenceStore: PreferenceStore
|
||||
) {
|
||||
|
||||
fun useAuthenticator() = this.preferenceStore.getBoolean("use_biometric_lock", false)
|
||||
|
||||
fun lockAppAfter() = this.preferenceStore.getInt("lock_app_after", 0)
|
||||
|
||||
fun secureScreen() = this.preferenceStore.getEnum("secure_screen_v2", SecureScreenMode.INCOGNITO)
|
||||
|
||||
fun hideNotificationContent() = this.preferenceStore.getBoolean("hide_notification_content", false)
|
||||
|
||||
// SY -->
|
||||
fun authenticatorTimeRanges() = this.preferenceStore.getStringSet("biometric_time_ranges", mutableSetOf())
|
||||
|
||||
fun authenticatorDays() = this.preferenceStore.getInt("biometric_days", 0x7F)
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* For app lock. Will be set when there is a pending timed lock.
|
||||
* Otherwise this pref should be deleted.
|
||||
*/
|
||||
fun lastAppClosed() = this.preferenceStore.getLong("last_app_closed", 0)
|
||||
|
||||
enum class SecureScreenMode(val titleResId: Int) {
|
||||
ALWAYS(R.string.lock_always),
|
||||
INCOGNITO(R.string.pref_incognito_mode),
|
||||
NEVER(R.string.lock_never),
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user