Fix prefs data storage for selected app mode and theme change
This commit is contained in:
parent
0ee6bd6cdc
commit
c0b9a9e701
13 changed files with 89 additions and 49 deletions
|
@ -185,10 +185,12 @@ public class AppInitializer implements IProgress {
|
||||||
}
|
}
|
||||||
if(prevAppVersion < VERSION_2_3) {
|
if(prevAppVersion < VERSION_2_3) {
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit();
|
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("");
|
app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set("");
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
|
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();
|
app.getSettings().migrateGlobalPrefsToProfile();
|
||||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3218,9 +3218,12 @@ public class OsmandSettings {
|
||||||
|
|
||||||
|
|
||||||
public boolean isLightContent() {
|
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<Boolean> FLUORESCENT_OVERLAYS =
|
public final CommonPreference<Boolean> FLUORESCENT_OVERLAYS =
|
||||||
new BooleanPreference("fluorescent_overlays", false).makeGlobal().cache();
|
new BooleanPreference("fluorescent_overlays", false).makeGlobal().cache();
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.TimeZone;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
import net.osmand.plus.OsmandSettings.DayNightMode;
|
import net.osmand.plus.OsmandSettings.DayNightMode;
|
||||||
|
@ -58,8 +59,12 @@ public class DayNightHelper implements SensorEventListener {
|
||||||
private StateChangedListener<Boolean> sensorStateListener;
|
private StateChangedListener<Boolean> sensorStateListener;
|
||||||
|
|
||||||
public boolean isNightModeForMapControls() {
|
public boolean isNightModeForMapControls() {
|
||||||
if (osmandApplication.getSettings().isLightContent()) {
|
return isNightModeForMapControlsForProfile(osmandApplication.getSettings().APPLICATION_MODE.get());
|
||||||
return isNightMode();
|
}
|
||||||
|
|
||||||
|
public boolean isNightModeForMapControlsForProfile(ApplicationMode mode) {
|
||||||
|
if (osmandApplication.getSettings().isLightContentForMode(mode)) {
|
||||||
|
return isNightModeForProfile(mode);
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +75,11 @@ public class DayNightHelper implements SensorEventListener {
|
||||||
* @return true if day is supposed to be
|
* @return true if day is supposed to be
|
||||||
*/
|
*/
|
||||||
public boolean isNightMode() {
|
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()) {
|
if (dayNightMode.isDay()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (dayNightMode.isNight()) {
|
} else if (dayNightMode.isNight()) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.support.v4.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
@ -36,8 +37,14 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
|
||||||
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
||||||
appModeChangeable = savedInstanceState.getBoolean(APP_MODE_CHANGEABLE_KEY);
|
appModeChangeable = savedInstanceState.getBoolean(APP_MODE_CHANGEABLE_KEY);
|
||||||
}
|
}
|
||||||
|
OsmandApplication app = requiredMyApplication();
|
||||||
if (appMode == null) {
|
if (appMode == null) {
|
||||||
appMode = requiredMyApplication().getSettings().getApplicationMode();
|
appMode = app.getSettings().getApplicationMode();
|
||||||
|
}
|
||||||
|
if (usedOnMap) {
|
||||||
|
nightMode = app.getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode());
|
||||||
|
} else {
|
||||||
|
nightMode = !app.getSettings().isLightContentForMode(getAppMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateTheme() {
|
private boolean updateTheme() {
|
||||||
boolean nightMode = !settings.isLightContent();
|
boolean nightMode = !settings.isLightContentForMode(getSelectedAppMode());
|
||||||
boolean changed = this.nightMode != nightMode;
|
boolean changed = this.nightMode != nightMode;
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
this.themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
this.themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
@ -311,6 +311,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
||||||
if (updateTheme()) {
|
if (updateTheme()) {
|
||||||
recreate();
|
recreate();
|
||||||
} else {
|
} else {
|
||||||
|
getPreferenceManager().setPreferenceDataStore(settings.getDataStore(appMode));
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
|
||||||
utmPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.UTM_FORMAT));
|
utmPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.UTM_FORMAT));
|
||||||
olcPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.OLC_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);
|
String currentPrefKey = getCoordinatesKeyForFormat(currentFormat);
|
||||||
updateSelectedFormatPrefs(currentPrefKey);
|
updateSelectedFormatPrefs(currentPrefKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
|
|
||||||
String prefId = preference.getKey();
|
String prefId = preference.getKey();
|
||||||
if (settings.EXTERNAL_INPUT_DEVICE.getId().equals(prefId)) {
|
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);
|
SwitchCompat switchView = (SwitchCompat) holder.findViewById(R.id.switchWidget);
|
||||||
switchView.setOnCheckedChangeListener(null);
|
switchView.setOnCheckedChangeListener(null);
|
||||||
|
@ -139,7 +139,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getRotateMapIcon() {
|
private Drawable getRotateMapIcon() {
|
||||||
switch (settings.ROTATE_MAP.get()) {
|
switch (settings.ROTATE_MAP.getModeValue(getSelectedAppMode())) {
|
||||||
case OsmandSettings.ROTATE_MAP_NONE:
|
case OsmandSettings.ROTATE_MAP_NONE:
|
||||||
return getContentIcon(R.drawable.ic_action_direction_north);
|
return getContentIcon(R.drawable.ic_action_direction_north);
|
||||||
case OsmandSettings.ROTATE_MAP_BEARING:
|
case OsmandSettings.ROTATE_MAP_BEARING:
|
||||||
|
@ -156,7 +156,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
|
|
||||||
|
|
||||||
private Drawable getCenterPositionOnMapIcon() {
|
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() {
|
private void setupMapScreenOrientationPref() {
|
||||||
|
@ -167,7 +167,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getMapScreenOrientationIcon() {
|
private Drawable getMapScreenOrientationIcon() {
|
||||||
switch (settings.MAP_SCREEN_ORIENTATION.get()) {
|
switch (settings.MAP_SCREEN_ORIENTATION.getModeValue(getSelectedAppMode())) {
|
||||||
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
|
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
|
||||||
return getContentIcon(R.drawable.ic_action_phone_portrait_orientation);
|
return getContentIcon(R.drawable.ic_action_phone_portrait_orientation);
|
||||||
case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
|
case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
|
||||||
|
@ -178,9 +178,10 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupDrivingRegionPref() {
|
private void setupDrivingRegionPref() {
|
||||||
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
Preference defaultDrivingRegion = findPreference(settings.DRIVING_REGION.getId());
|
Preference defaultDrivingRegion = findPreference(settings.DRIVING_REGION.getId());
|
||||||
defaultDrivingRegion.setIcon(getContentIcon(R.drawable.ic_action_car_dark));
|
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() {
|
private void setupUnitsOfLengthPref() {
|
||||||
|
@ -202,7 +203,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
private void setupCoordinatesFormatPref() {
|
private void setupCoordinatesFormatPref() {
|
||||||
Preference coordinatesFormat = findPreference(settings.COORDINATES_FORMAT.getId());
|
Preference coordinatesFormat = findPreference(settings.COORDINATES_FORMAT.getId());
|
||||||
coordinatesFormat.setIcon(getContentIcon(R.drawable.ic_action_coordinates_widget));
|
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() {
|
private void setupAngularUnitsPref() {
|
||||||
|
@ -304,8 +305,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
drs.add(null);
|
drs.add(null);
|
||||||
drs.addAll(Arrays.asList(OsmandSettings.DrivingRegion.values()));
|
drs.addAll(Arrays.asList(OsmandSettings.DrivingRegion.values()));
|
||||||
int sel = -1;
|
int sel = -1;
|
||||||
OsmandSettings.DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.get();
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
if (settings.DRIVING_REGION_AUTOMATIC.get()) {
|
OsmandSettings.DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.getModeValue(selectedMode);
|
||||||
|
if (settings.DRIVING_REGION_AUTOMATIC.getModeValue(selectedMode)) {
|
||||||
sel = 0;
|
sel = 0;
|
||||||
}
|
}
|
||||||
for (int i = 1; i < drs.size(); i++) {
|
for (int i = 1; i < drs.size(); i++) {
|
||||||
|
@ -344,15 +346,16 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
||||||
b.setAdapter(singleChoiceAdapter, new DialogInterface.OnClickListener() {
|
b.setAdapter(singleChoiceAdapter, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
if (drs.get(which) == null) {
|
if (drs.get(which) == null) {
|
||||||
settings.DRIVING_REGION_AUTOMATIC.set(true);
|
settings.DRIVING_REGION_AUTOMATIC.setModeValue(selectedMode, true);
|
||||||
MapViewTrackingUtilities mapViewTrackingUtilities = getMyApplication().getMapViewTrackingUtilities();
|
MapViewTrackingUtilities mapViewTrackingUtilities = getMyApplication().getMapViewTrackingUtilities();
|
||||||
if (mapViewTrackingUtilities != null) {
|
if (mapViewTrackingUtilities != null) {
|
||||||
mapViewTrackingUtilities.resetDrivingRegionUpdate();
|
mapViewTrackingUtilities.resetDrivingRegionUpdate();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings.DRIVING_REGION_AUTOMATIC.set(false);
|
settings.DRIVING_REGION_AUTOMATIC.setModeValue(selectedMode, false);
|
||||||
settings.DRIVING_REGION.set(drs.get(which));
|
settings.DRIVING_REGION.setModeValue(selectedMode, drs.get(which));
|
||||||
}
|
}
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.settings;
|
||||||
|
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -44,14 +45,14 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
|
||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
entries[i] = getString(R.string.auto_zoom_none);
|
entries[i] = getString(R.string.auto_zoom_none);
|
||||||
entryValues[0] = 0;
|
entryValues[0] = 0;
|
||||||
if (!settings.AUTO_ZOOM_MAP.get()) {
|
if (!settings.AUTO_ZOOM_MAP.getModeValue(getSelectedAppMode())) {
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
for (AutoZoomMap autoZoomMap : AutoZoomMap.values()) {
|
for (AutoZoomMap autoZoomMap : AutoZoomMap.values()) {
|
||||||
entries[i] = getString(autoZoomMap.name);
|
entries[i] = getString(autoZoomMap.name);
|
||||||
entryValues[i] = i;
|
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;
|
selectedIndex = i;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -76,7 +77,7 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
|
||||||
private void setupMapDirectionToCompassPref() {
|
private void setupMapDirectionToCompassPref() {
|
||||||
String[] entries;
|
String[] entries;
|
||||||
Float[] entryValues;
|
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};
|
entryValues = new Float[] {0f, 5f, 7f, 10f, 15f, 20f};
|
||||||
entries = new String[entryValues.length];
|
entries = new String[entryValues.length];
|
||||||
|
|
||||||
|
@ -102,12 +103,13 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
if (preference.getKey().equals(settings.AUTO_ZOOM_MAP.getId())) {
|
if (preference.getKey().equals(settings.AUTO_ZOOM_MAP.getId())) {
|
||||||
if (newValue instanceof Integer) {
|
if (newValue instanceof Integer) {
|
||||||
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
int position = (int) newValue;
|
int position = (int) newValue;
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
settings.AUTO_ZOOM_MAP.set(false);
|
settings.AUTO_ZOOM_MAP.setModeValue(selectedMode, false);
|
||||||
} else {
|
} else {
|
||||||
settings.AUTO_ZOOM_MAP.set(true);
|
settings.AUTO_ZOOM_MAP.setModeValue(selectedMode, true);
|
||||||
settings.AUTO_ZOOM_MAP_SCALE.set(OsmandSettings.AutoZoomMap.values()[position - 1]);
|
settings.AUTO_ZOOM_MAP_SCALE.setModeValue(selectedMode, OsmandSettings.AutoZoomMap.values()[position - 1]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,6 +346,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
||||||
String[] prefsIds = new String[routingParameters.size()];
|
String[] prefsIds = new String[routingParameters.size()];
|
||||||
Set<String> enabledPrefsIds = new HashSet<>();
|
Set<String> enabledPrefsIds = new HashSet<>();
|
||||||
|
|
||||||
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
for (int i = 0; i < routingParameters.size(); i++) {
|
for (int i = 0; i < routingParameters.size(); i++) {
|
||||||
RoutingParameter p = routingParameters.get(i);
|
RoutingParameter p = routingParameters.get(i);
|
||||||
BooleanPreference booleanRoutingPref = (BooleanPreference) settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
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());
|
entries[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||||
prefsIds[i] = booleanRoutingPref.getId();
|
prefsIds[i] = booleanRoutingPref.getId();
|
||||||
|
|
||||||
if (booleanRoutingPref.get()) {
|
if (booleanRoutingPref.getModeValue(selectedMode)) {
|
||||||
enabledPrefsIds.add(booleanRoutingPref.getId());
|
enabledPrefsIds.add(booleanRoutingPref.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
public class ScreenAlertsFragment extends BaseSettingsFragment {
|
public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
|
@ -38,7 +39,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
|
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
|
||||||
|
|
||||||
setupScreenAlertsImage();
|
setupScreenAlertsImage();
|
||||||
enableDisablePreferences(settings.SHOW_ROUTING_ALARMS.get());
|
enableDisablePreferences(settings.SHOW_ROUTING_ALARMS.getModeValue(getSelectedAppMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,8 +49,9 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
boolean checked = !settings.SHOW_ROUTING_ALARMS.get();
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
settings.SHOW_ROUTING_ALARMS.set(checked);
|
boolean checked = !settings.SHOW_ROUTING_ALARMS.getModeValue(selectedMode);
|
||||||
|
settings.SHOW_ROUTING_ALARMS.setModeValue(selectedMode, checked);
|
||||||
updateToolbarSwitch();
|
updateToolbarSwitch();
|
||||||
enableDisablePreferences(checked);
|
enableDisablePreferences(checked);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +69,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
return;
|
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);
|
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
|
||||||
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
||||||
|
@ -122,14 +124,15 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getWarningIcon() {
|
private Drawable getWarningIcon() {
|
||||||
boolean americanSigns = settings.DRIVING_REGION.get().americanSigns;
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
if (settings.SHOW_TRAFFIC_WARNINGS.get()) {
|
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);
|
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);
|
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);
|
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);
|
return getIcon(americanSigns ? R.drawable.warnings_tunnel_us : R.drawable.warnings_tunnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||||
|
@ -24,7 +25,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
setupTurnScreenOnTimePref();
|
setupTurnScreenOnTimePref();
|
||||||
setupTurnScreenOnSensorPref();
|
setupTurnScreenOnSensorPref();
|
||||||
enableDisablePreferences(settings.TURN_SCREEN_ON_ENABLED.get());
|
enableDisablePreferences(settings.TURN_SCREEN_ON_ENABLED.getModeValue(getSelectedAppMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,8 +35,9 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
||||||
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
boolean checked = !settings.TURN_SCREEN_ON_ENABLED.get();
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
settings.TURN_SCREEN_ON_ENABLED.set(checked);
|
boolean checked = !settings.TURN_SCREEN_ON_ENABLED.getModeValue(selectedMode);
|
||||||
|
settings.TURN_SCREEN_ON_ENABLED.setModeValue(selectedMode, checked);
|
||||||
updateToolbarSwitch();
|
updateToolbarSwitch();
|
||||||
enableDisablePreferences(checked);
|
enableDisablePreferences(checked);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +55,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
return;
|
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);
|
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
|
||||||
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
||||||
|
|
|
@ -40,8 +40,9 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
boolean checked = !settings.SPEAK_ROUTING_ALARMS.get();
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
settings.SPEAK_ROUTING_ALARMS.set(checked);
|
boolean checked = !settings.SPEAK_ROUTING_ALARMS.getModeValue(selectedMode);
|
||||||
|
settings.SPEAK_ROUTING_ALARMS.setModeValue(selectedMode, checked);
|
||||||
updateToolbarSwitch();
|
updateToolbarSwitch();
|
||||||
enableDisablePreferences(checked);
|
enableDisablePreferences(checked);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +60,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
return;
|
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);
|
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
|
||||||
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
||||||
|
@ -87,14 +88,14 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
setupAudioStreamGuidancePref();
|
setupAudioStreamGuidancePref();
|
||||||
setupInterruptMusicPref();
|
setupInterruptMusicPref();
|
||||||
}
|
}
|
||||||
enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.get());
|
enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.getModeValue(getSelectedAppMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupSpeedLimitExceedPref() {
|
private void setupSpeedLimitExceedPref() {
|
||||||
Float[] speedLimitValues;
|
Float[] speedLimitValues;
|
||||||
String[] speedLimitNames;
|
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};
|
speedLimitValues = new Float[] {-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||||
speedLimitNames = new String[speedLimitValues.length];
|
speedLimitNames = new String[speedLimitValues.length];
|
||||||
|
|
||||||
|
@ -206,7 +207,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
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());
|
SwitchPreferenceCompat speakSpeedCamera = (SwitchPreferenceCompat) findPreference(settings.SPEAK_SPEED_CAMERA.getId());
|
||||||
if (speakSpeedCamera != null) {
|
if (speakSpeedCamera != null) {
|
||||||
speakSpeedCamera.setChecked(true);
|
speakSpeedCamera.setChecked(true);
|
||||||
|
@ -220,6 +221,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
String prefId = preference.getKey();
|
String prefId = preference.getKey();
|
||||||
|
ApplicationMode selectedMode = getSelectedAppMode();
|
||||||
|
|
||||||
if (prefId.equals(settings.VOICE_PROVIDER.getId())) {
|
if (prefId.equals(settings.VOICE_PROVIDER.getId())) {
|
||||||
if (MORE_VALUE.equals(newValue)) {
|
if (MORE_VALUE.equals(newValue)) {
|
||||||
|
@ -229,13 +231,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (newValue instanceof String) {
|
} else if (newValue instanceof String) {
|
||||||
settings.VOICE_PROVIDER.set((String) newValue);
|
settings.VOICE_PROVIDER.setModeValue(selectedMode, (String) newValue);
|
||||||
app.initVoiceCommandPlayer(getActivity(), getSelectedAppMode(), false, null, true, false, false);
|
app.initVoiceCommandPlayer(getActivity(), selectedMode, false, null, true, false, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (prefId.equals(settings.SPEAK_SPEED_CAMERA.getId())) {
|
if (prefId.equals(settings.SPEAK_SPEED_CAMERA.getId())) {
|
||||||
if (!settings.SPEAK_SPEED_CAMERA.get()) {
|
if (!settings.SPEAK_SPEED_CAMERA.getModeValue(selectedMode)) {
|
||||||
confirmSpeedCamerasDlg();
|
confirmSpeedCamerasDlg();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -35,6 +35,11 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
|
||||||
}
|
}
|
||||||
|
if (usedOnMap) {
|
||||||
|
nightMode = requiredMyApplication().getDaynightHelper().isNightModeForMapControlsForProfile(getAppMode());
|
||||||
|
} else {
|
||||||
|
nightMode = !requiredMyApplication().getSettings().isLightContentForMode(getAppMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue