Move road style to Map Settings

This commit is contained in:
Alexey Kulish 2017-04-04 11:09:44 +03:00
parent c983e6b24e
commit 830bb962fa

View file

@ -77,6 +77,7 @@ public class ConfigureMapMenu {
public static final String CURRENT_TRACK_COLOR_ATTR = "currentTrackColor";
public static final String CURRENT_TRACK_WIDTH_ATTR = "currentTrackWidth";
public static final String COLOR_ATTR = "color";
public static final String ROAD_STYLE_ATTR = "roadStyle";
private int hikingRouteOSMCValue;
private int selectedLanguageIndex;
private boolean transliterateNames;
@ -633,6 +634,12 @@ public class ConfigureMapMenu {
}
}).createItem());
ContextMenuItem props;
props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR);
if (props != null) {
adapter.addItem(props);
}
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.text_size, activity)
.setDescription(getScale(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_text_size).setListener(new ContextMenuAdapter.ItemClickListener() {
@ -761,7 +768,6 @@ public class ConfigureMapMenu {
}
}).createItem());
ContextMenuItem props;
props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark,
"transport", null, adapter, activity, true);
if (props != null) {
@ -1143,24 +1149,42 @@ public class ConfigureMapMenu {
private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity,
List<RenderingRuleProperty> customRules) {
final OsmandMapTileView view = activity.getMapView();
for (final RenderingRuleProperty p : customRules) {
if (p.getAttrName().equals(RenderingRuleStorageProperties.A_APP_MODE) ||
p.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1) ||
p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR) ||
p.getAttrName().equals(ROAD_STYLE_ATTR) ||
p.getAttrName().equals(CURRENT_TRACK_COLOR_ATTR) ||
p.getAttrName().equals(CURRENT_TRACK_WIDTH_ATTR)) {
continue;
}
adapter.addItem(createRenderingProperty(adapter, activity, 0, p));
}
}
private ContextMenuItem createRenderingProperty(final List<RenderingRuleProperty> customRules,
final ContextMenuAdapter adapter, final MapActivity activity,
@DrawableRes final int icon, final String attrName) {
for (final RenderingRuleProperty p : customRules) {
if (p.getAttrName().equals(attrName)) {
return createRenderingProperty(adapter, activity, icon, p);
}
}
return null;
}
private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity,
@DrawableRes final int icon, final RenderingRuleProperty p) {
final OsmandMapTileView view = activity.getMapView();
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
p.getName());
// test old descr as title
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(),
p.getAttrName(), p.getName());
if (p.isBoolean()) {
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName());
adapter.addItem(ContextMenuItem.createBuilder(propertyName)
return ContextMenuItem.createBuilder(propertyName)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -1171,7 +1195,7 @@ public class ConfigureMapMenu {
}
})
.setSelected(pref.get())
.createItem());
.createItem();
} else {
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
@ -1182,7 +1206,8 @@ public class ConfigureMapMenu {
descr = SettingsActivity.getStringPropertyValue(view.getContext(),
p.getDefaultValueDescription());
}
adapter.addItem(ContextMenuItem.createBuilder(propertyName).setListener(new ContextMenuAdapter.ItemClickListener() {
ContextMenuItem.ItemBuilder builder = ContextMenuItem.createBuilder(propertyName)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
@ -1225,8 +1250,14 @@ public class ConfigureMapMenu {
b.show();
return false;
}
}).setDescription(descr).setLayout(R.layout.list_item_single_line_descrition_narrow).createItem());
})
.setDescription(descr)
.setLayout(R.layout.list_item_single_line_descrition_narrow);
if (icon != 0) {
builder.setIcon(icon);
}
return builder.createItem();
}
}