Specify preferences to exclude by resource id

pull/1122/head
Alex Baker 4 years ago
parent af5f8ee972
commit 63931c789e

@ -191,21 +191,23 @@ class TasksJsonImporter @Inject constructor(
}
googleTaskDao.updateParents()
caldavDao.updateParents()
backupContainer.intPrefs?.forEach { (key, value) ->
if (Preferences.P_CURRENT_VERSION == key) {
return@forEach
}
preferences.setInt(key, value)
}
backupContainer.longPrefs?.forEach { (key, value) ->
preferences.setLong(key, value)
}
backupContainer.stringPrefs?.forEach { (key, value) ->
preferences.setString(key, value)
}
backupContainer.boolPrefs?.forEach { (key, value) ->
preferences.setBoolean(key, value)
}
val ignoreKeys = ignorePrefs.map { context.getString(it) }
backupContainer
.intPrefs
?.filterNot { (key, _) -> ignoreKeys.contains(key) }
?.forEach { (key, value) -> preferences.setInt(key, value) }
backupContainer
.longPrefs
?.filterNot { (key, _) -> ignoreKeys.contains(key) }
?.forEach { (key, value) -> preferences.setLong(key, value) }
backupContainer
.stringPrefs
?.filterNot { (key, _) -> ignoreKeys.contains(key) }
?.forEach { (key, value) -> preferences.setString(key, value) }
backupContainer
.boolPrefs
?.filterNot { (key, _) -> ignoreKeys.contains(key) }
?.forEach { (key, value) -> preferences.setBoolean(key, value) }
if (version < Upgrader.V8_2) {
val themeIndex = preferences.getInt(R.string.p_theme_color, 7)
preferences.setInt(
@ -252,4 +254,10 @@ class TasksJsonImporter @Inject constructor(
var arrival = false
var departure = false
}
companion object {
private val ignorePrefs = intArrayOf(
R.string.p_current_version,
)
}
}

@ -308,10 +308,10 @@ class Preferences @JvmOverloads constructor(private val context: Context, name:
}
val lastSetVersion: Int
get() = getInt(P_CURRENT_VERSION, 0)
get() = getInt(R.string.p_current_version, 0)
fun setCurrentVersion(version: Int) {
setInt(P_CURRENT_VERSION, version)
setInt(R.string.p_current_version, version)
}
var sortMode: Int
@ -486,7 +486,6 @@ class Preferences @JvmOverloads constructor(private val context: Context, name:
}
companion object {
const val P_CURRENT_VERSION = "cv" // $NON-NLS-1$
private const val PREF_SORT_SORT = "sort_sort" // $NON-NLS-1$
private fun getSharedPreferencesName(context: Context): String {
return context.packageName + "_preferences"

@ -373,6 +373,7 @@
<string name="p_show_whats_new">show_whats_new</string>
<string name="p_just_updated">just_updated</string>
<string name="p_clicked_rate">clicked_rate</string>
<string name="p_current_version">cv</string>
<string name="event_whats_new">whats_new</string>
<string name="param_whats_new_display_rate">display_rate</string>

Loading…
Cancel
Save