Use an explicit SCHEMA_VERSION instead of BuildConfig.VERSION_CODE (#3324)
* Use an explicit SCHEMA_VERSION instead of BuildConfig.VERSION_CODE Every nightly release has a new BuildConfig.VERSION_CODE, so the previous code would not do the right thing. Require the schema version to be explicitly set. While I'm here, provide a clear set of guidelines as to what has to happen when the schema changes. * Improve documentation links
This commit is contained in:
parent
4ab305f3dc
commit
fda8c80949
2 changed files with 36 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ import autodispose2.AutoDisposePlugins
|
|||
import com.keylesspalace.tusky.components.notifications.NotificationWorkerFactory
|
||||
import com.keylesspalace.tusky.di.AppInjector
|
||||
import com.keylesspalace.tusky.settings.PrefKeys
|
||||
import com.keylesspalace.tusky.settings.SCHEMA_VERSION
|
||||
import com.keylesspalace.tusky.util.APP_THEME_DEFAULT
|
||||
import com.keylesspalace.tusky.util.LocaleManager
|
||||
import com.keylesspalace.tusky.util.setAppNightMode
|
||||
|
|
@ -69,10 +70,10 @@ class TuskyApplication : Application(), HasAndroidInjector {
|
|||
AppInjector.init(this)
|
||||
|
||||
// Migrate shared preference keys and defaults from version to version. The last
|
||||
// version that did not have a SCHEMA_VERSION was 97, so that's the default.
|
||||
val oldVersion = sharedPreferences.getInt(PrefKeys.SCHEMA_VERSION, 97)
|
||||
if (oldVersion != BuildConfig.VERSION_CODE) {
|
||||
upgradeSharedPreferences(oldVersion, BuildConfig.VERSION_CODE)
|
||||
// version that did not have a SCHEMA_VERSION was 100, so that's the default.
|
||||
val oldVersion = sharedPreferences.getInt(PrefKeys.SCHEMA_VERSION, 100)
|
||||
if (oldVersion != SCHEMA_VERSION) {
|
||||
upgradeSharedPreferences(oldVersion, SCHEMA_VERSION)
|
||||
}
|
||||
|
||||
// In this case, we want to have the emoji preferences merged with the other ones
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue