From ff7ab9bc2d12fa3e81fb9f2b678a707809b1d454 Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 15 Nov 2019 10:06:28 +0200 Subject: [PATCH] Profile dependent preferences migration improvements --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 4 ++-- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 85a38a0b27..c3c7819ff2 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -174,7 +174,7 @@ public class AppInitializer implements IProgress { firstTime = true; startPrefs.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit(); startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); - startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit(); + startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit(); } else if (!Version.getFullVersion(app).equals(startPrefs.getString(VERSION_INSTALLED, ""))) { prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0); if(prevAppVersion < VERSION_2_2) { @@ -188,7 +188,7 @@ 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) { + } else if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")) { app.getSettings().migrateGlobalPrefsToProfile(); startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit(); } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index ca2bf8a2d1..eee737ddda 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -236,8 +236,14 @@ public class OsmandSettings { OsmandPreference pref = getPreference(key); if (pref instanceof CommonPreference) { CommonPreference commonPreference = (CommonPreference) pref; - if (!commonPreference.global && !commonPreference.isSetForMode(ApplicationMode.DEFAULT)) { - boolean valueSaved = setPreference(key, map.get(key), ApplicationMode.DEFAULT); + if (!commonPreference.global) { + List modes = commonPreference.general ? Collections.singletonList(ApplicationMode.DEFAULT) : ApplicationMode.allPossibleValues(); + boolean valueSaved = false; + for (ApplicationMode mode : modes) { + if (!commonPreference.isSetForMode(mode)) { + valueSaved = setPreference(key, map.get(key), mode) || valueSaved; + } + } if (valueSaved) { settingsAPI.edit(globalPreferences).remove(key).commit(); }