Migrate general preferences
This commit is contained in:
parent
78adda625e
commit
661cea641c
2 changed files with 48 additions and 2 deletions
|
@ -95,6 +95,8 @@ public class AppInitializer implements IProgress {
|
|||
public static final int VERSION_3_2 = 32;
|
||||
// 35 - 3.5
|
||||
public static final int VERSION_3_5 = 35;
|
||||
// 36 - 3.6
|
||||
public static final int VERSION_3_6 = 36;
|
||||
|
||||
|
||||
public static final boolean TIPS_AND_TRICKS = false;
|
||||
|
@ -200,6 +202,10 @@ public class AppInitializer implements IProgress {
|
|||
app.getSettings().migrateHomeWorkParkingToFavorites();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
||||
}
|
||||
if (prevAppVersion < VERSION_3_6) {
|
||||
app.getSettings().migratePreferences();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_6).commit();
|
||||
}
|
||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
appVersionChanged = true;
|
||||
}
|
||||
|
|
|
@ -237,8 +237,7 @@ public class OsmandSettings {
|
|||
if (pref instanceof CommonPreference) {
|
||||
CommonPreference commonPreference = (CommonPreference) pref;
|
||||
if (!commonPreference.global) {
|
||||
List<ApplicationMode> modes = ApplicationMode.allPossibleValues();
|
||||
for (ApplicationMode mode : modes) {
|
||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||
if (!commonPreference.isSetForMode(mode)) {
|
||||
setPreference(key, globalPrefsMap.get(key), mode);
|
||||
}
|
||||
|
@ -257,6 +256,14 @@ public class OsmandSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (OsmandPreference pref : generalPrefs) {
|
||||
Object defaultVal = pref.getModeValue(ApplicationMode.DEFAULT);
|
||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||
if (!pref.isSetForMode(mode)) {
|
||||
pref.setModeValue(mode, defaultVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void migrateHomeWorkParkingToFavorites() {
|
||||
|
@ -3447,6 +3454,39 @@ public class OsmandSettings {
|
|||
}
|
||||
}
|
||||
|
||||
private OsmandPreference[] generalPrefs = new OsmandPreference[]{
|
||||
EXTERNAL_INPUT_DEVICE,
|
||||
CENTER_POSITION_ON_MAP,
|
||||
ROTATE_MAP,
|
||||
MAP_SCREEN_ORIENTATION,
|
||||
LIVE_MONITORING_URL,
|
||||
LIVE_MONITORING_MAX_INTERVAL_TO_SEND,
|
||||
LIVE_MONITORING_INTERVAL,
|
||||
LIVE_MONITORING,
|
||||
SHOW_TRIP_REC_NOTIFICATION,
|
||||
AUTO_SPLIT_RECORDING,
|
||||
SAVE_TRACK_MIN_SPEED,
|
||||
SAVE_TRACK_PRECISION,
|
||||
SAVE_TRACK_MIN_DISTANCE,
|
||||
SAVE_TRACK_INTERVAL,
|
||||
TRACK_STORAGE_DIRECTORY,
|
||||
SAVE_HEADING_TO_GPX,
|
||||
DISABLE_RECORDING_ONCE_APP_KILLED,
|
||||
SAVE_TRACK_TO_GPX,
|
||||
SAVE_GLOBAL_TRACK_REMEMBER,
|
||||
SAVE_GLOBAL_TRACK_INTERVAL,
|
||||
MAP_EMPTY_STATE_ALLOWED,
|
||||
DO_NOT_USE_ANIMATIONS,
|
||||
USE_KALMAN_FILTER_FOR_COMPASS,
|
||||
USE_MAGNETIC_FIELD_SENSOR_COMPASS,
|
||||
USE_TRACKBALL_FOR_MOVEMENTS,
|
||||
SPEED_SYSTEM,
|
||||
ANGULAR_UNITS,
|
||||
METRIC_SYSTEM,
|
||||
DRIVING_REGION,
|
||||
DRIVING_REGION_AUTOMATIC
|
||||
};
|
||||
|
||||
public class PreferencesDataStore extends PreferenceDataStore {
|
||||
|
||||
private ApplicationMode appMode;
|
||||
|
|
Loading…
Reference in a new issue