Skip to content

Commit

Permalink
[RFR-799] Fix settings always reset to default
Browse files Browse the repository at this point in the history
  • Loading branch information
hb0 committed Sep 19, 2023
1 parent 399fb84 commit d51bb7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
package de.cyface.utils.settings

import android.content.Context
import android.util.Log
import androidx.datastore.migrations.SharedPreferencesMigration
import androidx.datastore.migrations.SharedPreferencesView
import de.cyface.utils.Constants
import de.cyface.utils.Settings

/**
Expand Down Expand Up @@ -67,6 +69,7 @@ object PreferencesMigrationFactory {
preferences: SharedPreferencesView,
settings: Settings
): Settings {
Log.i(Constants.TAG, "Migrating from shared preferences to version 1")
return settings.toBuilder()
.setVersion(1) // Ensure the migrated values below are used instead of default values.
.setCenterMap(preferences.getBoolean(CENTER_MAP_KEY, DEFAULT_CENTER_MAP))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class StoreMigration : DataMigration<Settings> {
0 -> {
@Suppress("UsePropertyAccessSyntax")
builder
.setVersion(targetVersion)
.setCenterMap(DEFAULT_CENTER_MAP)
.setUploadEnabled(DEFAULT_SYNCHRONIZATION)
.setSensorFrequency(DEFAULT_SENSOR_FREQUENCY)
Expand Down

0 comments on commit d51bb7d

Please sign in to comment.