Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-03-12 16:36:21 +01:00
commit 68c059b5ab
8 changed files with 362 additions and 59 deletions

View file

@ -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(); RoutingParameter rp = new RoutingParameter();
rp.group = group;
rp.name = name; rp.name = name;
rp.description = description; rp.description = description;
rp.id = id; rp.id = id;
rp.type = RoutingParameterType.BOOLEAN; rp.type = RoutingParameterType.BOOLEAN;
rp.defaultBoolean = defaultValue;
parameters.put(rp.id, rp); parameters.put(rp.id, rp);
} }
@ -435,16 +437,21 @@ public class GeneralRouter implements VehicleRouter {
public static class RoutingParameter { public static class RoutingParameter {
private String id; private String id;
private String group;
private String name; private String name;
private String description; private String description;
private RoutingParameterType type; private RoutingParameterType type;
private Object[] possibleValues; private Object[] possibleValues;
private String[] possibleValueDescriptions; private String[] possibleValueDescriptions;
private boolean defaultBoolean;
public String getId() { public String getId() {
return id; return id;
} }
public String getGroup() {
return group;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -457,10 +464,12 @@ public class GeneralRouter implements VehicleRouter {
public String[] getPossibleValueDescriptions() { public String[] getPossibleValueDescriptions() {
return possibleValueDescriptions; return possibleValueDescriptions;
} }
public Object[] getPossibleValues() { public Object[] getPossibleValues() {
return possibleValues; return possibleValues;
} }
public boolean getDefaultBoolean() {
return defaultBoolean;
}
} }

View file

@ -215,11 +215,13 @@ public class RoutingConfiguration {
private static void parseRoutingParameter(XmlPullParser parser, GeneralRouter currentRouter) { private static void parseRoutingParameter(XmlPullParser parser, GeneralRouter currentRouter) {
String description = parser.getAttributeValue("", "description"); String description = parser.getAttributeValue("", "description");
String group = parser.getAttributeValue("", "group");
String name = parser.getAttributeValue("", "name"); String name = parser.getAttributeValue("", "name");
String id = parser.getAttributeValue("", "id"); String id = parser.getAttributeValue("", "id");
String type = parser.getAttributeValue("", "type"); String type = parser.getAttributeValue("", "type");
if(type.equalsIgnoreCase("boolean")) { boolean defaultValue = Boolean.parseBoolean(parser.getAttributeValue("", "default"));
currentRouter.registerBooleanParameter(id, name, description); if (type.equalsIgnoreCase("boolean")) {
currentRouter.registerBooleanParameter(id, Algorithms.isEmpty(group) ? null : group, name, description, defaultValue);
} else if(type.equalsIgnoreCase("numeric")) { } else if(type.equalsIgnoreCase("numeric")) {
String values = parser.getAttributeValue("", "values"); String values = parser.getAttributeValue("", "values");
String valueDescriptions = parser.getAttributeValue("", "valueDescriptions"); String valueDescriptions = parser.getAttributeValue("", "valueDescriptions");

View file

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding"
@ -15,18 +16,33 @@
android:visibility="gone" android:visibility="gone"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_action_settings" /> android:src="@drawable/ic_action_settings" />
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="@string/layer_poi" android:text="@string/layer_poi"
android:textSize="@dimen/default_list_text_size" /> android:textSize="@dimen/default_list_text_size" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingLeft="16dp"
android:textSize="@dimen/default_list_text_size"
android:visibility="gone"/>
<CheckBox <CheckBox
android:id="@+id/toggle_item" android:id="@+id/toggle_item"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="relief_smoothness_factor_descr">More plains, balance, more hills</string>
<string name="shared_string_slope">Slope</string> <string name="shared_string_slope">Slope</string>
<string name="add_new_folder">Add new folder</string> <string name="add_new_folder">Add new folder</string>
<string name="points_delete_multiple_succesful">Point(s) deleted successfully.</string> <string name="points_delete_multiple_succesful">Point(s) deleted successfully.</string>

View file

@ -2724,9 +2724,9 @@ public class OsmandSettings {
Map<String, CommonPreference<Boolean>> customBooleanRoutingProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>(); Map<String, CommonPreference<Boolean>> customBooleanRoutingProps = new LinkedHashMap<String, OsmandSettings.CommonPreference<Boolean>>();
public CommonPreference<Boolean> getCustomRoutingBooleanProperty(String attrName) { public CommonPreference<Boolean> getCustomRoutingBooleanProperty(String attrName, boolean defaulfValue) {
if (!customBooleanRoutingProps.containsKey(attrName)) { 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); return customBooleanRoutingProps.get(attrName);
} }

View file

@ -3,6 +3,7 @@ package net.osmand.plus.activities;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener; import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent; import android.content.Intent;
@ -12,8 +13,17 @@ import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; 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.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DeviceAdminRecv; import net.osmand.plus.DeviceAdminRecv;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; 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;
import net.osmand.router.GeneralRouter.RoutingParameter; import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.router.GeneralRouter.RoutingParameterType; import net.osmand.router.GeneralRouter.RoutingParameterType;
import net.osmand.util.Algorithms;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -35,6 +46,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
private Preference avoidRouting; private Preference avoidRouting;
private Preference preferRouting; private Preference preferRouting;
private Preference reliefFactorRouting;
private Preference showAlarms; private Preference showAlarms;
private Preference speakAlarms; private Preference speakAlarms;
private ListPreference routerServicePreference; private ListPreference routerServicePreference;
@ -46,6 +58,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
private List<RoutingParameter> avoidParameters = new ArrayList<RoutingParameter>(); private List<RoutingParameter> avoidParameters = new ArrayList<RoutingParameter>();
private List<RoutingParameter> preferParameters = new ArrayList<RoutingParameter>(); private List<RoutingParameter> preferParameters = new ArrayList<RoutingParameter>();
private List<RoutingParameter> reliefFactorParameters = new ArrayList<RoutingParameter>();
public static final String INTENT_SKIP_DIALOG = "INTENT_SKIP_DIALOG"; public static final String INTENT_SKIP_DIALOG = "INTENT_SKIP_DIALOG";
public SettingsNavigationActivity() { public SettingsNavigationActivity() {
@ -238,12 +251,15 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
List<RoutingParameter> others = new ArrayList<GeneralRouter.RoutingParameter>(); List<RoutingParameter> others = new ArrayList<GeneralRouter.RoutingParameter>();
for(Map.Entry<String, RoutingParameter> e : parameters.entrySet()) { for(Map.Entry<String, RoutingParameter> e : parameters.entrySet()) {
String param = e.getKey(); String param = e.getKey();
if(param.startsWith("avoid_")) { RoutingParameter routingParameter = e.getValue();
avoidParameters.add(e.getValue()); if (param.startsWith("avoid_")) {
} else if(param.startsWith("prefer_")) { avoidParameters.add(routingParameter);
preferParameters.add(e.getValue()); } else if (param.startsWith("prefer_")) {
} else if(!param.equals("short_way")) { preferParameters.add(routingParameter);
others.add(e.getValue()); } 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) { if (avoidParameters.size() > 0) {
@ -260,10 +276,18 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
preferRouting.setOnPreferenceClickListener(this); preferRouting.setOnPreferenceClickListener(this);
cat.addPreference(preferRouting); 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) { for(RoutingParameter p : others) {
Preference basePref; Preference basePref;
if(p.getType() == RoutingParameterType.BOOLEAN) { if(p.getType() == RoutingParameterType.BOOLEAN) {
basePref = createCheckBoxPreference(settings.getCustomRoutingBooleanProperty(p.getId())); basePref = createCheckBoxPreference(settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()));
} else { } else {
Object[] vls = p.getPossibleValues(); Object[] vls = p.getPossibleValues();
String[] svlss = new String[vls.length]; 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<Boolean> 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<Boolean> property =
settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
if(am != null) {
property.setModeValue(am, isChecked);
} else {
property.set(isChecked);
}
}
private void clearParameters() { private void clearParameters() {
preferParameters.clear(); preferParameters.clear();
@ -349,13 +398,80 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
List<RoutingParameter> prms = preference == avoidRouting ? avoidParameters : preferParameters; List<RoutingParameter> prms = preference == avoidRouting ? avoidParameters : preferParameters;
String[] vals = new String[prms.size()]; String[] vals = new String[prms.size()];
OsmandPreference[] bls = new OsmandPreference[prms.size()]; OsmandPreference[] bls = new OsmandPreference[prms.size()];
for(int i = 0; i < prms.size(); i++) { for (int i = 0; i < prms.size(); i++) {
RoutingParameter p = prms.get(i); RoutingParameter p = prms.get(i);
vals[i] = SettingsBaseActivity.getRoutingStringPropertyName(this, p.getId(), p.getName()); 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()); showBooleanSettings(vals, bls, preference.getTitle());
return true; 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<String> listAdapter = new ArrayAdapter<String>(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) { } else if (preference == showAlarms) {
showBooleanSettings(new String[] { getString(R.string.show_traffic_warnings), getString(R.string.show_pedestrian_warnings), 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, getString(R.string.show_cameras), getString(R.string.show_lanes) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS,

View file

@ -3,8 +3,10 @@ package net.osmand.plus.mapcontextmenu.other;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.util.TypedValue;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -41,6 +43,8 @@ import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.io.File; import java.io.File;
@ -70,7 +74,7 @@ public class RoutePreferencesMenu {
public static class LocalRoutingParameter { public static class LocalRoutingParameter {
public GeneralRouter.RoutingParameter routingParameter; public RoutingParameter routingParameter;
private ApplicationMode am; private ApplicationMode am;
public LocalRoutingParameter(ApplicationMode am) { public LocalRoutingParameter(ApplicationMode am) {
@ -83,8 +87,8 @@ public class RoutePreferencesMenu {
} }
public boolean isSelected(OsmandSettings settings) { public boolean isSelected(OsmandSettings settings) {
final OsmandSettings.CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(routingParameter final OsmandSettings.CommonPreference<Boolean> property =
.getId()); settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
if(am != null) { if(am != null) {
return property.getModeValue(am); return property.getModeValue(am);
} else { } else {
@ -93,8 +97,8 @@ public class RoutePreferencesMenu {
} }
public void setSelected(OsmandSettings settings, boolean isChecked) { public void setSelected(OsmandSettings settings, boolean isChecked) {
final OsmandSettings.CommonPreference<Boolean> property = settings.getCustomRoutingBooleanProperty(routingParameter final OsmandSettings.CommonPreference<Boolean> property =
.getId()); settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
if(am != null) { if(am != null) {
property.setModeValue(am, isChecked); property.setModeValue(am, isChecked);
} else { } else {
@ -102,6 +106,58 @@ public class RoutePreferencesMenu {
} }
} }
public ApplicationMode getApplicationMode() {
return am;
}
}
private static class LocalRoutingParameterGroup extends LocalRoutingParameter {
private String groupName;
private List<LocalRoutingParameter> 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<LocalRoutingParameter> 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 { private static class MuteSoundRoutingParameter extends LocalRoutingParameter {
@ -291,7 +347,73 @@ public class RoutePreferencesMenu {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
Object obj = listAdapter.getItem(item); 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<String> listAdapter = new ArrayAdapter<String>(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); final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true); settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey()); settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
@ -460,11 +582,22 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final TextView tv = (TextView) v.findViewById(R.id.title); 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 CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
final LocalRoutingParameter rp = getItem(position); final LocalRoutingParameter rp = getItem(position);
AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
tv.setText(rp.getText(mapActivity)); tv.setText(rp.getText(mapActivity));
ch.setOnCheckedChangeListener(null); ch.setOnCheckedChangeListener(null);
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 (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) {
// if short route settings - it should be inverse of fast_route_mode // if short route settings - it should be inverse of fast_route_mode
ch.setChecked(!settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode())); ch.setChecked(!settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode()));
@ -475,6 +608,18 @@ public class RoutePreferencesMenu {
ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { ch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
applyRoutingParameter(rp, isChecked);
}
});
}
return v;
}
};
return listAdapter;
}
private void applyRoutingParameter(LocalRoutingParameter rp, boolean isChecked) {
// if short way that it should set valut to fast mode opposite of current // if short way that it should set valut to fast mode opposite of current
if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) { if (rp.routingParameter != null && rp.routingParameter.getId().equals("short_way")) {
settings.FAST_ROUTE_MODE.setModeValue(routingHelper.getAppMode(), !isChecked); settings.FAST_ROUTE_MODE.setModeValue(routingHelper.getAppMode(), !isChecked);
@ -486,13 +631,6 @@ public class RoutePreferencesMenu {
} }
mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange(); mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange();
} }
});
return v;
}
};
return listAdapter;
}
private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) { private void updateGpxRoutingParameter(OtherLocalRoutingParameter gpxParam) {
RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
@ -590,17 +728,38 @@ public class RoutePreferencesMenu {
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) { if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
return list; return list;
} }
for (GeneralRouter.RoutingParameter r : rm.getParameters().values()) { for (RoutingParameter r : rm.getParameters().values()) {
if (r.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) { if (r.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
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); LocalRoutingParameter rp = new LocalRoutingParameter(am);
rp.routingParameter = r; rp.routingParameter = r;
list.add(rp); list.add(rp);
} }
} }
}
return list; return list;
} }
private LocalRoutingParameterGroup getLocalRoutingParameterGroup(List<LocalRoutingParameter> list, String groupName) {
for (LocalRoutingParameter p : list) {
if (p instanceof LocalRoutingParameterGroup && groupName.equals(((LocalRoutingParameterGroup) p).getGroupName())) {
return (LocalRoutingParameterGroup) p;
}
}
return null;
}
private void updateParameters() { private void updateParameters() {
//ApplicationMode am = settings.APPLICATION_MODE.get(); //ApplicationMode am = settings.APPLICATION_MODE.get();
ApplicationMode am = routingHelper.getAppMode(); ApplicationMode am = routingHelper.getAppMode();

View file

@ -743,7 +743,7 @@ public class RouteProvider {
Boolean bool = !settings.FAST_ROUTE_MODE.getModeValue(params.mode); Boolean bool = !settings.FAST_ROUTE_MODE.getModeValue(params.mode);
vl = bool ? "true" : null; vl = bool ? "true" : null;
} else if(pr.getType() == RoutingParameterType.BOOLEAN) { } else if(pr.getType() == RoutingParameterType.BOOLEAN) {
CommonPreference<Boolean> pref = settings.getCustomRoutingBooleanProperty(key); CommonPreference<Boolean> pref = settings.getCustomRoutingBooleanProperty(key, pr.getDefaultBoolean());
Boolean bool = pref.getModeValue(params.mode); Boolean bool = pref.getModeValue(params.mode);
vl = bool ? "true" : null; vl = bool ? "true" : null;
} else { } else {