Don't include "app state" preferences in backups
(cherry picked from commit ce7bf396ebc0b85d0e857c55b27cb5eab2ad9d5b) # Conflicts: # app/build.gradle.kts
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.core.security
|
||||
|
||||
import eu.kanade.tachiyomi.core.R
|
||||
import tachiyomi.core.preference.Preference
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.core.preference.getEnum
|
||||
|
||||
@@ -21,22 +22,25 @@ class SecurityPreferences(
|
||||
|
||||
fun authenticatorDays() = this.preferenceStore.getInt("biometric_days", 0x7F)
|
||||
|
||||
fun encryptDatabase() = this.preferenceStore.getBoolean("encrypt_database", false)
|
||||
fun encryptDatabase() = this.preferenceStore.getBoolean(Preference.privateKey("encrypt_database"), false)
|
||||
|
||||
fun sqlPassword() = this.preferenceStore.getString("sql_password", "")
|
||||
fun sqlPassword() = this.preferenceStore.getString(Preference.privateKey("sql_password"), "")
|
||||
|
||||
fun passwordProtectDownloads() = preferenceStore.getBoolean("password_protect_downloads", false)
|
||||
fun passwordProtectDownloads() = preferenceStore.getBoolean(Preference.privateKey("password_protect_downloads"), false)
|
||||
|
||||
fun encryptionType() = this.preferenceStore.getEnum("encryption_type", EncryptionType.AES_256)
|
||||
|
||||
fun cbzPassword() = this.preferenceStore.getString("cbz_password", "")
|
||||
fun cbzPassword() = this.preferenceStore.getString(Preference.privateKey("cbz_password"), "")
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* For app lock. Will be set when there is a pending timed lock.
|
||||
* Otherwise this pref should be deleted.
|
||||
*/
|
||||
fun lastAppClosed() = preferenceStore.getLong("last_app_closed", 0)
|
||||
fun lastAppClosed() = preferenceStore.getLong(
|
||||
Preference.appStateKey("last_app_closed"),
|
||||
0,
|
||||
)
|
||||
|
||||
enum class SecureScreenMode(val titleResId: Int) {
|
||||
ALWAYS(R.string.lock_always),
|
||||
|
||||
@@ -22,21 +22,29 @@ interface Preference<T> {
|
||||
|
||||
fun stateIn(scope: CoroutineScope): StateFlow<T>
|
||||
|
||||
val isPrivate: Boolean
|
||||
get() = key().startsWith(PRIVATE_PREFIX)
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* A preference that should not be exposed in places like backups.
|
||||
* A preference that should not be exposed in places like backups without user consent.
|
||||
*/
|
||||
fun isPrivate(key: String): Boolean {
|
||||
return key.startsWith(PRIVATE_PREFIX)
|
||||
}
|
||||
|
||||
fun privateKey(key: String): String {
|
||||
return "${PRIVATE_PREFIX}$key"
|
||||
}
|
||||
|
||||
/**
|
||||
* A preference used for internal app state that isn't really a user preference
|
||||
* and therefore should not be inplaces like backips.
|
||||
*/
|
||||
fun isAppState(key: String): Boolean {
|
||||
return key.startsWith(APP_STATE_PREFIX)
|
||||
}
|
||||
fun appStateKey(key: String): String {
|
||||
return "${APP_STATE_PREFIX}$key"
|
||||
}
|
||||
|
||||
private const val APP_STATE_PREFIX = "__APP_STATE_"
|
||||
private const val PRIVATE_PREFIX = "__PRIVATE_"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user