diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index cfb6a127bb..c95fd8e3ef 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -93,6 +93,8 @@ public class AppInitializer implements IProgress { public static final int VERSION_2_3 = 23; // 32 - 3.2 public static final int VERSION_3_2 = 32; + // 35 - 3.5 + public static final int VERSION_3_5 = 35; public static final boolean TIPS_AND_TRICKS = false; @@ -187,6 +189,9 @@ public class AppInitializer implements IProgress { } else if (prevAppVersion < VERSION_3_2) { app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set(""); startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit(); + } else if (prevAppVersion < VERSION_3_5) { + app.getSettings().migrateGlobalPrefsToProfile(); + startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit(); } startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); appVersionChanged = true; diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index e453993b8a..901e02d8da 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -231,6 +231,21 @@ public class OsmandSettings { return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false); } + public void migrateGlobalPrefsToProfile() { + SharedPreferences sharedPreferences = (SharedPreferences) globalPreferences; + Map map = sharedPreferences.getAll(); + for (String key : map.keySet()) { + OsmandPreference pref = getPreference(key); + if (pref instanceof CommonPreference) { + CommonPreference commonPreference = (CommonPreference) pref; + if (!commonPreference.global && !commonPreference.isSetForMode(ApplicationMode.DEFAULT)) { + setPreference(key, map.get(key), ApplicationMode.DEFAULT); + settingsAPI.edit(globalPreferences).remove(key).commit(); + } + } + } + } + public Object getProfilePreferences(ApplicationMode mode) { return settingsAPI.getPreferenceObject(getSharedPreferencesName(mode)); }