Split security preferences from PrefrencesHelper (#8030)

This commit is contained in:
Andreas
2022-09-18 19:07:48 +02:00
committed by GitHub
parent 877ae041a4
commit b668364afb
13 changed files with 70 additions and 53 deletions

View File

@@ -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))

View File

@@ -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) {

View File

@@ -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.ui.main.MainActivity
import eu.kanade.tachiyomi.util.lang.chop
import eu.kanade.tachiyomi.util.lang.launchUI
@@ -33,7 +33,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

View File

@@ -37,8 +37,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"

View File

@@ -74,10 +74,4 @@ object PreferenceValues {
PACKAGEINSTALLER(R.string.ext_installer_packageinstaller),
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),
}
}

View File

@@ -46,20 +46,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)