aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormax-klaus <53395422+max-klaus@users.noreply.github.com>2019-10-18 20:25:51 +0300
committerGitHub <noreply@github.com>2019-10-18 20:25:51 +0300
commitdc4fb89ceae09057afb0396856f6c35afee7eb70 (patch)
treed6c1c11195589f82ebc47f2f2149b6e11690f825
parent6b49cc689d79acc5c4737286411dedb546072cfd (diff)
parent17b9972a1c17e31a72fda16224987309b9a88362 (diff)
downloadOsmand-dc4fb89ceae09057afb0396856f6c35afee7eb70.tar.gz
Merge pull request #7688 from osmandapp/settings_improvements
Profile settings improvements
-rwxr-xr-xOsmAnd/res/drawable-large/map_action_utv.pngbin586 -> 452 bytes
-rw-r--r--OsmAnd/res/xml/general_profile_settings.xml5
-rw-r--r--OsmAnd/src/net/osmand/plus/OsmandSettings.java29
-rw-r--r--OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java10
-rw-r--r--OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java1
-rw-r--r--OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java20
-rw-r--r--OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java81
7 files changed, 96 insertions, 50 deletions
diff --git a/OsmAnd/res/drawable-large/map_action_utv.png b/OsmAnd/res/drawable-large/map_action_utv.png
index c6e51e8629..7c34c8c326 100755
--- a/OsmAnd/res/drawable-large/map_action_utv.png
+++ b/OsmAnd/res/drawable-large/map_action_utv.png
Binary files differ
diff --git a/OsmAnd/res/xml/general_profile_settings.xml b/OsmAnd/res/xml/general_profile_settings.xml
index eedbd410af..bf059a374d 100644
--- a/OsmAnd/res/xml/general_profile_settings.xml
+++ b/OsmAnd/res/xml/general_profile_settings.xml
@@ -53,6 +53,11 @@
android:layout="@layout/preference_with_descr"
android:title="@string/angular_measeurement" />
+ <net.osmand.plus.settings.preferences.ListPreferenceEx
+ android:key="default_speed_system"
+ android:layout="@layout/preference_with_descr"
+ android:title="@string/default_speed_system" />
+
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index 34436b51d5..7285d5835a 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -45,17 +45,11 @@ import net.osmand.util.Algorithms;
import org.json.JSONException;
import org.json.JSONObject;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -157,8 +151,8 @@ public class OsmandSettings {
private final OsmandApplication ctx;
private PreferencesDataStore dataStore;
private SettingsAPI settingsAPI;
- private Object globalPreferences;
private Object defaultProfilePreferences;
+ private Object globalPreferences;
private Object profilePreferences;
private ApplicationMode currentMode;
private Map<String, OsmandPreference<?>> registeredPreferences =
@@ -287,7 +281,7 @@ public class OsmandSettings {
}
}
if (metricSystem != null) {
- METRIC_SYSTEM.set(metricSystem);
+ METRIC_SYSTEM.setModeValue(mode, metricSystem);
return true;
}
} else if (preference == SPEED_SYSTEM) {
@@ -306,7 +300,7 @@ public class OsmandSettings {
}
}
if (speedSystem != null) {
- SPEED_SYSTEM.set(speedSystem);
+ SPEED_SYSTEM.setModeValue(mode, speedSystem);
return true;
}
} else if (preference instanceof BooleanPreference) {
@@ -396,6 +390,7 @@ public class OsmandSettings {
if (aidlApi != null) {
aidlApi.loadConnectedApps();
OsmandPlugin.updateActivatedPlugins(ctx);
+ ctx.poiFilters.loadSelectedPoiFilters();
}
fireEvent(oldMode);
@@ -1360,9 +1355,9 @@ public class OsmandSettings {
}
- public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
+ public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeProfile();
- public final OsmandPreference<Boolean> SHOW_MAPILLARY = new BooleanPreference("show_mapillary", false).makeGlobal();
+ public final OsmandPreference<Boolean> SHOW_MAPILLARY = new BooleanPreference("show_mapillary", false).makeProfile();
public final OsmandPreference<Boolean> MAPILLARY_FIRST_DIALOG_SHOWN = new BooleanPreference("mapillary_first_dialog_shown", false).makeGlobal();
public final OsmandPreference<Boolean> ONLINE_PHOTOS_ROW_COLLAPSED = new BooleanPreference("mapillary_menu_collapsed", false).makeGlobal();
public final OsmandPreference<Boolean> WEBGL_SUPPORTED = new BooleanPreference("webgl_supported", true).makeGlobal();
@@ -1798,15 +1793,15 @@ public class OsmandSettings {
public final OsmandPreference<Integer> BT_SCO_DELAY = new IntPreference("bt_sco_delay", 1500).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
- public final CommonPreference<Boolean> MAP_ONLINE_DATA = new BooleanPreference("map_online_data", false).makeGlobal();
+ public final CommonPreference<Boolean> MAP_ONLINE_DATA = new BooleanPreference("map_online_data", false).makeProfile();
public final CommonPreference<String> CONTOUR_LINES_ZOOM = new StringPreference("contour_lines_zoom", null).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
- public final CommonPreference<String> MAP_OVERLAY = new StringPreference("map_overlay", null).makeGlobal().cache();
+ public final CommonPreference<String> MAP_OVERLAY = new StringPreference("map_overlay", null).makeProfile().cache();
// this value string is synchronized with settings_pref.xml preference name
- public final CommonPreference<String> MAP_UNDERLAY = new StringPreference("map_underlay", null).makeGlobal().cache();
+ public final CommonPreference<String> MAP_UNDERLAY = new StringPreference("map_underlay", null).makeProfile().cache();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Integer> MAP_OVERLAY_TRANSPARENCY = new IntPreference("overlay_transparency",
@@ -1818,7 +1813,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<String> MAP_TILE_SOURCES = new StringPreference("map_tile_sources",
- TileSourceManager.getMapnikSource().getName()).makeGlobal();
+ TileSourceManager.getMapnikSource().getName()).makeProfile();
public final CommonPreference<LayerTransparencySeekbarMode> LAYER_TRANSPARENCY_SEEKBAR_MODE =
new EnumIntPreference<>("layer_transparency_seekbar_mode", LayerTransparencySeekbarMode.UNDEFINED, LayerTransparencySeekbarMode.values());
@@ -1846,7 +1841,7 @@ public class OsmandSettings {
MAP_MARKERS_MODE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, MapMarkersMode.TOOLBAR);
}
- public final OsmandPreference<Boolean> SHOW_MAP_MARKERS = new BooleanPreference("show_map_markers", true).makeGlobal();
+ public final OsmandPreference<Boolean> SHOW_MAP_MARKERS = new BooleanPreference("show_map_markers", true).makeProfile();
public final OsmandPreference<Boolean> SHOW_COORDINATES_WIDGET = new BooleanPreference("show_coordinates_widget", false).makeProfile().cache();
@@ -2914,7 +2909,7 @@ public class OsmandSettings {
public final OsmandPreference<String> LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT = new StringPreference("last_selected_gpx_track_for_new_point", null).makeGlobal().cache();
// Avoid using this property, probably you need to use PoiFiltersHelper.getSelectedPoiFilters()
- public final OsmandPreference<String> SELECTED_POI_FILTER_FOR_MAP = new StringPreference("selected_poi_filter_for_map", null).makeGlobal().cache();
+ public final OsmandPreference<String> SELECTED_POI_FILTER_FOR_MAP = new StringPreference("selected_poi_filter_for_map", null).makeProfile().cache();
public Set<String> getSelectedPoiFilters() {
Set<String> result = new LinkedHashSet<>();
diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
index 432fb53164..996a1be09b 100644
--- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
@@ -17,6 +17,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
+import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.util.SunriseSunset;
import java.text.SimpleDateFormat;
@@ -37,6 +38,15 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
cat.addPreference(createCheckBoxPreference(settings.USE_OPENGL_RENDER,
R.string.use_opengl_render,R.string.use_opengl_render_descr));
+ CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode,
+ R.string.safe_mode_description);
+ // disable the checkbox if the library cannot be used
+ if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
+ nativeCheckbox.setEnabled(false);
+ nativeCheckbox.setChecked(true);
+ }
+ cat.addPreference(nativeCheckbox);
+
PreferenceCategory navigation = new PreferenceCategory(this);
navigation.setTitle(R.string.routing_settings);
cat.addPreference(navigation);
diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java
index e2aa0d5d20..5356fedfa2 100644
--- a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java
+++ b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java
@@ -369,6 +369,7 @@ public class PoiFiltersHelper {
}
public void loadSelectedPoiFilters() {
+ selectedPoiFilters.clear();
Set<String> filters = application.getSettings().getSelectedPoiFilters();
for (String f : filters) {
PoiUIFilter filter = getFilterById(f);
diff --git a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java
index 447c5e8a36..ba5299fc04 100644
--- a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java
@@ -48,6 +48,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
setupUnitsOfLengthPref();
setupCoordinatesFormatPref();
setupAngularUnitsPref();
+ setupSpeedSystemPref();
setupKalmanFilterPref();
setupMagneticFieldSensorPref();
@@ -202,7 +203,24 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
ListPreferenceEx angularUnits = (ListPreferenceEx) findPreference(settings.ANGULAR_UNITS.getId());
angularUnits.setEntries(entries);
angularUnits.setEntryValues(entryValues);
- angularUnits.setIcon(getContentIcon(R.drawable.ic_action_angular_unit));
+ angularUnits.setIcon(getIcon(R.drawable.ic_action_angular_unit));
+ }
+
+ private void setupSpeedSystemPref() {
+ OsmandSettings.SpeedConstants[] speedConstants = OsmandSettings.SpeedConstants.values();
+ String[] entries = new String[speedConstants.length];
+ Integer[] entryValues = new Integer[speedConstants.length];
+
+ for (int i = 0; i < entries.length; i++) {
+ entries[i] = speedConstants[i].toHumanString(app);
+ entryValues[i] = speedConstants[i].ordinal();
+ }
+
+ ListPreferenceEx speedSystem = (ListPreferenceEx) findPreference(settings.SPEED_SYSTEM.getId());
+ speedSystem.setEntries(entries);
+ speedSystem.setEntryValues(entryValues);
+ speedSystem.setDescription(R.string.default_speed_system_descr);
+ speedSystem.setIcon(getContentIcon(R.drawable.ic_action_speed));
}
private void setupKalmanFilterPref() {
diff --git a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java
index 6c4dd6ba70..c4ab399b6c 100644
--- a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java
@@ -15,7 +15,6 @@ import net.osmand.plus.OsmandSettings.BooleanPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.activities.SettingsNavigationActivity;
-import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference;
@@ -30,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
+import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE;
public class RouteParametersFragment extends BaseSettingsFragment {
@@ -43,6 +43,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
private List<GeneralRouter.RoutingParameter> preferParameters = new ArrayList<GeneralRouter.RoutingParameter>();
+ private List<GeneralRouter.RoutingParameter> drivingStyleParameters = new ArrayList<GeneralRouter.RoutingParameter>();
private List<GeneralRouter.RoutingParameter> reliefFactorParameters = new ArrayList<GeneralRouter.RoutingParameter>();
private List<GeneralRouter.RoutingParameter> otherRoutingParameters = new ArrayList<GeneralRouter.RoutingParameter>();
@@ -118,7 +119,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
clearParameters();
if (router != null) {
Map<String, GeneralRouter.RoutingParameter> parameters = router.getParameters();
- if (parameters.containsKey(GeneralRouter.USE_SHORTEST_WAY)) {
+ if (!am.isDerivedRoutingFrom(ApplicationMode.CAR)) {
screen.addPreference(fastRoute);
}
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : parameters.entrySet()) {
@@ -130,14 +131,19 @@ public class RouteParametersFragment extends BaseSettingsFragment {
preferParameters.add(routingParameter);
} else if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) {
reliefFactorParameters.add(routingParameter);
- } else if (!param.equals(GeneralRouter.USE_SHORTEST_WAY)
+ } else if (DRIVING_STYLE.equals(routingParameter.getGroup())) {
+ drivingStyleParameters.add(routingParameter);
+ } else if ((!param.equals(GeneralRouter.USE_SHORTEST_WAY) || am.isDerivedRoutingFrom(ApplicationMode.CAR))
&& !param.equals(GeneralRouter.VEHICLE_HEIGHT)
&& !param.equals(GeneralRouter.VEHICLE_WEIGHT)
- && !param.equals(GeneralRouter.VEHICLE_WIDTH)
- && !RoutingOptionsHelper.DRIVING_STYLE.equals(routingParameter.getGroup())) {
+ && !param.equals(GeneralRouter.VEHICLE_WIDTH)) {
otherRoutingParameters.add(routingParameter);
}
}
+ if (drivingStyleParameters.size() > 0) {
+ ListPreferenceEx drivingStyleRouting = createRoutingBooleanListPreference(DRIVING_STYLE, drivingStyleParameters);
+ screen.addPreference(drivingStyleRouting);
+ }
if (avoidParameters.size() > 0) {
MultiSelectBooleanPreference avoidRouting = new MultiSelectBooleanPreference(app);
avoidRouting.setKey(AVOID_ROUTING_PARAMETER_PREFIX);
@@ -179,27 +185,8 @@ public class RouteParametersFragment extends BaseSettingsFragment {
screen.addPreference(preferRouting);
}
if (reliefFactorParameters.size() > 0) {
- String defaultTitle = Algorithms.capitalizeFirstLetterAndLowercase(RELIEF_SMOOTHNESS_FACTOR.replace('_', ' '));
- String title = SettingsBaseActivity.getRoutingStringPropertyName(app, RELIEF_SMOOTHNESS_FACTOR, defaultTitle);
-
- Object[] entryValues = new Object[reliefFactorParameters.size()];
- String[] entries = new String[entryValues.length];
-
- String selectedParameterId = null;
- for (int i = 0; i < reliefFactorParameters.size(); i++) {
- GeneralRouter.RoutingParameter parameter = reliefFactorParameters.get(i);
- entryValues[i] = parameter.getId();
- entries[i] = SettingsNavigationActivity.getRoutinParameterTitle(app, parameter);
- if (SettingsNavigationActivity.isRoutingParameterSelected(settings, am, parameter)) {
- selectedParameterId = parameter.getId();
- }
- }
-
- ListPreferenceEx reliefFactorRouting = createListPreferenceEx(RELIEF_SMOOTHNESS_FACTOR, entries, entryValues, title, R.layout.preference_with_descr);
- reliefFactorRouting.setPersistent(false);
- reliefFactorRouting.setValue(selectedParameterId);
+ ListPreferenceEx reliefFactorRouting = createRoutingBooleanListPreference(RELIEF_SMOOTHNESS_FACTOR, reliefFactorParameters);
reliefFactorRouting.setDescription(R.string.relief_smoothness_factor_descr);
- reliefFactorRouting.setIconSpaceReserved(true);
screen.addPreference(reliefFactorRouting);
}
@@ -243,13 +230,12 @@ public class RouteParametersFragment extends BaseSettingsFragment {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
- if (RELIEF_SMOOTHNESS_FACTOR.equals(key)) {
- if (newValue instanceof String) {
- String selectedParameterId = (String) newValue;
- for (GeneralRouter.RoutingParameter parameter : reliefFactorParameters) {
- String parameterId = parameter.getId();
- SettingsNavigationActivity.setRoutingParameterSelected(settings, getSelectedAppMode(), parameterId, parameter.getDefaultBoolean(), parameterId.equals(selectedParameterId));
- }
+ if ((RELIEF_SMOOTHNESS_FACTOR.equals(key) || DRIVING_STYLE.equals(key)) && newValue instanceof String) {
+ String selectedParameterId = (String) newValue;
+ List<GeneralRouter.RoutingParameter> routingParameters = DRIVING_STYLE.equals(key) ? drivingStyleParameters : reliefFactorParameters;
+ for (GeneralRouter.RoutingParameter parameter : routingParameters) {
+ String parameterId = parameter.getId();
+ SettingsNavigationActivity.setRoutingParameterSelected(settings, getSelectedAppMode(), parameterId, parameter.getDefaultBoolean(), parameterId.equals(selectedParameterId));
}
return true;
}
@@ -257,9 +243,36 @@ public class RouteParametersFragment extends BaseSettingsFragment {
return super.onPreferenceChange(preference, newValue);
}
+ private ListPreferenceEx createRoutingBooleanListPreference(String groupKey, List<GeneralRouter.RoutingParameter> routingParameters) {
+ String defaultTitle = Algorithms.capitalizeFirstLetterAndLowercase(groupKey.replace('_', ' '));
+ String title = SettingsBaseActivity.getRoutingStringPropertyName(app, groupKey, defaultTitle);
+ ApplicationMode am = settings.getApplicationMode();
+
+ Object[] entryValues = new Object[routingParameters.size()];
+ String[] entries = new String[entryValues.length];
+
+ String selectedParameterId = null;
+ for (int i = 0; i < routingParameters.size(); i++) {
+ GeneralRouter.RoutingParameter parameter = routingParameters.get(i);
+ entryValues[i] = parameter.getId();
+ entries[i] = SettingsNavigationActivity.getRoutinParameterTitle(app, parameter);
+ if (SettingsNavigationActivity.isRoutingParameterSelected(settings, am, parameter)) {
+ selectedParameterId = parameter.getId();
+ }
+ }
+
+ ListPreferenceEx routingListPref = createListPreferenceEx(groupKey, entries, entryValues, title, R.layout.preference_with_descr);
+ routingListPref.setPersistent(false);
+ routingListPref.setValue(selectedParameterId);
+ routingListPref.setIcon(getRoutingPrefIcon(groupKey));
+
+ return routingListPref;
+ }
+
private void clearParameters() {
avoidParameters.clear();
preferParameters.clear();
+ drivingStyleParameters.clear();
reliefFactorParameters.clear();
otherRoutingParameters.clear();
}
@@ -268,8 +281,12 @@ public class RouteParametersFragment extends BaseSettingsFragment {
switch (prefId) {
case GeneralRouter.ALLOW_PRIVATE:
return getIcon(R.drawable.ic_action_private_access);
+ case GeneralRouter.USE_SHORTEST_WAY:
+ return getContentIcon(R.drawable.ic_action_fuel);
case AVOID_ROUTING_PARAMETER_PREFIX:
return getContentIcon(R.drawable.ic_action_alert);
+ case DRIVING_STYLE:
+ return getContentIcon(R.drawable.ic_action_bicycle_dark);
case "fast_route_mode":
return getIcon(R.drawable.ic_action_fastest_route);
case "enable_time_conditional_routing":