diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index c3c7819ff2..6edea04bcf 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -185,10 +185,12 @@ public class AppInitializer implements IProgress { } if(prevAppVersion < VERSION_2_3) { startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit(); - } else if (prevAppVersion < VERSION_3_2) { + } + 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 || Version.getAppVersion(app).equals("3.5.3")) { + } + 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 eee737ddda..14e662e604 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3218,9 +3218,12 @@ public class OsmandSettings { public boolean isLightContent() { - return OSMAND_THEME.get() != OSMAND_DARK_THEME; + return isLightContentForMode(APPLICATION_MODE.get()); } + public boolean isLightContentForMode(ApplicationMode mode) { + return OSMAND_THEME.getModeValue(mode) != OSMAND_DARK_THEME; + } public final CommonPreference FLUORESCENT_OVERLAYS = new BooleanPreference("fluorescent_overlays", false).makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java b/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java index 4ee788ea68..d3ec516cf7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java @@ -8,6 +8,7 @@ import java.util.TimeZone; import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.StateChangedListener; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.DayNightMode; @@ -58,8 +59,12 @@ public class DayNightHelper implements SensorEventListener { private StateChangedListener sensorStateListener; public boolean isNightModeForMapControls() { - if (osmandApplication.getSettings().isLightContent()) { - return isNightMode(); + return isNightModeForMapControlsForProfile(osmandApplication.getSettings().APPLICATION_MODE.get()); + } + + public boolean isNightModeForMapControlsForProfile(ApplicationMode mode) { + if (osmandApplication.getSettings().isLightContentForMode(mode)) { + return isNightModeForProfile(mode); } else { return true; } @@ -70,7 +75,11 @@ public class DayNightHelper implements SensorEventListener { * @return true if day is supposed to be */ public boolean isNightMode() { - DayNightMode dayNightMode = pref.get(); + return isNightModeForProfile(osmandApplication.getSettings().APPLICATION_MODE.get()); + } + + public boolean isNightModeForProfile(ApplicationMode mode) { + DayNightMode dayNightMode = pref.getModeValue(mode); if (dayNightMode.isDay()) { return false; } else if (dayNightMode.isNight()) { diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java index f4b8be1cbc..bfc42cc80e 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectAppModesBottomSheetDialogFragment.java @@ -8,6 +8,7 @@ import android.support.v4.app.FragmentManager; import net.osmand.PlatformUtil; import net.osmand.plus.ApplicationMode; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -36,8 +37,14 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null); appModeChangeable = savedInstanceState.getBoolean(APP_MODE_CHANGEABLE_KEY); } + OsmandApplication app = requiredMyApplication(); if (appMode == null) { - appMode = requiredMyApplication().getSettings().getApplicationMode(); + appMode = app.getSettings().getApplicationMode(); + } + if (usedOnMap) { + nightMode = app.getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode()); + } else { + nightMode = !app.getSettings().isLightContentForMode(getAppMode()); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index 982985bb54..5d89bc2a32 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -159,7 +159,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } private boolean updateTheme() { - boolean nightMode = !settings.isLightContent(); + boolean nightMode = !settings.isLightContentForMode(getSelectedAppMode()); boolean changed = this.nightMode != nightMode; this.nightMode = nightMode; this.themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; @@ -311,6 +311,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl if (updateTheme()) { recreate(); } else { + getPreferenceManager().setPreferenceDataStore(settings.getDataStore(appMode)); updateToolbar(); updateAllSettings(); } diff --git a/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java b/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java index 41844dbdf3..68d08ebb17 100644 --- a/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java @@ -53,7 +53,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { utmPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.UTM_FORMAT)); olcPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.OLC_FORMAT)); - int currentFormat = settings.COORDINATES_FORMAT.get(); + int currentFormat = settings.COORDINATES_FORMAT.getModeValue(getSelectedAppMode()); String currentPrefKey = getCoordinatesKeyForFormat(currentFormat); updateSelectedFormatPrefs(currentPrefKey); } diff --git a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java index b64fbd787a..f46b21c952 100644 --- a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java @@ -72,7 +72,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme String prefId = preference.getKey(); if (settings.EXTERNAL_INPUT_DEVICE.getId().equals(prefId)) { - boolean checked = settings.EXTERNAL_INPUT_DEVICE.get() != OsmandSettings.NO_EXTERNAL_DEVICE; + boolean checked = settings.EXTERNAL_INPUT_DEVICE.getModeValue(getSelectedAppMode()) != OsmandSettings.NO_EXTERNAL_DEVICE; SwitchCompat switchView = (SwitchCompat) holder.findViewById(R.id.switchWidget); switchView.setOnCheckedChangeListener(null); @@ -139,7 +139,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme } private Drawable getRotateMapIcon() { - switch (settings.ROTATE_MAP.get()) { + switch (settings.ROTATE_MAP.getModeValue(getSelectedAppMode())) { case OsmandSettings.ROTATE_MAP_NONE: return getContentIcon(R.drawable.ic_action_direction_north); case OsmandSettings.ROTATE_MAP_BEARING: @@ -156,7 +156,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme private Drawable getCenterPositionOnMapIcon() { - return getContentIcon(settings.CENTER_POSITION_ON_MAP.get() ? R.drawable.ic_action_display_position_center : R.drawable.ic_action_display_position_bottom); + return getContentIcon(settings.CENTER_POSITION_ON_MAP.getModeValue(getSelectedAppMode()) ? R.drawable.ic_action_display_position_center : R.drawable.ic_action_display_position_bottom); } private void setupMapScreenOrientationPref() { @@ -167,7 +167,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme } private Drawable getMapScreenOrientationIcon() { - switch (settings.MAP_SCREEN_ORIENTATION.get()) { + switch (settings.MAP_SCREEN_ORIENTATION.getModeValue(getSelectedAppMode())) { case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: return getContentIcon(R.drawable.ic_action_phone_portrait_orientation); case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: @@ -178,9 +178,10 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme } private void setupDrivingRegionPref() { + ApplicationMode selectedMode = getSelectedAppMode(); Preference defaultDrivingRegion = findPreference(settings.DRIVING_REGION.getId()); defaultDrivingRegion.setIcon(getContentIcon(R.drawable.ic_action_car_dark)); - defaultDrivingRegion.setSummary(getString(settings.DRIVING_REGION_AUTOMATIC.get() ? R.string.driving_region_automatic : settings.DRIVING_REGION.get().name)); + defaultDrivingRegion.setSummary(getString(settings.DRIVING_REGION_AUTOMATIC.getModeValue(selectedMode) ? R.string.driving_region_automatic : settings.DRIVING_REGION.getModeValue(selectedMode).name)); } private void setupUnitsOfLengthPref() { @@ -202,7 +203,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme private void setupCoordinatesFormatPref() { Preference coordinatesFormat = findPreference(settings.COORDINATES_FORMAT.getId()); coordinatesFormat.setIcon(getContentIcon(R.drawable.ic_action_coordinates_widget)); - coordinatesFormat.setSummary(PointDescription.formatToHumanString(app, settings.COORDINATES_FORMAT.get())); + coordinatesFormat.setSummary(PointDescription.formatToHumanString(app, settings.COORDINATES_FORMAT.getModeValue(getSelectedAppMode()))); } private void setupAngularUnitsPref() { @@ -304,8 +305,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme drs.add(null); drs.addAll(Arrays.asList(OsmandSettings.DrivingRegion.values())); int sel = -1; - OsmandSettings.DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.get(); - if (settings.DRIVING_REGION_AUTOMATIC.get()) { + ApplicationMode selectedMode = getSelectedAppMode(); + OsmandSettings.DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.getModeValue(selectedMode); + if (settings.DRIVING_REGION_AUTOMATIC.getModeValue(selectedMode)) { sel = 0; } for (int i = 1; i < drs.size(); i++) { @@ -344,15 +346,16 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme b.setAdapter(singleChoiceAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + ApplicationMode selectedMode = getSelectedAppMode(); if (drs.get(which) == null) { - settings.DRIVING_REGION_AUTOMATIC.set(true); + settings.DRIVING_REGION_AUTOMATIC.setModeValue(selectedMode, true); MapViewTrackingUtilities mapViewTrackingUtilities = getMyApplication().getMapViewTrackingUtilities(); if (mapViewTrackingUtilities != null) { mapViewTrackingUtilities.resetDrivingRegionUpdate(); } } else { - settings.DRIVING_REGION_AUTOMATIC.set(false); - settings.DRIVING_REGION.set(drs.get(which)); + settings.DRIVING_REGION_AUTOMATIC.setModeValue(selectedMode, false); + settings.DRIVING_REGION.setModeValue(selectedMode, drs.get(which)); } updateAllSettings(); } diff --git a/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java index 3bbb1bf6fe..313243a1c8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java @@ -2,6 +2,7 @@ package net.osmand.plus.settings; import android.support.v7.preference.Preference; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.AutoZoomMap; import net.osmand.plus.R; @@ -44,14 +45,14 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment { int selectedIndex = -1; entries[i] = getString(R.string.auto_zoom_none); entryValues[0] = 0; - if (!settings.AUTO_ZOOM_MAP.get()) { + if (!settings.AUTO_ZOOM_MAP.getModeValue(getSelectedAppMode())) { selectedIndex = 0; } i++; for (AutoZoomMap autoZoomMap : AutoZoomMap.values()) { entries[i] = getString(autoZoomMap.name); entryValues[i] = i; - if (selectedIndex == -1 && settings.AUTO_ZOOM_MAP_SCALE.get() == autoZoomMap) { + if (selectedIndex == -1 && settings.AUTO_ZOOM_MAP_SCALE.getModeValue(getSelectedAppMode()) == autoZoomMap) { selectedIndex = i; } i++; @@ -76,7 +77,7 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment { private void setupMapDirectionToCompassPref() { String[] entries; Float[] entryValues; - if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { entryValues = new Float[] {0f, 5f, 7f, 10f, 15f, 20f}; entries = new String[entryValues.length]; @@ -102,12 +103,13 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment { public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(settings.AUTO_ZOOM_MAP.getId())) { if (newValue instanceof Integer) { + ApplicationMode selectedMode = getSelectedAppMode(); int position = (int) newValue; if (position == 0) { - settings.AUTO_ZOOM_MAP.set(false); + settings.AUTO_ZOOM_MAP.setModeValue(selectedMode, false); } else { - settings.AUTO_ZOOM_MAP.set(true); - settings.AUTO_ZOOM_MAP_SCALE.set(OsmandSettings.AutoZoomMap.values()[position - 1]); + settings.AUTO_ZOOM_MAP.setModeValue(selectedMode, true); + settings.AUTO_ZOOM_MAP_SCALE.setModeValue(selectedMode, OsmandSettings.AutoZoomMap.values()[position - 1]); } return true; } diff --git a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java index edf9287d3d..b23081f31c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java @@ -346,6 +346,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP String[] prefsIds = new String[routingParameters.size()]; Set enabledPrefsIds = new HashSet<>(); + ApplicationMode selectedMode = getSelectedAppMode(); for (int i = 0; i < routingParameters.size(); i++) { RoutingParameter p = routingParameters.get(i); BooleanPreference booleanRoutingPref = (BooleanPreference) settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()); @@ -353,7 +354,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP entries[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName()); prefsIds[i] = booleanRoutingPref.getId(); - if (booleanRoutingPref.get()) { + if (booleanRoutingPref.getModeValue(selectedMode)) { enabledPrefsIds.add(booleanRoutingPref.getId()); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java b/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java index 1f123f5580..d402f059ca 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java @@ -14,6 +14,7 @@ import android.widget.ImageView; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.R; public class ScreenAlertsFragment extends BaseSettingsFragment { @@ -38,7 +39,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment { showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel)); setupScreenAlertsImage(); - enableDisablePreferences(settings.SHOW_ROUTING_ALARMS.get()); + enableDisablePreferences(settings.SHOW_ROUTING_ALARMS.getModeValue(getSelectedAppMode())); } @Override @@ -48,8 +49,9 @@ public class ScreenAlertsFragment extends BaseSettingsFragment { view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - boolean checked = !settings.SHOW_ROUTING_ALARMS.get(); - settings.SHOW_ROUTING_ALARMS.set(checked); + ApplicationMode selectedMode = getSelectedAppMode(); + boolean checked = !settings.SHOW_ROUTING_ALARMS.getModeValue(selectedMode); + settings.SHOW_ROUTING_ALARMS.setModeValue(selectedMode, checked); updateToolbarSwitch(); enableDisablePreferences(checked); } @@ -67,7 +69,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment { if (view == null) { return; } - boolean checked = settings.SHOW_ROUTING_ALARMS.get(); + boolean checked = settings.SHOW_ROUTING_ALARMS.getModeValue(getSelectedAppMode()); int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off); View switchContainer = view.findViewById(R.id.toolbar_switch_container); @@ -122,14 +124,15 @@ public class ScreenAlertsFragment extends BaseSettingsFragment { } private Drawable getWarningIcon() { - boolean americanSigns = settings.DRIVING_REGION.get().americanSigns; - if (settings.SHOW_TRAFFIC_WARNINGS.get()) { + ApplicationMode selectedMode = getSelectedAppMode(); + boolean americanSigns = settings.DRIVING_REGION.getModeValue(selectedMode).americanSigns; + if (settings.SHOW_TRAFFIC_WARNINGS.getModeValue(selectedMode)) { return getIcon(americanSigns ? R.drawable.warnings_traffic_calming_us : R.drawable.warnings_traffic_calming); - } else if (settings.SHOW_PEDESTRIAN.get()) { + } else if (settings.SHOW_PEDESTRIAN.getModeValue(selectedMode)) { return getIcon(americanSigns ? R.drawable.warnings_pedestrian_us : R.drawable.warnings_pedestrian); - } else if (settings.SHOW_CAMERAS.get()) { + } else if (settings.SHOW_CAMERAS.getModeValue(selectedMode)) { return getIcon(R.drawable.warnings_speed_camera); - } else if (settings.SHOW_TUNNELS.get()) { + } else if (settings.SHOW_TUNNELS.getModeValue(selectedMode)) { return getIcon(americanSigns ? R.drawable.warnings_tunnel_us : R.drawable.warnings_tunnel); } diff --git a/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java b/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java index fe4015e4cf..567f435d0d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java @@ -9,6 +9,7 @@ import android.view.View; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; @@ -24,7 +25,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment { setupTurnScreenOnTimePref(); setupTurnScreenOnSensorPref(); - enableDisablePreferences(settings.TURN_SCREEN_ON_ENABLED.get()); + enableDisablePreferences(settings.TURN_SCREEN_ON_ENABLED.getModeValue(getSelectedAppMode())); } @Override @@ -34,8 +35,9 @@ public class TurnScreenOnFragment extends BaseSettingsFragment { view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - boolean checked = !settings.TURN_SCREEN_ON_ENABLED.get(); - settings.TURN_SCREEN_ON_ENABLED.set(checked); + ApplicationMode selectedMode = getSelectedAppMode(); + boolean checked = !settings.TURN_SCREEN_ON_ENABLED.getModeValue(selectedMode); + settings.TURN_SCREEN_ON_ENABLED.setModeValue(selectedMode, checked); updateToolbarSwitch(); enableDisablePreferences(checked); } @@ -53,7 +55,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment { if (view == null) { return; } - boolean checked = settings.TURN_SCREEN_ON_ENABLED.get(); + boolean checked = settings.TURN_SCREEN_ON_ENABLED.getModeValue(getSelectedAppMode()); int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off); View switchContainer = view.findViewById(R.id.toolbar_switch_container); diff --git a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java index 48869a4aa1..0d6204e4fb 100644 --- a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java @@ -40,8 +40,9 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - boolean checked = !settings.SPEAK_ROUTING_ALARMS.get(); - settings.SPEAK_ROUTING_ALARMS.set(checked); + ApplicationMode selectedMode = getSelectedAppMode(); + boolean checked = !settings.SPEAK_ROUTING_ALARMS.getModeValue(selectedMode); + settings.SPEAK_ROUTING_ALARMS.setModeValue(selectedMode, checked); updateToolbarSwitch(); enableDisablePreferences(checked); } @@ -59,7 +60,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { if (view == null) { return; } - boolean checked = settings.SPEAK_ROUTING_ALARMS.get(); + boolean checked = settings.SPEAK_ROUTING_ALARMS.getModeValue(getSelectedAppMode()); int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off); View switchContainer = view.findViewById(R.id.toolbar_switch_container); @@ -87,14 +88,14 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { setupAudioStreamGuidancePref(); setupInterruptMusicPref(); } - enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.get()); + enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.getModeValue(getSelectedAppMode())); } private void setupSpeedLimitExceedPref() { Float[] speedLimitValues; String[] speedLimitNames; - if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { speedLimitValues = new Float[] {-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f}; speedLimitNames = new String[speedLimitValues.length]; @@ -206,7 +207,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { @Override public void onClick(DialogInterface dialog, int which) { - settings.SPEAK_SPEED_CAMERA.set(true); + settings.SPEAK_SPEED_CAMERA.setModeValue(getSelectedAppMode(), true); SwitchPreferenceCompat speakSpeedCamera = (SwitchPreferenceCompat) findPreference(settings.SPEAK_SPEED_CAMERA.getId()); if (speakSpeedCamera != null) { speakSpeedCamera.setChecked(true); @@ -220,6 +221,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String prefId = preference.getKey(); + ApplicationMode selectedMode = getSelectedAppMode(); if (prefId.equals(settings.VOICE_PROVIDER.getId())) { if (MORE_VALUE.equals(newValue)) { @@ -229,13 +231,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag()); startActivity(intent); } else if (newValue instanceof String) { - settings.VOICE_PROVIDER.set((String) newValue); - app.initVoiceCommandPlayer(getActivity(), getSelectedAppMode(), false, null, true, false, false); + settings.VOICE_PROVIDER.setModeValue(selectedMode, (String) newValue); + app.initVoiceCommandPlayer(getActivity(), selectedMode, false, null, true, false, false); } return true; } if (prefId.equals(settings.SPEAK_SPEED_CAMERA.getId())) { - if (!settings.SPEAK_SPEED_CAMERA.get()) { + if (!settings.SPEAK_SPEED_CAMERA.getModeValue(selectedMode)) { confirmSpeedCamerasDlg(); return false; } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java index b731c99465..cc2b370d18 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BasePreferenceBottomSheet.java @@ -35,6 +35,11 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra if (savedInstanceState != null) { appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null); } + if (usedOnMap) { + nightMode = requiredMyApplication().getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode()); + } else { + nightMode = !requiredMyApplication().getSettings().isLightContentForMode(getAppMode()); + } } @Override