diff --git a/OsmAnd-java/src/net/osmand/router/GeneralRouter.java b/OsmAnd-java/src/net/osmand/router/GeneralRouter.java index 8e76789596..ad0189b99e 100644 --- a/OsmAnd-java/src/net/osmand/router/GeneralRouter.java +++ b/OsmAnd-java/src/net/osmand/router/GeneralRouter.java @@ -164,12 +164,14 @@ public class GeneralRouter implements VehicleRouter { } - public void registerBooleanParameter(String id, String name, String description) { + public void registerBooleanParameter(String id, String group, String name, String description, boolean defaultValue) { RoutingParameter rp = new RoutingParameter(); + rp.group = group; rp.name = name; rp.description = description; rp.id = id; rp.type = RoutingParameterType.BOOLEAN; + rp.defaultBoolean = defaultValue; parameters.put(rp.id, rp); } @@ -435,16 +437,21 @@ public class GeneralRouter implements VehicleRouter { public static class RoutingParameter { private String id; + private String group; private String name; private String description; private RoutingParameterType type; private Object[] possibleValues; private String[] possibleValueDescriptions; + private boolean defaultBoolean; public String getId() { return id; } - + + public String getGroup() { + return group; + } public String getName() { return name; } @@ -457,10 +464,12 @@ public class GeneralRouter implements VehicleRouter { public String[] getPossibleValueDescriptions() { return possibleValueDescriptions; } - public Object[] getPossibleValues() { return possibleValues; } + public boolean getDefaultBoolean() { + return defaultBoolean; + } } diff --git a/OsmAnd-java/src/net/osmand/router/RoutingConfiguration.java b/OsmAnd-java/src/net/osmand/router/RoutingConfiguration.java index 9039434625..3a79929142 100644 --- a/OsmAnd-java/src/net/osmand/router/RoutingConfiguration.java +++ b/OsmAnd-java/src/net/osmand/router/RoutingConfiguration.java @@ -215,11 +215,13 @@ public class RoutingConfiguration { private static void parseRoutingParameter(XmlPullParser parser, GeneralRouter currentRouter) { String description = parser.getAttributeValue("", "description"); + String group = parser.getAttributeValue("", "group"); String name = parser.getAttributeValue("", "name"); String id = parser.getAttributeValue("", "id"); String type = parser.getAttributeValue("", "type"); - if(type.equalsIgnoreCase("boolean")) { - currentRouter.registerBooleanParameter(id, name, description); + boolean defaultValue = Boolean.parseBoolean(parser.getAttributeValue("", "default")); + if (type.equalsIgnoreCase("boolean")) { + currentRouter.registerBooleanParameter(id, Algorithms.isEmpty(group) ? null : group, name, description, defaultValue); } else if(type.equalsIgnoreCase("numeric")) { String values = parser.getAttributeValue("", "values"); String valueDescriptions = parser.getAttributeValue("", "valueDescriptions"); diff --git a/OsmAnd/res/layout/layers_list_activity_item.xml b/OsmAnd/res/layout/layers_list_activity_item.xml index 519ed7c5bf..c01217f0b2 100644 --- a/OsmAnd/res/layout/layers_list_activity_item.xml +++ b/OsmAnd/res/layout/layers_list_activity_item.xml @@ -1,11 +1,12 @@ + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:minHeight="@dimen/list_item_height" + android:descendantFocusability="blocksDescendants" + android:orientation="horizontal" + android:paddingLeft="@dimen/list_content_padding" + android:paddingRight="@dimen/list_content_padding" > + + + More plains, balance, more hills Slope Add new folder Point(s) deleted successfully. diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index f9deb06a7a..1c659c7cb8 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -2724,9 +2724,9 @@ public class OsmandSettings { Map> customBooleanRoutingProps = new LinkedHashMap>(); - public CommonPreference getCustomRoutingBooleanProperty(String attrName) { + public CommonPreference getCustomRoutingBooleanProperty(String attrName, boolean defaulfValue) { if (!customBooleanRoutingProps.containsKey(attrName)) { - customBooleanRoutingProps.put(attrName, new BooleanPreference("prouting_" + attrName, false).makeProfile()); + customBooleanRoutingProps.put(attrName, new BooleanPreference("prouting_" + attrName, defaulfValue).makeProfile()); } return customBooleanRoutingProps.get(attrName); } diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index f16b2a1c61..1aa15a7620 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -3,6 +3,7 @@ package net.osmand.plus.activities; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; +import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnMultiChoiceClickListener; import android.content.Intent; @@ -12,8 +13,17 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; +import android.util.TypedValue; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + import net.osmand.plus.ApplicationMode; +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.ContextMenuItem; import net.osmand.plus.DeviceAdminRecv; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -26,6 +36,7 @@ import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.RoutingParameter; import net.osmand.router.GeneralRouter.RoutingParameterType; +import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.List; @@ -35,6 +46,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { private Preference avoidRouting; private Preference preferRouting; + private Preference reliefFactorRouting; private Preference showAlarms; private Preference speakAlarms; private ListPreference routerServicePreference; @@ -46,7 +58,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { private List avoidParameters = new ArrayList(); private List preferParameters = new ArrayList(); - public static final String INTENT_SKIP_DIALOG = "INTENT_SKIP_DIALOG"; + private List reliefFactorParameters = new ArrayList(); + public static final String INTENT_SKIP_DIALOG = "INTENT_SKIP_DIALOG"; public SettingsNavigationActivity() { super(true); @@ -238,12 +251,15 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { List others = new ArrayList(); for(Map.Entry e : parameters.entrySet()) { String param = e.getKey(); - if(param.startsWith("avoid_")) { - avoidParameters.add(e.getValue()); - } else if(param.startsWith("prefer_")) { - preferParameters.add(e.getValue()); - } else if(!param.equals("short_way")) { - others.add(e.getValue()); + RoutingParameter routingParameter = e.getValue(); + if (param.startsWith("avoid_")) { + avoidParameters.add(routingParameter); + } else if (param.startsWith("prefer_")) { + preferParameters.add(routingParameter); + } else if ("relief_smoothness_factor".equals(routingParameter.getGroup())) { + reliefFactorParameters.add(routingParameter); + } else if (!param.equals("short_way") && !"driving_style".equals(routingParameter.getGroup())) { + others.add(routingParameter); } } if (avoidParameters.size() > 0) { @@ -260,10 +276,18 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { preferRouting.setOnPreferenceClickListener(this); cat.addPreference(preferRouting); } + if (reliefFactorParameters.size() > 0) { + reliefFactorRouting = new Preference(this); + reliefFactorRouting.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, reliefFactorParameters.get(0).getGroup(), + Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' ')))); + reliefFactorRouting.setSummary(R.string.relief_smoothness_factor_descr); + reliefFactorRouting.setOnPreferenceClickListener(this); + cat.addPreference(reliefFactorRouting); + } for(RoutingParameter p : others) { Preference basePref; if(p.getType() == RoutingParameterType.BOOLEAN) { - basePref = createCheckBoxPreference(settings.getCustomRoutingBooleanProperty(p.getId())); + basePref = createCheckBoxPreference(settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean())); } else { Object[] vls = p.getPossibleValues(); String[] svlss = new String[vls.length]; @@ -293,6 +317,31 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { } } + public String getRoutinParameterTitle(Context context, RoutingParameter routingParameter) { + return SettingsBaseActivity.getRoutingStringPropertyName(context, routingParameter.getId(), + routingParameter.getName()); + } + + public boolean isRoutingParameterSelected(OsmandSettings settings, ApplicationMode am, RoutingParameter routingParameter) { + final OsmandSettings.CommonPreference property = + settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean()); + if(am != null) { + return property.getModeValue(am); + } else { + return property.get(); + } + } + + public void setRoutingParameterSelected(OsmandSettings settings, ApplicationMode am, RoutingParameter routingParameter, boolean isChecked) { + final OsmandSettings.CommonPreference property = + settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean()); + if(am != null) { + property.setModeValue(am, isChecked); + } else { + property.set(isChecked); + } + } + private void clearParameters() { preferParameters.clear(); @@ -346,16 +395,83 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { @Override public boolean onPreferenceClick(Preference preference) { if (preference == avoidRouting || preference == preferRouting) { - List prms = preference == avoidRouting ? avoidParameters : preferParameters; + List prms = preference == avoidRouting ? avoidParameters : preferParameters; String[] vals = new String[prms.size()]; OsmandPreference[] bls = new OsmandPreference[prms.size()]; - for(int i = 0; i < prms.size(); i++) { - RoutingParameter p = prms.get(i); + for (int i = 0; i < prms.size(); i++) { + RoutingParameter p = prms.get(i); vals[i] = SettingsBaseActivity.getRoutingStringPropertyName(this, p.getId(), p.getName()); - bls[i] = settings.getCustomRoutingBooleanProperty(p.getId()); + bls[i] = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()); } showBooleanSettings(vals, bls, preference.getTitle()); return true; + } else if (preference == reliefFactorRouting) { + final ApplicationMode am = settings.getApplicationMode(); + final ContextMenuAdapter adapter = new ContextMenuAdapter(); + int i = 0; + int selectedIndex = -1; + for (RoutingParameter p : reliefFactorParameters) { + adapter.addItem(ContextMenuItem.createBuilder(getRoutinParameterTitle(this, p)) + .setSelected(false).createItem()); + if (isRoutingParameterSelected(settings, am, p)) { + selectedIndex = i; + } + i++; + } + if (selectedIndex == -1) { + selectedIndex = 0; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + final int layout = R.layout.list_menu_item_native_singlechoice; + + final ArrayAdapter listAdapter = new ArrayAdapter(this, layout, R.id.text1, + adapter.getItemNames()) { + @NonNull + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + // User super class to create the View + View v = convertView; + if (v == null) { + v = SettingsNavigationActivity.this.getLayoutInflater().inflate(layout, null); + } + final ContextMenuItem item = adapter.getItem(position); + TextView tv = (TextView) v.findViewById(R.id.text1); + tv.setText(item.getTitle()); + tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f); + + return v; + } + }; + + final int[] selectedPosition = {selectedIndex}; + builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int position) { + selectedPosition[0] = position; + } + }); + builder.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, reliefFactorParameters.get(0).getGroup(), + Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' ')))) + .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + int position = selectedPosition[0]; + if (position >= 0 && position < reliefFactorParameters.size()) { + for (int i = 0; i < reliefFactorParameters.size(); i++) { + setRoutingParameterSelected(settings, am, reliefFactorParameters.get(i), i == position); + } + //mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange(); + //updateParameters(); + } + } + }) + .setNegativeButton(R.string.shared_string_cancel, null); + + builder.create().show(); + return true; } else if (preference == showAlarms) { showBooleanSettings(new String[] { getString(R.string.show_traffic_warnings), getString(R.string.show_pedestrian_warnings), getString(R.string.show_cameras), getString(R.string.show_lanes) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS, diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java index 676d065359..d662c38638 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java @@ -3,8 +3,10 @@ package net.osmand.plus.mapcontextmenu.other; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; import android.support.v7.widget.PopupMenu; +import android.util.TypedValue; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -41,6 +43,8 @@ import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.MapControlsLayer; import net.osmand.router.GeneralRouter; +import net.osmand.router.GeneralRouter.RoutingParameter; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.io.File; @@ -70,7 +74,7 @@ public class RoutePreferencesMenu { public static class LocalRoutingParameter { - public GeneralRouter.RoutingParameter routingParameter; + public RoutingParameter routingParameter; private ApplicationMode am; public LocalRoutingParameter(ApplicationMode am) { @@ -83,8 +87,8 @@ public class RoutePreferencesMenu { } public boolean isSelected(OsmandSettings settings) { - final OsmandSettings.CommonPreference property = settings.getCustomRoutingBooleanProperty(routingParameter - .getId()); + final OsmandSettings.CommonPreference property = + settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean()); if(am != null) { return property.getModeValue(am); } else { @@ -93,8 +97,8 @@ public class RoutePreferencesMenu { } public void setSelected(OsmandSettings settings, boolean isChecked) { - final OsmandSettings.CommonPreference property = settings.getCustomRoutingBooleanProperty(routingParameter - .getId()); + final OsmandSettings.CommonPreference property = + settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean()); if(am != null) { property.setModeValue(am, isChecked); } else { @@ -102,6 +106,58 @@ public class RoutePreferencesMenu { } } + public ApplicationMode getApplicationMode() { + return am; + } + } + + private static class LocalRoutingParameterGroup extends LocalRoutingParameter { + + private String groupName; + private List routingParameters = new ArrayList<>(); + + public LocalRoutingParameterGroup(ApplicationMode am, String groupName) { + super(am); + this.groupName = groupName; + } + + public void addRoutingParameter(RoutingParameter routingParameter) { + LocalRoutingParameter p = new LocalRoutingParameter(getApplicationMode()); + p.routingParameter = routingParameter; + routingParameters.add(p); + } + + public String getGroupName() { + return groupName; + } + + public List getRoutingParameters() { + return routingParameters; + } + + @Override + public String getText(MapActivity mapActivity) { + return SettingsBaseActivity.getRoutingStringPropertyName(mapActivity, groupName, + Algorithms.capitalizeFirstLetterAndLowercase(groupName.replace('_', ' '))); + } + + @Override + public boolean isSelected(OsmandSettings settings) { + return false; + } + + @Override + public void setSelected(OsmandSettings settings, boolean isChecked) { + } + + public LocalRoutingParameter getSelected(OsmandSettings settings) { + for (LocalRoutingParameter p : routingParameters) { + if (p.isSelected(settings)) { + return p; + } + } + return null; + } } private static class MuteSoundRoutingParameter extends LocalRoutingParameter { @@ -291,7 +347,73 @@ public class RoutePreferencesMenu { @Override public void onItemClick(AdapterView adapterView, View view, int item, long l) { Object obj = listAdapter.getItem(item); - if (obj instanceof OtherSettingsRoutingParameter) { + if (obj instanceof LocalRoutingParameterGroup) { + final LocalRoutingParameterGroup group = (LocalRoutingParameterGroup) obj; + final ContextMenuAdapter adapter = new ContextMenuAdapter(); + int i = 0; + int selectedIndex = -1; + for (LocalRoutingParameter p : group.getRoutingParameters()) { + adapter.addItem(ContextMenuItem.createBuilder(p.getText(mapActivity)) + .setSelected(false).createItem()); + if (p.isSelected(settings)) { + selectedIndex = i; + } + i++; + } + if (selectedIndex == -1) { + selectedIndex = 0; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); + final int layout = R.layout.list_menu_item_native_singlechoice; + + final ArrayAdapter listAdapter = new ArrayAdapter(mapActivity, layout, R.id.text1, + adapter.getItemNames()) { + @NonNull + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + // User super class to create the View + View v = convertView; + if (v == null) { + v = mapActivity.getLayoutInflater().inflate(layout, null); + } + final ContextMenuItem item = adapter.getItem(position); + TextView tv = (TextView) v.findViewById(R.id.text1); + tv.setText(item.getTitle()); + tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f); + + return v; + } + }; + + final int[] selectedPosition = {selectedIndex}; + builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int position) { + selectedPosition[0] = position; + } + }); + builder.setTitle(group.getText(mapActivity)) + .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + + int position = selectedPosition[0]; + if (position >= 0 && position < group.getRoutingParameters().size()) { + for (int i = 0; i < group.getRoutingParameters().size(); i++) { + LocalRoutingParameter rp = group.getRoutingParameters().get(i); + rp.setSelected(settings, i == position); + } + mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange(); + updateParameters(); + } + } + }) + .setNegativeButton(R.string.shared_string_cancel, null); + + builder.create().show(); + } else if (obj instanceof OtherSettingsRoutingParameter) { final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class); settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true); settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey()); @@ -460,33 +582,36 @@ public class RoutePreferencesMenu { View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null); AndroidUtils.setListItemBackground(mapActivity, v, nightMode); final TextView tv = (TextView) v.findViewById(R.id.title); + final TextView desc = (TextView) v.findViewById(R.id.description); final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item)); final LocalRoutingParameter rp = getItem(position); AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode); tv.setText(rp.getText(mapActivity)); ch.setOnCheckedChangeListener(null); - if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) { - // if short route settings - it should be inverse of fast_route_mode - ch.setChecked(!settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode())); - } else { - ch.setChecked(rp.isSelected(settings)); - } - ch.setVisibility(View.VISIBLE); - ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - // if short way that it should set valut to fast mode opposite of current - if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) { - settings.FAST_ROUTE_MODE.setModeValue(routingHelper.getAppMode(), !isChecked); - } - rp.setSelected(settings, isChecked); - - if (rp instanceof OtherLocalRoutingParameter) { - updateGpxRoutingParameter((OtherLocalRoutingParameter) rp); - } - mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange(); + if (rp instanceof LocalRoutingParameterGroup) { + LocalRoutingParameterGroup group = (LocalRoutingParameterGroup) rp; + AndroidUtils.setTextPrimaryColor(mapActivity, desc, nightMode); + LocalRoutingParameter selected = group.getSelected(settings); + if (selected != null) { + desc.setText(selected.getText(mapActivity)); + desc.setVisibility(View.VISIBLE); } - }); + ch.setVisibility(View.GONE); + } else { + if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) { + // if short route settings - it should be inverse of fast_route_mode + ch.setChecked(!settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode())); + } else { + ch.setChecked(rp.isSelected(settings)); + } + ch.setVisibility(View.VISIBLE); + ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + applyRoutingParameter(rp, isChecked); + } + }); + } return v; } }; @@ -494,6 +619,19 @@ public class RoutePreferencesMenu { return listAdapter; } + private void applyRoutingParameter(LocalRoutingParameter rp, boolean isChecked) { + // if short way that it should set valut to fast mode opposite of current + if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) { + settings.FAST_ROUTE_MODE.setModeValue(routingHelper.getAppMode(), !isChecked); + } + rp.setSelected(settings, isChecked); + + if (rp instanceof OtherLocalRoutingParameter) { + updateGpxRoutingParameter((OtherLocalRoutingParameter) rp); + } + mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange(); + } + private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) { RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); boolean selected = gpxParam.isSelected(settings); @@ -590,17 +728,38 @@ public class RoutePreferencesMenu { if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) { return list; } - for (GeneralRouter.RoutingParameter r : rm.getParameters().values()) { + for (RoutingParameter r : rm.getParameters().values()) { if (r.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) { - LocalRoutingParameter rp = new LocalRoutingParameter(am); - rp.routingParameter = r; - list.add(rp); + if ("relief_smoothness_factor".equals(r.getGroup())) { + continue; + } + if (!Algorithms.isEmpty(r.getGroup())) { + LocalRoutingParameterGroup rpg = getLocalRoutingParameterGroup(list, r.getGroup()); + if (rpg == null) { + rpg = new LocalRoutingParameterGroup(am, r.getGroup()); + list.add(rpg); + } + rpg.addRoutingParameter(r); + } else { + LocalRoutingParameter rp = new LocalRoutingParameter(am); + rp.routingParameter = r; + list.add(rp); + } } } return list; } + private LocalRoutingParameterGroup getLocalRoutingParameterGroup(List list, String groupName) { + for (LocalRoutingParameter p : list) { + if (p instanceof LocalRoutingParameterGroup && groupName.equals(((LocalRoutingParameterGroup) p).getGroupName())) { + return (LocalRoutingParameterGroup) p; + } + } + return null; + } + private void updateParameters() { //ApplicationMode am = settings.APPLICATION_MODE.get(); ApplicationMode am = routingHelper.getAppMode(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 93d3863875..9def324f1b 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -743,7 +743,7 @@ public class RouteProvider { Boolean bool = !settings.FAST_ROUTE_MODE.getModeValue(params.mode); vl = bool ? "true" : null; } else if(pr.getType() == RoutingParameterType.BOOLEAN) { - CommonPreference pref = settings.getCustomRoutingBooleanProperty(key); + CommonPreference pref = settings.getCustomRoutingBooleanProperty(key, pr.getDefaultBoolean()); Boolean bool = pref.getModeValue(params.mode); vl = bool ? "true" : null; } else {