Skip to content

Commit

Permalink
Change preferences containing passwords to appStateKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamicen committed Feb 19, 2024
1 parent 2daccb5 commit 33cc57d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/exh/EXHMigrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,20 @@ object EXHMigrations {
}
}

if (oldVersion under 65) {
val appStatePrefsToReplace = listOf(
"__PRIVATE_sql_password",
"__PRIVATE_encrypt_database",
"__PRIVATE_cbz_password",
)

replacePreferences(
preferenceStore = preferenceStore,
filterPredicate = { it.key in appStatePrefsToReplace },
newKey = { Preference.appStateKey(it.replace("__PRIVATE_", "").trim()) },
)
}

// if (oldVersion under 1) { } (1 is current release version)
// do stuff here when releasing changed crap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class SecurityPreferences(

fun authenticatorDays() = this.preferenceStore.getInt("biometric_days", 0x7F)

fun encryptDatabase() = this.preferenceStore.getBoolean(Preference.privateKey("encrypt_database"), false)
fun encryptDatabase() = this.preferenceStore.getBoolean(Preference.appStateKey("encrypt_database"), false)

fun sqlPassword() = this.preferenceStore.getString(Preference.privateKey("sql_password"), "")
fun sqlPassword() = this.preferenceStore.getString(Preference.appStateKey("sql_password"), "")

fun passwordProtectDownloads() = preferenceStore.getBoolean(
Preference.privateKey("password_protect_downloads"),
Expand All @@ -35,7 +35,7 @@ class SecurityPreferences(

fun encryptionType() = this.preferenceStore.getEnum("encryption_type", EncryptionType.AES_256)

fun cbzPassword() = this.preferenceStore.getString(Preference.privateKey("cbz_password"), "")
fun cbzPassword() = this.preferenceStore.getString(Preference.appStateKey("cbz_password"), "")
// SY <--

/**
Expand Down

0 comments on commit 33cc57d

Please sign in to comment.