This commit is contained in:
Chumva 2019-10-23 15:17:44 +03:00
parent 11196c1be3
commit fca207a3f3
2 changed files with 20 additions and 0 deletions

View file

@ -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;

View file

@ -231,6 +231,21 @@ public class OsmandSettings {
return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false);
}
public void migrateGlobalPrefsToProfile() {
SharedPreferences sharedPreferences = (SharedPreferences) globalPreferences;
Map<String, ?> 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));
}