diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index fd6f9eb915..f1809483ad 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,12 +11,13 @@
Thx - Hardy
-->
- "OsmAnd uses UTM Standard format which is similar but not identical to UTM Nato format."
+ All settings below are affected only selected profile.
+ OsmAnd uses UTM Standard format which is similar but not identical to UTM Nato format.
Example
UTM Standard
Open Location Code
The selected format will be applied to all places in the application.
- This setting is selected by default for profiles: %s.
+ This setting is selected by default for profiles: %s
Change default settings
Discard changes
Apply to current %1$s profile
@@ -24,7 +25,7 @@
Start up message
Analytics
Show map during navigation above the lock screen.
- These settings affect the construction of the route. Will be applied only to the selected profile: %1$s.
+ These settings affect the construction of the route. Will be applied only to the selected profile: %1$s.
Wake time
Units & formats
Appearance
@@ -42,8 +43,6 @@
Manage application profiles…
Affect the entire application
OsmAnd settings
- Create or Log in into personal account
- Personal account
Copy from other profile
Turn screen on
Map during navigation
diff --git a/OsmAnd/res/xml/configure_profile.xml b/OsmAnd/res/xml/configure_profile.xml
index fb17dbc432..261453edfa 100644
--- a/OsmAnd/res/xml/configure_profile.xml
+++ b/OsmAnd/res/xml/configure_profile.xml
@@ -3,6 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
+
+
-
diff --git a/OsmAnd/res/xml/general_profile_settings.xml b/OsmAnd/res/xml/general_profile_settings.xml
index a7f942289f..26de3fba8f 100644
--- a/OsmAnd/res/xml/general_profile_settings.xml
+++ b/OsmAnd/res/xml/general_profile_settings.xml
@@ -56,22 +56,29 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools">
diff --git a/OsmAnd/res/xml/map_during_navigation.xml b/OsmAnd/res/xml/map_during_navigation.xml
index 91400396c2..8576ebf065 100644
--- a/OsmAnd/res/xml/map_during_navigation.xml
+++ b/OsmAnd/res/xml/map_during_navigation.xml
@@ -3,8 +3,8 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools">
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/OsmAnd/res/xml/proxy_preferences.xml b/OsmAnd/res/xml/proxy_preferences.xml
index fe20a699fe..3ba3a50800 100644
--- a/OsmAnd/res/xml/proxy_preferences.xml
+++ b/OsmAnd/res/xml/proxy_preferences.xml
@@ -7,7 +7,8 @@
+ android:summaryOff="@string/shared_string_off"
+ android:summaryOn="@string/shared_string_on" />
+ tools:title="@string/route_parameters_info" />
\ No newline at end of file
diff --git a/OsmAnd/res/xml/screen_alerts.xml b/OsmAnd/res/xml/screen_alerts.xml
index 78a5aefb9f..060bac0788 100644
--- a/OsmAnd/res/xml/screen_alerts.xml
+++ b/OsmAnd/res/xml/screen_alerts.xml
@@ -5,28 +5,33 @@
+ android:summaryOff="@string/shared_string_off"
+ android:summaryOn="@string/shared_string_on" />
+ android:selectable="false"
+ android:title="@string/screen_alerts_descr"
+ tools:icon="@drawable/ic_action_info_dark" />
diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml
index 1ec831fc2b..b6a769ca9e 100644
--- a/OsmAnd/res/xml/settings_main_screen.xml
+++ b/OsmAnd/res/xml/settings_main_screen.xml
@@ -3,14 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
-
-
-
-
-
-
-
-
+ android:key="turn_screen_on_enabled"
+ android:layout="@layout/preference_top_switch"
+ android:summaryOff="@string/shared_string_off"
+ android:summaryOn="@string/shared_string_on" />
\ No newline at end of file
diff --git a/OsmAnd/res/xml/vehicle_parameters.xml b/OsmAnd/res/xml/vehicle_parameters.xml
index ea89565bcf..9c2d5811ad 100644
--- a/OsmAnd/res/xml/vehicle_parameters.xml
+++ b/OsmAnd/res/xml/vehicle_parameters.xml
@@ -5,7 +5,9 @@
+ tools:icon="@drawable/ic_action_info_dark"
+ tools:title="@string/route_parameters_info" />
\ No newline at end of file
diff --git a/OsmAnd/res/xml/voice_announces.xml b/OsmAnd/res/xml/voice_announces.xml
index 0a9059f768..acbeaecc39 100644
--- a/OsmAnd/res/xml/voice_announces.xml
+++ b/OsmAnd/res/xml/voice_announces.xml
@@ -5,71 +5,84 @@
+ android:summaryOff="@string/shared_string_off"
+ android:summaryOn="@string/shared_string_on" />
@@ -80,9 +93,11 @@
android:title="@string/language_and_output" />
+ tools:icon="@drawable/ic_action_volume_up" />
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index de948c9da8..e0ef92fb31 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -8,6 +8,8 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.hardware.Sensor;
import android.hardware.SensorManager;
+import android.media.AudioAttributes;
+import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
@@ -38,6 +40,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.mapillary.MapillaryPlugin;
import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
import net.osmand.plus.render.RendererRegistry;
+import net.osmand.plus.voice.CommandPlayer;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
@@ -158,6 +161,7 @@ public class OsmandSettings {
ctx = clientContext;
this.settingsAPI = settinsAPI;
CUSTOM_SHARED_PREFERENCES_NAME = CUSTOM_SHARED_PREFERENCES_PREFIX + sharedPreferencesName;
+ dataStore = new PreferencesDataStore();
initPrefs();
setCustomized();
}
@@ -471,9 +475,15 @@ public class OsmandSettings {
if (global) {
return set(obj);
}
- boolean ch = setValue(getProfilePreferences(mode), obj);
+ Object profilePrefs = getProfilePreferences(mode);
+ boolean changed = setValue(profilePrefs, obj);
+
+ if (changed && cache && cachedPreference == profilePrefs) {
+ cachedValue = obj;
+ }
+
fireEvent(obj);
- return ch;
+ return changed;
}
public T getProfileDefaultValue(ApplicationMode mode) {
@@ -1227,11 +1237,11 @@ public class OsmandSettings {
public final CommonPreference ENABLE_PROXY = new BooleanPreference("enable_proxy", false) {
@Override
protected boolean setValue(Object prefs, Boolean val) {
- boolean changed = super.setValue(prefs, val);
- if (changed) {
+ boolean valueSet = super.setValue(prefs, val);
+ if (valueSet) {
NetworkUtils.setProxy(val ? PROXY_HOST.get() : null, val ? PROXY_PORT.get() : 0);
}
- return changed;
+ return valueSet;
}
}.makeGlobal();
@@ -1309,9 +1319,42 @@ public class OsmandSettings {
public final OsmandPreference SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", false).makeProfile().cache();
public final OsmandPreference SPEAK_SPEED_CAMERA = new BooleanPreference("speak_cameras", false).makeProfile().cache();
public final OsmandPreference SPEAK_TUNNELS = new BooleanPreference("speak_tunnels", false).makeProfile().cache();
- public final OsmandPreference ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true).makeProfile().cache();
- public final OsmandPreference ANNOUNCE_NEARBY_FAVORITES = new BooleanPreference("announce_nearby_favorites", false).makeProfile().cache();
- public final OsmandPreference ANNOUNCE_NEARBY_POI = new BooleanPreference("announce_nearby_poi", false).makeProfile().cache();
+
+ public final OsmandPreference ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true) {
+ @Override
+ protected boolean setValue(Object prefs, Boolean val) {
+ boolean changed = super.setValue(prefs, val);
+ if (changed) {
+ SHOW_WPT.set(val);
+ }
+
+ return changed;
+ }
+ }.makeProfile().cache();
+
+ public final OsmandPreference ANNOUNCE_NEARBY_FAVORITES = new BooleanPreference("announce_nearby_favorites", false) {
+ @Override
+ protected boolean setValue(Object prefs, Boolean val) {
+ boolean changed = super.setValue(prefs, val);
+ if (changed) {
+ SHOW_NEARBY_FAVORITES.set(val);
+ }
+
+ return changed;
+ }
+ }.makeProfile().cache();
+
+ public final OsmandPreference ANNOUNCE_NEARBY_POI = new BooleanPreference("announce_nearby_poi", false) {
+ @Override
+ protected boolean setValue(Object prefs, Boolean val) {
+ boolean changed = super.setValue(prefs, val);
+ if (changed) {
+ SHOW_NEARBY_POI.set(val);
+ }
+
+ return changed;
+ }
+ }.makeProfile().cache();
public final OsmandPreference GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference("gpx_routing_calculate_osmand_route", true).makeGlobal().cache();
public final OsmandPreference GPX_CALCULATE_RTEPT = new BooleanPreference("gpx_routing_calculate_rtept", true).makeGlobal().cache();
@@ -1437,7 +1480,7 @@ public class OsmandSettings {
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
}
- public final CommonPreference TURN_SCREEN_ON = new BooleanPreference("turn_screen_on", false).makeProfile();
+ public final CommonPreference TURN_SCREEN_ON_ENABLED = new BooleanPreference("turn_screen_on_enabled", false).makeProfile();
public final CommonPreference TURN_SCREEN_ON_TIME_INT = new IntPreference("turn_screen_on_time_int", 0).makeProfile();
@@ -1487,8 +1530,31 @@ public class OsmandSettings {
public final OsmandPreference LEVEL_TO_SWITCH_VECTOR_RASTER = new IntPreference("level_to_switch_vector_raster", 1).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
- public final OsmandPreference AUDIO_STREAM_GUIDANCE = new IntPreference("audio_stream",
- 3/*AudioManager.STREAM_MUSIC*/).makeProfile();
+ public final OsmandPreference AUDIO_STREAM_GUIDANCE = new IntPreference("audio_stream", 3/*AudioManager.STREAM_MUSIC*/) {
+ @Override
+ protected boolean setValue(Object prefs, Integer stream) {
+ boolean valueSet = super.setValue(prefs, stream);
+
+ if (valueSet) {
+ CommandPlayer player = ctx.getPlayer();
+ if (player != null) {
+ player.updateAudioStream(get());
+ }
+ // Sync corresponding AUDIO_USAGE value
+ ApplicationMode mode = APPLICATION_MODE.get();
+ if (stream == AudioManager.STREAM_MUSIC) {
+ AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE);
+ } else if (stream == AudioManager.STREAM_NOTIFICATION) {
+ AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_NOTIFICATION);
+ } else if (stream == AudioManager.STREAM_VOICE_CALL) {
+ AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_VOICE_COMMUNICATION);
+ }
+ }
+
+ return valueSet;
+ }
+ }.makeProfile();
+
// Corresponding USAGE value for AudioAttributes
public final OsmandPreference AUDIO_USAGE = new IntPreference("audio_usage",
12/*AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE*/).makeProfile();
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
index dbd632471e..6b2a0020ed 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
@@ -645,7 +645,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
if (!initialSpeedCam) {
if (settings.SPEAK_SPEED_CAMERA.get()) {
settings.SPEAK_SPEED_CAMERA.set(false);
- confirmSpeedCamerasDlg(SettingsNavigationActivity.this, settings);
+ confirmSpeedCamerasDlg();
}
}
@@ -658,9 +658,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
return false;
}
-
- public static void confirmSpeedCamerasDlg(Activity activity, final OsmandSettings settings) {
- AlertDialog.Builder bld = new AlertDialog.Builder(activity);
+
+ private void confirmSpeedCamerasDlg() {
+ AlertDialog.Builder bld = new AlertDialog.Builder(this);
bld.setMessage(R.string.confirm_usage_speed_cameras);
bld.setPositiveButton(R.string.shared_string_yes, new OnClickListener() {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
index 9fd15ee11e..6359b15e6e 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
@@ -31,6 +31,7 @@ public class LockHelper implements SensorEventListener {
private OsmandApplication app;
private CommonPreference turnScreenOnTime;
private CommonPreference turnScreenOnSensor;
+ private CommonPreference turnScreenOnEnabled;
@Nullable
private LockUIAdapter lockUIAdapter;
@@ -48,6 +49,7 @@ public class LockHelper implements SensorEventListener {
this.app = app;
uiHandler = new Handler();
OsmandSettings settings = app.getSettings();
+ turnScreenOnEnabled = settings.TURN_SCREEN_ON_ENABLED;
turnScreenOnTime = settings.TURN_SCREEN_ON_TIME_INT;
turnScreenOnSensor = settings.TURN_SCREEN_ON_SENSOR;
@@ -116,7 +118,7 @@ public class LockHelper implements SensorEventListener {
private void unlockEvent() {
int unlockTime = turnScreenOnTime.get();
- if (unlockTime > 0) {
+ if (unlockTime > 0 && turnScreenOnEnabled.get()) {
timedUnlock(unlockTime * 1000L);
}
}
@@ -165,7 +167,7 @@ public class LockHelper implements SensorEventListener {
public void onStop(@NonNull Activity activity) {
lock();
- if (!activity.isFinishing() && isSensorEnabled()) {
+ if (!activity.isFinishing() && turnScreenOnEnabled.get() && isSensorEnabled()) {
switchSensorOn();
}
}
diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
index 37912eb65b..30721333ab 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
@@ -255,7 +255,7 @@ public class WaypointHelper {
public boolean isTypeEnabled(int type) {
if (type == ALARMS) {
- return app.getSettings().SHOW_TRAFFIC_WARNINGS.getModeValue(appMode);
+ return app.getSettings().SHOW_ROUTING_ALARMS.get() && app.getSettings().SHOW_TRAFFIC_WARNINGS.getModeValue(appMode);
} else if (type == POI) {
return app.getSettings().SHOW_NEARBY_POI.getModeValue(appMode);
} else if (type == FAVORITES) {
@@ -620,7 +620,8 @@ public class WaypointHelper {
AlarmInfo prevSpeedCam = null;
for (AlarmInfo i : route.getAlarmInfo()) {
if (i.getType() == AlarmInfoType.SPEED_CAMERA) {
- if (app.getSettings().SHOW_CAMERAS.getModeValue(mode) || app.getSettings().SPEAK_SPEED_CAMERA.getModeValue(mode)) {
+ if (app.getSettings().SHOW_ROUTING_ALARMS.get() && app.getSettings().SHOW_CAMERAS.getModeValue(mode)
+ || app.getSettings().SPEAK_SPEED_CAMERA.getModeValue(mode)) {
LocationPointWrapper lw = new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex());
if(prevSpeedCam != null &&
MapUtils.getDistance(prevSpeedCam.getLatitude(), prevSpeedCam.getLongitude(),
@@ -633,7 +634,8 @@ public class WaypointHelper {
}
}
} else {
- if (app.getSettings().SHOW_TRAFFIC_WARNINGS.getModeValue(mode) || app.getSettings().SPEAK_TRAFFIC_WARNINGS.getModeValue(mode)) {
+ if (app.getSettings().SHOW_ROUTING_ALARMS.get() && app.getSettings().SHOW_TRAFFIC_WARNINGS.getModeValue(mode)
+ || app.getSettings().SPEAK_TRAFFIC_WARNINGS.getModeValue(mode)) {
LocationPointWrapper lw = new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex());
lw.setAnnounce(app.getSettings().SPEAK_TRAFFIC_WARNINGS.get());
array.add(lw);
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index 0daa00fd2c..149d1a9ec0 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -1080,7 +1080,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (!poiFilters.isEmpty()) {
createPoiFiltersItems(mapActivity, poiFilters, optionsContainer);
}
- if (traffic) {
+ if (traffic && app.getSettings().SHOW_ROUTING_ALARMS.get()) {
createWaypointItem(mapActivity, optionsContainer, WaypointHelper.ALARMS);
}
if (fav) {
diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java
index 6290baa66c..ef092063b1 100644
--- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java
+++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java
@@ -1,14 +1,8 @@
package net.osmand.plus.routing;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import android.media.AudioManager;
+import android.media.SoundPool;
import net.osmand.Location;
import net.osmand.binary.RouteDataObject;
@@ -26,8 +20,14 @@ import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType;
import net.osmand.util.MapUtils;
-import android.media.AudioManager;
-import android.media.SoundPool;
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
public class VoiceRouter {
@@ -907,13 +907,14 @@ public class VoiceRouter {
}
private void play(CommandBuilder p) {
- if (p != null) {
- List played = p.play();
- notifyOnVoiceMessage(p.getListCommands(), played);
- } else {
- notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
+ if (settings.SPEAK_ROUTING_ALARMS.get()) {
+ if (p != null) {
+ List played = p.play();
+ notifyOnVoiceMessage(p.getListCommands(), played);
+ } else {
+ notifyOnVoiceMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
+ }
}
-
}
private void makeSound() {
diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
index e4c127a1b6..e7e4f98e44 100644
--- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
@@ -281,7 +281,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
if (preference != null) {
preference.setOnPreferenceChangeListener(this);
preference.setOnPreferenceClickListener(this);
- preference.setIconSpaceReserved(true);
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
diff --git a/OsmAnd/src/net/osmand/plus/settings/ChangeGeneralProfilesPrefBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/ChangeGeneralProfilesPrefBottomSheet.java
index 0bf158162e..a7eb577441 100644
--- a/OsmAnd/src/net/osmand/plus/settings/ChangeGeneralProfilesPrefBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/ChangeGeneralProfilesPrefBottomSheet.java
@@ -23,6 +23,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
public class ChangeGeneralProfilesPrefBottomSheet extends MenuBottomSheetDialogFragment {
@@ -39,7 +40,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends MenuBottomSheetDialogF
public void createMenuItems(Bundle savedInstanceState) {
final OsmandApplication app = getMyApplication();
Bundle args = getArguments();
- if (app == null || args == null || !args.containsKey(PREFERENCE_ID)) {
+ if (app == null || args == null || newValue == null || !args.containsKey(PREFERENCE_ID)) {
return;
}
final String prefId = args.getString(PREFERENCE_ID);
@@ -57,17 +58,18 @@ public class ChangeGeneralProfilesPrefBottomSheet extends MenuBottomSheetDialogF
for (int i = 0; i < values.size(); i++) {
ApplicationMode mode = values.get(i);
Object modeValue = pref.getModeValue(mode);
+ if (modeValue instanceof Enum) {
+ modeValue = ((Enum) modeValue).ordinal();
+ }
if (modeValue.equals(newValue)) {
appModesSameValue.add(mode);
}
}
- for (int i = 0; i < appModesSameValue.size(); i++) {
- ApplicationMode mode = appModesSameValue.get(i);
- builder.append(mode.toHumanString(app));
- if (i < appModesSameValue.size() - 1) {
- builder.append(", ");
- }
+ Iterator iterator = appModesSameValue.iterator();
+ while (iterator.hasNext()) {
+ builder.append(iterator.next().toHumanString(app));
+ builder.append(iterator.hasNext() ? ", " : '.');
}
if (builder.length() > 0) {
@@ -85,6 +87,10 @@ public class ChangeGeneralProfilesPrefBottomSheet extends MenuBottomSheetDialogF
for (ApplicationMode mode : values) {
app.getSettings().setPreference(prefId, newValue, mode);
}
+ BaseSettingsFragment target = (BaseSettingsFragment) getTargetFragment();
+ if (target != null) {
+ target.updateAllSettings();
+ }
dismiss();
}
})
@@ -101,6 +107,10 @@ public class ChangeGeneralProfilesPrefBottomSheet extends MenuBottomSheetDialogF
@Override
public void onClick(View v) {
app.getSettings().setPreference(prefId, newValue);
+ BaseSettingsFragment target = (BaseSettingsFragment) getTargetFragment();
+ if (target != null) {
+ target.updateAllSettings();
+ }
dismiss();
}
})
diff --git a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java
index 63528c0d08..3e430ded5d 100644
--- a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java
@@ -40,6 +40,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
protected void setupPreferences() {
Preference generalSettings = findPreference("general_settings");
Preference navigationSettings = findPreference("navigation_settings");
+ Preference pluginSettings = findPreference("plugin_settings");
generalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings));
navigationSettings.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark));
diff --git a/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java b/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java
index cd074d649e..217a233b6b 100644
--- a/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/CoordinatesFormatFragment.java
@@ -92,6 +92,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
}
};
utmPref.setKey(UTM_FORMAT);
+ utmPref.setTitle(R.string.navigate_point_format_utm);
utmPref.setPersistent(false);
utmPref.setOrder(4);
utmPref.setLayoutResource(R.layout.preference_radio_button);
diff --git a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java
index 628cf9641f..2779feb662 100644
--- a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java
@@ -15,7 +15,6 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
-import net.osmand.StateChangedListener;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@@ -69,13 +68,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
appTheme.setEntries(new String[] {getString(R.string.dark_theme), getString(R.string.light_theme)});
appTheme.setEntryValues(new Integer[] {OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
appTheme.setIcon(getOsmandThemeIcon());
-
- settings.OSMAND_THEME.addListener(new StateChangedListener() {
- @Override
- public void stateChanged(Integer change) {
- appTheme.setIcon(getOsmandThemeIcon());
- }
- });
}
private Drawable getOsmandThemeIcon() {
@@ -87,13 +79,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
rotateMap.setEntries(new String[] {getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
rotateMap.setEntryValues(new Integer[] {OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
rotateMap.setIcon(getRotateMapIcon());
-
- settings.ROTATE_MAP.addListener(new StateChangedListener() {
- @Override
- public void stateChanged(Integer change) {
- rotateMap.setIcon(getRotateMapIcon());
- }
- });
}
private Drawable getRotateMapIcon() {
@@ -112,13 +97,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
mapScreenOrientation.setEntries(new String[] {getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
mapScreenOrientation.setEntryValues(new Integer[] {ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
-
- settings.MAP_SCREEN_ORIENTATION.addListener(new StateChangedListener() {
- @Override
- public void stateChanged(Integer change) {
- mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
- }
- });
}
private Drawable getMapScreenOrientationIcon() {
@@ -157,21 +135,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
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.setEntries(new String[] {
-// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_DEGREES),
-// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_MINUTES),
-// PointDescription.formatToHumanString(ctx, PointDescription.FORMAT_SECONDS),
-// PointDescription.formatToHumanString(ctx, PointDescription.UTM_FORMAT),
-// PointDescription.formatToHumanString(ctx, PointDescription.OLC_FORMAT)
-// });
-// coordinatesFormat.setPrefsIds(new Integer[] {
-// PointDescription.FORMAT_DEGREES,
-// PointDescription.FORMAT_MINUTES,
-// PointDescription.FORMAT_SECONDS,
-// PointDescription.UTM_FORMAT,
-// PointDescription.OLC_FORMAT
-// });
}
private void setupAngularUnitsPref() {
@@ -200,36 +163,33 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
private void setupKalmanFilterPref() {
SwitchPreferenceEx kalmanFilterPref = (SwitchPreferenceEx) findPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS.getId());
- kalmanFilterPref.setSummaryOn(R.string.shared_string_on);
- kalmanFilterPref.setSummaryOff(R.string.shared_string_off);
kalmanFilterPref.setTitle(getString(R.string.use_kalman_filter_compass));
kalmanFilterPref.setDescription(getString(R.string.use_kalman_filter_compass_descr));
+ kalmanFilterPref.setIconSpaceReserved(true);
}
private void setupMagneticFieldSensorPref() {
SwitchPreferenceEx useMagneticSensorPref = (SwitchPreferenceEx) findPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS.getId());
- useMagneticSensorPref.setSummaryOn(R.string.shared_string_on);
- useMagneticSensorPref.setSummaryOff(R.string.shared_string_off);
useMagneticSensorPref.setTitle(getString(R.string.use_magnetic_sensor));
useMagneticSensorPref.setDescription(getString(R.string.use_magnetic_sensor_descr));
+ useMagneticSensorPref.setIconSpaceReserved(true);
}
private void setupMapEmptyStateAllowedPref() {
SwitchPreferenceEx mapEmptyStateAllowedPref = (SwitchPreferenceEx) findPreference(settings.MAP_EMPTY_STATE_ALLOWED.getId());
- mapEmptyStateAllowedPref.setSummaryOn(R.string.shared_string_on);
- mapEmptyStateAllowedPref.setSummaryOff(R.string.shared_string_off);
mapEmptyStateAllowedPref.setTitle(getString(R.string.tap_on_map_to_hide_interface));
mapEmptyStateAllowedPref.setDescription(getString(R.string.tap_on_map_to_hide_interface_descr));
+ mapEmptyStateAllowedPref.setIconSpaceReserved(true);
}
private void setupDoNotUseAnimationsPref() {
SwitchPreference doNotUseAnimations = (SwitchPreference) findPreference(settings.DO_NOT_USE_ANIMATIONS.getId());
- doNotUseAnimations.setSummaryOn(R.string.shared_string_on);
- doNotUseAnimations.setSummaryOff(R.string.shared_string_off);
+ doNotUseAnimations.setIconSpaceReserved(true);
}
private void setupExternalInputDevicePref() {
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
+ externalInputDevice.setIconSpaceReserved(true);
externalInputDevice.setEntries(new String[] {
getString(R.string.sett_no_ext_input),
getString(R.string.sett_generic_ext_input),
diff --git a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java
index 32d7008581..6d2853e372 100644
--- a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java
@@ -319,21 +319,15 @@ public class GlobalSettingsFragment extends BaseSettingsFragment {
private void setupSendAnonymousDataPref() {
SwitchPreferenceEx sendAnonymousData = (SwitchPreferenceEx) findPreference(settings.SEND_ANONYMOUS_DATA.getId());
- sendAnonymousData.setSummaryOn(R.string.shared_string_on);
- sendAnonymousData.setSummaryOff(R.string.shared_string_off);
}
private void setupDoNotShowStartupMessagesPref() {
SwitchPreference doNotShowStartupMessages = (SwitchPreference) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId());
- doNotShowStartupMessages.setSummaryOn(R.string.shared_string_on);
- doNotShowStartupMessages.setSummaryOff(R.string.shared_string_off);
}
private void setupEnableProxyPref() {
SwitchPreferenceEx enableProxy = (SwitchPreferenceEx) findPreference(settings.ENABLE_PROXY.getId());
enableProxy.setIcon(getContentIcon(R.drawable.ic_action_proxy));
- enableProxy.setSummaryOn(R.string.shared_string_on);
- enableProxy.setSummaryOff(R.string.shared_string_off);
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java
index a3a9dc5be1..367716e8d8 100644
--- a/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/MapDuringNavigationFragment.java
@@ -30,7 +30,6 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
@Override
protected void setupPreferences() {
Preference mapDuringNavigationInfo = findPreference("map_during_navigation_info");
- mapDuringNavigationInfo.setTitle(R.string.map_during_navigation_info);
mapDuringNavigationInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
setupAutoFollowPref();
@@ -86,8 +85,6 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
private void setupSnapToRoadPref() {
SwitchPreferenceEx snapToRoad = (SwitchPreferenceEx) findPreference(settings.SNAP_TO_ROAD.getId());
snapToRoad.setTitle(getString(R.string.snap_to_road));
- snapToRoad.setSummaryOn(R.string.shared_string_on);
- snapToRoad.setSummaryOff(R.string.shared_string_off);
snapToRoad.setDescription(getString(R.string.snap_to_road_descr));
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java
index 43b8010509..0168735937 100644
--- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java
@@ -27,19 +27,24 @@ public class NavigationFragment extends BaseSettingsFragment {
@Override
protected void setupPreferences() {
Preference routeParameters = findPreference("route_parameters");
- SwitchPreference showRoutingAlarms = (SwitchPreference) findPreference("show_routing_alarms");
- SwitchPreference speakRoutingAlarms = (SwitchPreference) findPreference("speak_routing_alarms");
- Preference vehicleParameters = findPreference("vehicle_parameters");
+ SwitchPreference showRoutingAlarms = (SwitchPreference) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
+ SwitchPreference speakRoutingAlarms = (SwitchPreference) findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
Preference mapDuringNavigation = findPreference("map_during_navigation");
- SwitchPreference turnScreenOn = (SwitchPreference) findPreference("turn_screen_on");
+ mapDuringNavigation.setIconSpaceReserved(true);
+
+ SwitchPreference turnScreenOn = (SwitchPreference) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert));
speakRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_volume_up));
+ turnScreenOn.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on));
+ setupVehicleParametersPref();
+ }
+
+ private void setupVehicleParametersPref() {
+ Preference vehicleParameters = findPreference("vehicle_parameters");
int iconRes = getSelectedAppMode().getIconRes();
vehicleParameters.setIcon(getContentIcon(iconRes));
-
- turnScreenOn.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on));
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java
index f799c9cf7f..d5d0a59734 100644
--- a/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java
@@ -41,29 +41,22 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
private void setupEnableProxyPref() {
SwitchPreference enableProxyPref = (SwitchPreference) findPreference(settings.ENABLE_PROXY.getId());
- enableProxyPref.setSummaryOn(R.string.shared_string_on);
- enableProxyPref.setSummaryOff(R.string.shared_string_off);
}
private void setupProxyHostPref() {
EditTextPreferenceEx hostPref = (EditTextPreferenceEx) findPreference(settings.PROXY_HOST.getId());
+ hostPref.setPersistent(false);
hostPref.setSummary(settings.PROXY_HOST.get());
hostPref.setDescription(R.string.proxy_host_descr);
+ hostPref.setIconSpaceReserved(true);
}
private void setupProxyPortPref() {
EditTextPreferenceEx portPref = (EditTextPreferenceEx) findPreference(settings.PROXY_PORT.getId());
+ portPref.setPersistent(false);
portPref.setSummary(String.valueOf(settings.PROXY_PORT.get()));
portPref.setDescription(R.string.proxy_port_descr);
- }
-
- protected void enableProxy(boolean enable) {
- settings.ENABLE_PROXY.set(enable);
- if (enable) {
- NetworkUtils.setProxy(settings.PROXY_HOST.get(), settings.PROXY_PORT.get());
- } else {
- NetworkUtils.setProxy(null, 0);
- }
+ portPref.setIconSpaceReserved(true);
}
@Override
@@ -76,8 +69,8 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
String ipAddress = (String) newValue;
if (ipAddress.matches(IP_ADDRESS_PATTERN)) {
settings.PROXY_HOST.set(ipAddress);
- enableProxy(NetworkUtils.getProxy() != null);
- setupProxyHostPref();
+ settings.ENABLE_PROXY.set(NetworkUtils.getProxy() != null);
+ preference.setSummary(ipAddress);
return true;
} else {
Toast.makeText(getContext(), getString(R.string.wrong_format), Toast.LENGTH_SHORT).show();
@@ -91,8 +84,8 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
} catch (NumberFormatException e1) {
}
settings.PROXY_PORT.set(port);
- enableProxy(NetworkUtils.getProxy() != null);
- setupProxyPortPref();
+ settings.ENABLE_PROXY.set(NetworkUtils.getProxy() != null);
+ preference.setSummary(String.valueOf(port));
return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java
index e84caef410..d43b26ad1e 100644
--- a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java
@@ -1,12 +1,12 @@
package net.osmand.plus.settings;
-import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import net.osmand.plus.ApplicationMode;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.BooleanPreference;
import net.osmand.plus.R;
@@ -58,6 +58,10 @@ public class RouteParametersFragment extends BaseSettingsFragment {
@Override
protected void setupPreferences() {
+ Preference vehicleParametersInfo = findPreference("route_parameters_info");
+ vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
+ vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
+
setupRoutingPrefs();
setupTimeConditionalRoutingPref();
}
@@ -71,22 +75,22 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
private void setupRoutingPrefs() {
- Context ctx = getContext();
- if (ctx == null) {
+ OsmandApplication app = getMyApplication();
+ if (app == null) {
return;
}
PreferenceScreen screen = getPreferenceScreen();
- SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(settings.FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_dialog_and_switch);
- fastRoute.setIcon(getRoutingPrefIcon(settings.FAST_ROUTE_MODE.getId()));
+ SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_dialog_and_switch);
+ fastRoute.setIcon(getRoutingPrefIcon(app.getSettings().FAST_ROUTE_MODE.getId()));
fastRoute.setDescription(getString(R.string.fast_route_mode_descr));
fastRoute.setSummaryOn(R.string.shared_string_enable);
fastRoute.setSummaryOff(R.string.shared_string_disable);
- if (settings.getApplicationMode().getRouteService() != RouteProvider.RouteService.OSMAND) {
+ if (app.getSettings().getApplicationMode().getRouteService() != RouteProvider.RouteService.OSMAND) {
screen.addPreference(fastRoute);
} else {
- ApplicationMode am = settings.getApplicationMode();
+ ApplicationMode am = app.getSettings().getApplicationMode();
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am);
clearParameters();
if (router != null) {
@@ -111,7 +115,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
}
if (avoidParameters.size() > 0) {
- MultiSelectBooleanPreference avoidRouting = new MultiSelectBooleanPreference(ctx);
+ MultiSelectBooleanPreference avoidRouting = new MultiSelectBooleanPreference(app);
avoidRouting.setKey(AVOID_ROUTING_PARAMETER_PREFIX);
avoidRouting.setTitle(R.string.avoid_in_routing_title);
avoidRouting.setSummary(R.string.avoid_in_routing_descr);
@@ -127,7 +131,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
GeneralRouter.RoutingParameter p = avoidParameters.get(i);
BooleanPreference booleanRoutingPref = (BooleanPreference) settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
- entries[i] = SettingsBaseActivity.getRoutingStringPropertyName(ctx, p.getId(), p.getName());
+ entries[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
prefsIds[i] = booleanRoutingPref.getId();
if (booleanRoutingPref.get()) {
@@ -138,20 +142,22 @@ public class RouteParametersFragment extends BaseSettingsFragment {
avoidRouting.setEntries(entries);
avoidRouting.setEntryValues(prefsIds);
avoidRouting.setValues(enabledPrefsIds);
+ avoidRouting.setIconSpaceReserved(true);
screen.addPreference(avoidRouting);
}
if (preferParameters.size() > 0) {
- Preference preferRouting = new Preference(ctx);
+ Preference preferRouting = new Preference(app);
preferRouting.setKey(PREFER_ROUTING_PARAMETER_PREFIX);
preferRouting.setTitle(R.string.prefer_in_routing_title);
preferRouting.setSummary(R.string.prefer_in_routing_descr);
preferRouting.setLayoutResource(R.layout.preference_with_descr);
+ preferRouting.setIconSpaceReserved(true);
screen.addPreference(preferRouting);
}
if (reliefFactorParameters.size() > 0) {
String defaultTitle = Algorithms.capitalizeFirstLetterAndLowercase(RELIEF_SMOOTHNESS_FACTOR.replace('_', ' '));
- String title = SettingsBaseActivity.getRoutingStringPropertyName(ctx, RELIEF_SMOOTHNESS_FACTOR, defaultTitle);
+ String title = SettingsBaseActivity.getRoutingStringPropertyName(app, RELIEF_SMOOTHNESS_FACTOR, defaultTitle);
Object[] entryValues = new Object[reliefFactorParameters.size()];
String[] entries = new String[entryValues.length];
@@ -160,7 +166,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
for (int i = 0; i < reliefFactorParameters.size(); i++) {
GeneralRouter.RoutingParameter parameter = reliefFactorParameters.get(i);
entryValues[i] = parameter.getId();
- entries[i] = SettingsNavigationActivity.getRoutinParameterTitle(ctx, parameter);
+ entries[i] = SettingsNavigationActivity.getRoutinParameterTitle(app, parameter);
if (SettingsNavigationActivity.isRoutingParameterSelected(settings, am, parameter)) {
selectedParameterId = parameter.getId();
}
@@ -170,12 +176,13 @@ public class RouteParametersFragment extends BaseSettingsFragment {
reliefFactorRouting.setPersistent(false);
reliefFactorRouting.setValue(selectedParameterId);
reliefFactorRouting.setDescription(R.string.relief_smoothness_factor_descr);
+ reliefFactorRouting.setIconSpaceReserved(true);
screen.addPreference(reliefFactorRouting);
}
for (GeneralRouter.RoutingParameter p : otherRoutingParameters) {
- String title = SettingsBaseActivity.getRoutingStringPropertyName(ctx, p.getId(), p.getName());
- String description = SettingsBaseActivity.getRoutingStringPropertyDescription(ctx, p.getId(), p.getDescription());
+ String title = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
+ String description = SettingsBaseActivity.getRoutingStringPropertyDescription(app, p.getId(), p.getDescription());
if (p.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
OsmandSettings.OsmandPreference pref = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
@@ -185,6 +192,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
switchPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
switchPreferenceEx.setSummaryOn(R.string.shared_string_enable);
switchPreferenceEx.setSummaryOff(R.string.shared_string_disable);
+ switchPreferenceEx.setIconSpaceReserved(true);
screen.addPreference(switchPreferenceEx);
} else {
@@ -199,6 +207,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
ListPreferenceEx listPreferenceEx = (ListPreferenceEx) createListPreferenceEx(pref.getId(), p.getPossibleValueDescriptions(), svlss, title, R.layout.preference_with_descr);
listPreferenceEx.setDescription(description);
listPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
+ listPreferenceEx.setIconSpaceReserved(true);
screen.addPreference(listPreferenceEx);
}
@@ -226,8 +235,8 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
private void clearParameters() {
- preferParameters.clear();
avoidParameters.clear();
+ preferParameters.clear();
reliefFactorParameters.clear();
otherRoutingParameters.clear();
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java b/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java
index 467cb27321..3f00079d46 100644
--- a/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/ScreenAlertsFragment.java
@@ -25,12 +25,9 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
@Override
protected void setupPreferences() {
+ setupShowRoutingAlarmsPref();
+
Preference showRoutingAlarmsInfo = findPreference("show_routing_alarms_info");
-
- SwitchPreference showRoutingAlarms = (SwitchPreference) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
- showRoutingAlarms.setSummaryOn(R.string.shared_string_on);
- showRoutingAlarms.setSummaryOff(R.string.shared_string_off);
-
SwitchPreference showTrafficWarnings = (SwitchPreference) findPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
SwitchPreference showPedestrian = (SwitchPreference) findPreference(settings.SHOW_PEDESTRIAN.getId());
SwitchPreference showCameras = (SwitchPreference) findPreference(settings.SHOW_CAMERAS.getId());
@@ -42,4 +39,9 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
showCameras.setIcon(getIcon(R.drawable.list_warnings_speed_camera));
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
}
+
+ private void setupShowRoutingAlarmsPref() {
+ SwitchPreference showRoutingAlarms = (SwitchPreference) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
+
+ }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java b/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java
index 61da3cb861..71f0fa4ecf 100644
--- a/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/TurnScreenOnFragment.java
@@ -38,9 +38,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
}
private void setupTurnScreenOnPref() {
- SwitchPreference turnScreenOn = (SwitchPreference) findPreference(settings.TURN_SCREEN_ON.getId());
- turnScreenOn.setSummaryOn(R.string.shared_string_on);
- turnScreenOn.setSummaryOff(R.string.shared_string_off);
+ SwitchPreference turnScreenOn = (SwitchPreference) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
}
private void setupTurnScreenOnTimePref() {
@@ -65,8 +63,6 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
SwitchPreferenceEx turnScreenOnSensor = (SwitchPreferenceEx) findPreference(settings.TURN_SCREEN_ON_SENSOR.getId());
turnScreenOnSensor.setIcon(getContentIcon(R.drawable.ic_action_sensor_interaction));
turnScreenOnSensor.setTitle(title);
- turnScreenOnSensor.setSummaryOn(R.string.shared_string_on);
- turnScreenOnSensor.setSummaryOff(R.string.shared_string_off);
turnScreenOnSensor.setDescription(description);
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java
index fd80c03538..cd52f5947c 100644
--- a/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java
@@ -45,9 +45,9 @@ public class VehicleParametersFragment extends BaseSettingsFragment {
Preference vehicleParametersInfo = findPreference("vehicle_parameters_info");
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
- vehicleParametersInfo.setTitle(getString(R.string.vehicle_parameters_info, getSelectedAppMode().toHumanString(getContext())));
+ vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
- if (settings.getApplicationMode().getRouteService() == RouteProvider.RouteService.OSMAND) {
+ if (app.getSettings().getApplicationMode().getRouteService() == RouteProvider.RouteService.OSMAND) {
GeneralRouter router = getRouter(app.getRoutingConfig(), getSelectedAppMode());
if (router != null) {
Map parameters = router.getParameters();
@@ -68,16 +68,16 @@ public class VehicleParametersFragment extends BaseSettingsFragment {
}
private void setupCustomRoutingPropertyPref(GeneralRouter.RoutingParameter parameter) {
- Context ctx = getContext();
- if (ctx == null) {
+ OsmandApplication app = getMyApplication();
+ if (app == null) {
return;
}
String parameterId = parameter.getId();
- String title = SettingsBaseActivity.getRoutingStringPropertyName(ctx, parameterId, parameter.getName());
- String description = SettingsBaseActivity.getRoutingStringPropertyDescription(ctx, parameterId, parameter.getDescription());
+ String title = SettingsBaseActivity.getRoutingStringPropertyName(app, parameterId, parameter.getName());
+ String description = SettingsBaseActivity.getRoutingStringPropertyDescription(app, parameterId, parameter.getDescription());
String defValue = parameter.getType() == GeneralRouter.RoutingParameterType.NUMERIC ? "0.0" : "-";
- OsmandSettings.StringPreference pref = (OsmandSettings.StringPreference) settings.getCustomRoutingProperty(parameterId, defValue);
+ OsmandSettings.StringPreference pref = (OsmandSettings.StringPreference) app.getSettings().getCustomRoutingProperty(parameterId, defValue);
Object[] values = parameter.getPossibleValues();
String[] valuesStr = new String[values.length];
diff --git a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java
index 0eeb1ecc42..982071e849 100644
--- a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java
@@ -1,19 +1,22 @@
package net.osmand.plus.settings;
-import android.media.AudioAttributes;
+import android.app.Activity;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
import android.media.AudioManager;
import android.support.v14.preference.SwitchPreference;
+import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
-import net.osmand.StateChangedListener;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
-import net.osmand.plus.activities.SettingsNavigationActivity;
+import net.osmand.plus.download.DownloadActivity;
+import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
-import net.osmand.plus.voice.CommandPlayer;
import java.util.Set;
@@ -33,14 +36,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
return R.layout.profile_preference_toolbar;
}
+ @Override
protected String getToolbarTitle() {
return getString(R.string.voice_announces);
}
protected void setupPreferences() {
- SwitchPreference speakRoutingAlarms = (SwitchPreference) findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
- speakRoutingAlarms.setSummaryOn(R.string.shared_string_on);
- speakRoutingAlarms.setSummaryOff(R.string.shared_string_off);
+ setupSpeakRoutingAlarmsPref();
Preference voiceAnnouncesInfo = findPreference("voice_announces_info");
voiceAnnouncesInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
@@ -50,14 +52,25 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
SwitchPreference speakPedestrian = (SwitchPreference) findPreference(settings.SPEAK_PEDESTRIAN.getId());
SwitchPreference speakSpeedLimit = (SwitchPreference) findPreference(settings.SPEAK_SPEED_LIMIT.getId());
- setupSpeedLimitExceedPref();
- setupSpeakSpeedCameraPref();
+ speakStreetNames.setIconSpaceReserved(true);
+ speakTrafficWarnings.setIconSpaceReserved(true);
+ speakPedestrian.setIconSpaceReserved(true);
+ speakSpeedLimit.setIconSpaceReserved(true);
+ setupSpeedLimitExceedPref();
+
+ SwitchPreference speakSpeedCamera = (SwitchPreference) findPreference(settings.SPEAK_SPEED_CAMERA.getId());
SwitchPreference speakTunnels = (SwitchPreference) findPreference(settings.SPEAK_TUNNELS.getId());
SwitchPreference announceWpt = (SwitchPreference) findPreference(settings.ANNOUNCE_WPT.getId());
SwitchPreference announceNearbyFavorites = (SwitchPreference) findPreference(settings.ANNOUNCE_NEARBY_FAVORITES.getId());
SwitchPreference announceNearbyPoi = (SwitchPreference) findPreference(settings.ANNOUNCE_NEARBY_POI.getId());
+ speakSpeedCamera.setIconSpaceReserved(true);
+ speakTunnels.setIconSpaceReserved(true);
+ announceWpt.setIconSpaceReserved(true);
+ announceNearbyFavorites.setIconSpaceReserved(true);
+ announceNearbyPoi.setIconSpaceReserved(true);
+
setupKeepInformingPref();
setupArrivalAnnouncementPref();
setupVoiceProviderPref();
@@ -68,6 +81,11 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
}
}
+ private void setupSpeakRoutingAlarmsPref() {
+ SwitchPreference speakRoutingAlarms = (SwitchPreference) findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
+
+ }
+
private void setupSpeedLimitExceedPref() {
Float[] speedLimitValues;
String[] speedLimitNames;
@@ -91,18 +109,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.SPEED_LIMIT_EXCEED.getId());
voiceProvider.setEntries(speedLimitNames);
voiceProvider.setEntryValues(speedLimitValues);
- }
-
- private void setupSpeakSpeedCameraPref() {
- settings.SPEAK_SPEED_CAMERA.addListener(new StateChangedListener() {
- @Override
- public void stateChanged(Boolean change) {
- SwitchPreference speakSpeedCamera = (SwitchPreference) findPreference(settings.SPEAK_SPEED_CAMERA.getId());
- if (speakSpeedCamera != null) {
- speakSpeedCamera.setChecked(change);
- }
- }
- });
+ voiceProvider.setIconSpaceReserved(true);
}
private void setupKeepInformingPref() {
@@ -113,9 +120,10 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
}
- ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.KEEP_INFORMING.getId());
- voiceProvider.setEntries(keepInformingNames);
- voiceProvider.setEntryValues(keepInformingValues);
+ ListPreferenceEx keepInforming = (ListPreferenceEx) findPreference(settings.KEEP_INFORMING.getId());
+ keepInforming.setEntries(keepInformingNames);
+ keepInforming.setEntryValues(keepInformingValues);
+ keepInforming.setIconSpaceReserved(true);
}
private void setupArrivalAnnouncementPref() {
@@ -127,13 +135,18 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
getString(R.string.arrival_distance_factor_at_last)
};
- ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId());
- voiceProvider.setEntries(arrivalNames);
- voiceProvider.setEntryValues(arrivalValues);
+ ListPreferenceEx arrivalDistanceFactor = (ListPreferenceEx) findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId());
+ arrivalDistanceFactor.setEntries(arrivalNames);
+ arrivalDistanceFactor.setEntryValues(arrivalValues);
+ arrivalDistanceFactor.setIconSpaceReserved(true);
}
private void setupVoiceProviderPref() {
- Set voiceFiles = app.getRoutingOptionsHelper().getVoiceFiles(getActivity());
+ Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+ Set voiceFiles = app.getRoutingOptionsHelper().getVoiceFiles(activity);
String[] entries = new String[voiceFiles.size() + 2];
String[] entryValues = new String[voiceFiles.size() + 2];
@@ -142,7 +155,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
entryValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE;
entries[k++] = getString(R.string.shared_string_do_not_use);
for (String s : voiceFiles) {
- entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) + " " : "") + FileNameTranslationHelper.getVoiceName(getActivity(), s);
+ entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) + " " : "") + FileNameTranslationHelper.getVoiceName(activity, s);
entryValues[k] = s;
k++;
}
@@ -170,55 +183,79 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
};
//AudioManager.USE_DEFAULT_STREAM_TYPE};
- ListPreferenceEx lp = createListPreferenceEx(settings.AUDIO_STREAM_GUIDANCE.getId(), streamTypes, streamIntTypes, R.string.choose_audio_stream, R.layout.preference_with_descr);
- getPreferenceScreen().addPreference(lp);
+ ListPreferenceEx audioStreamGuidance = createListPreferenceEx(settings.AUDIO_STREAM_GUIDANCE.getId(), streamTypes, streamIntTypes, R.string.choose_audio_stream, R.layout.preference_with_descr);
+ audioStreamGuidance.setIconSpaceReserved(true);
+
+ getPreferenceScreen().addPreference(audioStreamGuidance);
+
+ audioStreamGuidance.setDependency(settings.SPEAK_ROUTING_ALARMS.getId());
}
private void setupInterruptMusicPref() {
Preference interruptMusicPref = createSwitchPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music, R.string.interrupt_music_descr, R.layout.preference_switch);
+ interruptMusicPref.setIconSpaceReserved(true);
getPreferenceScreen().addPreference(interruptMusicPref);
+
+ interruptMusicPref.setDependency(settings.SPEAK_ROUTING_ALARMS.getId());
+ }
+
+ public void confirmSpeedCamerasDlg() {
+ Context ctx = getContext();
+ if (ctx == null) {
+ return;
+ }
+ AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
+ bld.setMessage(R.string.confirm_usage_speed_cameras);
+ bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ settings.SPEAK_SPEED_CAMERA.set(true);
+ SwitchPreference speakSpeedCamera = (SwitchPreference) findPreference(settings.SPEAK_SPEED_CAMERA.getId());
+ if (speakSpeedCamera != null) {
+ speakSpeedCamera.setChecked(true);
+ }
+ }
+ });
+ bld.setNegativeButton(R.string.shared_string_cancel, null);
+ bld.show();
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String prefId = preference.getKey();
- if (prefId.equals(settings.ANNOUNCE_NEARBY_POI.getId())) {
- settings.SHOW_NEARBY_POI.set(settings.ANNOUNCE_NEARBY_POI.get());
- }
- if (prefId.equals(settings.ANNOUNCE_NEARBY_FAVORITES.getId())) {
- settings.SHOW_NEARBY_FAVORITES.set(settings.ANNOUNCE_NEARBY_FAVORITES.get());
- }
- if (prefId.equals(settings.ANNOUNCE_WPT.getId())) {
- settings.SHOW_WPT.set(settings.ANNOUNCE_WPT.get());
+ if (prefId.equals(settings.VOICE_PROVIDER.getId())) {
+ if (MORE_VALUE.equals(newValue)) {
+ // listPref.set(oldValue); // revert the change..
+ final Intent intent = new Intent(getContext(), DownloadActivity.class);
+ intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
+ 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);
+ }
+ return true;
}
if (prefId.equals(settings.SPEAK_SPEED_CAMERA.getId())) {
if (!settings.SPEAK_SPEED_CAMERA.get()) {
- SettingsNavigationActivity.confirmSpeedCamerasDlg(getActivity(), settings);
+ confirmSpeedCamerasDlg();
return false;
} else {
return true;
}
}
if (prefId.equals(settings.AUDIO_STREAM_GUIDANCE.getId())) {
- CommandPlayer player = app.getPlayer();
- if (player != null) {
- player.updateAudioStream(settings.AUDIO_STREAM_GUIDANCE.get());
- }
- // Sync corresponding AUDIO_USAGE value
- ApplicationMode mode = getSelectedAppMode();
- int stream = settings.AUDIO_STREAM_GUIDANCE.getModeValue(mode);
- if (stream == AudioManager.STREAM_MUSIC) {
- settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE);
- } else if (stream == AudioManager.STREAM_NOTIFICATION) {
- settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_NOTIFICATION);
- } else if (stream == AudioManager.STREAM_VOICE_CALL) {
- settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_VOICE_COMMUNICATION);
- }
-
// Sync DEFAULT value with CAR value, as we have other way to set it for now
- settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_STREAM_GUIDANCE.getModeValue(ApplicationMode.CAR));
+
+ if (getSelectedAppMode().equals(ApplicationMode.CAR) && newValue instanceof Integer) {
+ settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, (Integer) newValue);
+ } else {
+ settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_STREAM_GUIDANCE.getModeValue(ApplicationMode.CAR));
+ }
settings.AUDIO_USAGE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_USAGE.getModeValue(ApplicationMode.CAR));
+
return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java
index 87235deac1..61620a04ca 100644
--- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java
+++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java
@@ -1248,13 +1248,14 @@ public class RouteInfoWidgetsFactory {
}
public boolean updateInfo(DrawSettings drawSettings) {
+ boolean showRoutingAlarms = settings.SHOW_ROUTING_ALARMS.get();
boolean trafficWarnings = settings.SHOW_TRAFFIC_WARNINGS.get();
boolean cams = settings.SHOW_CAMERAS.get();
boolean peds = settings.SHOW_PEDESTRIAN.get();
boolean tunnels = settings.SHOW_TUNNELS.get();
boolean visible = false;
if ((rh.isFollowingMode() || trackingUtilities.isMapLinkedToLocation())
- && (trafficWarnings || cams)) {
+ && showRoutingAlarms && (trafficWarnings || cams)) {
AlarmInfo alarm;
if(rh.isFollowingMode() && !rh.isDeviatedFromRoute() && rh.getCurrentGPXRoute() == null) {
alarm = wh.getMostImportantAlarm(settings.METRIC_SYSTEM.get(), cams);