From be01ba260f9b4e6ae0ef844aa7ec60ec4d160976 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Fri, 21 Aug 2020 15:39:59 +0300 Subject: [PATCH] setup Light theme instead of System default when importing a profile for devices with android less than 10 --- .../osmand/plus/settings/backend/OsmandSettings.java | 11 ++++++++++- .../fragments/GeneralProfileSettingsFragment.java | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 95d7748a88..bd46c48673 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -3909,7 +3909,16 @@ public class OsmandSettings { new IntPreference("FAVORITES_TAB", 0).makeGlobal().cache(); public final CommonPreference OSMAND_THEME = - new IntPreference("osmand_theme", OSMAND_LIGHT_THEME).makeProfile().cache(); + new IntPreference("osmand_theme", OSMAND_LIGHT_THEME) { + @Override + public void readFromJson(JSONObject json, ApplicationMode appMode) throws JSONException { + Integer theme = parseString(json.getString(getId())); + if (theme == SYSTEM_DEFAULT_THEME && !isSupportSystemDefaultTheme()) { + theme = OSMAND_LIGHT_THEME; + } + setModeValue(appMode, theme); + } + }.makeProfile().cache(); public final OsmandPreference OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED = new BooleanPreference("open_only_header_route_calculated", false).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java index cbd682cf9d..e870fed149 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java @@ -119,7 +119,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme private Drawable getOsmandThemeIcon() { int iconId; - if (settings.isSystemDefaultThemeUsed()) { + ApplicationMode mode = getSelectedAppMode(); + if (settings.isSystemDefaultThemeUsedForMode(mode)) { iconId = R.drawable.ic_action_android; } else { iconId = settings.isLightContent() ? R.drawable.ic_action_sun : R.drawable.ic_action_moon;