diff --git a/OsmAnd/res/layout/drawer_list_header.xml b/OsmAnd/res/layout/drawer_list_header.xml index 5ee351dfe1..82d7bee642 100644 --- a/OsmAnd/res/layout/drawer_list_header.xml +++ b/OsmAnd/res/layout/drawer_list_header.xml @@ -9,7 +9,7 @@ android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"/> - - + - - - - + - - diff --git a/OsmAnd/res/layout/drawer_list_sub_header.xml b/OsmAnd/res/layout/drawer_list_sub_header.xml index cba82a02e8..3b786b85b2 100644 --- a/OsmAnd/res/layout/drawer_list_sub_header.xml +++ b/OsmAnd/res/layout/drawer_list_sub_header.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="16dp"> - itemDescription = new ArrayList(); public ContextMenuAdapter(Context ctx) { this.ctx = ctx; @@ -64,10 +61,18 @@ public class ContextMenuAdapter { public String getItemName(int pos){ return itemNames.get(pos); } + + public String getItemDescr(int pos){ + return itemDescription.get(pos); + } public void setItemName(int pos, String str) { itemNames.set(pos, str); } + + public void setItemDescription(int pos, String str) { + itemDescription.set(pos, str); + } public int getSelection(int pos) { return selectedList.get(pos); @@ -120,6 +125,7 @@ public class ContextMenuAdapter { int layout = -1; boolean cat; int pos = -1; + String description = ""; private OnContextMenuClick listener; private Item() { @@ -151,6 +157,11 @@ public class ContextMenuAdapter { return this; } + public Item description(String descr){ + this.description = descr; + return this; + } + public Item listen(OnContextMenuClick l) { this.listener = l; return this; @@ -163,6 +174,7 @@ public class ContextMenuAdapter { } items.insert(pos, id); itemNames.add(pos, name); + itemDescription.add(pos, description); selectedList.insert(pos, selected); layoutIds.insert(pos, layout); iconList.insert(pos, icon); @@ -219,11 +231,12 @@ public class ContextMenuAdapter { TextView tv = (TextView) v.findViewById(R.id.title); tv.setText(getItemName(position)); - // Put the image on the TextView - if (getImageId(position, holoLight) != 0) { - tv.setCompoundDrawablesWithIntrinsicBounds(getImageId(position, holoLight), 0, 0, 0); - } else { - tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_transparent, 0, 0, 0); + int imageId = getImageId(position, holoLight); + if (imageId != 0) { + ((ImageView) v.findViewById(R.id.icon)).setImageResource(imageId); + v.findViewById(R.id.icon).setVisibility(View.VISIBLE); + } else if (v.findViewById(R.id.icon) != null){ + v.findViewById(R.id.icon).setVisibility(View.GONE); } tv.setCompoundDrawablePadding(padding); @@ -249,9 +262,14 @@ public class ContextMenuAdapter { } }); ch.setVisibility(View.VISIBLE); - } else { + } else if (ch != null) { ch.setVisibility(View.GONE); } + + String itemDescr = getItemDescr(position); + if (v.findViewById(R.id.descr) != null){ + ((TextView)v.findViewById(R.id.descr)).setText(itemDescr); + } return v; } }; diff --git a/OsmAnd/src/net/osmand/plus/configuremap/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/configuremap/ConfigureMapMenu.java index 94462e8368..6f41cfacd6 100644 --- a/OsmAnd/src/net/osmand/plus/configuremap/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/configuremap/ConfigureMapMenu.java @@ -91,24 +91,24 @@ public class ConfigureMapMenu { OsmandApplication app = activity.getMyApplication(); OsmandSettings settings = app.getSettings(); LayerMenuListener l = new LayerMenuListener(activity); - adapter.item(R.string.layers_category_show).setCategory(true).reg(); + adapter.item(R.string.layers_category_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg(); // String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] "; adapter.item(R.string.layer_poi).selected(settings.SHOW_POI_OVER_MAP.get() ? 1 : 0) - .icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).listen(l).reg(); + .icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).listen(l).layout(R.layout.drawer_list_layer).reg(); adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0) - .icons(R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light).listen(l).reg(); + .icons(R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light).listen(l).layout(R.layout.drawer_list_layer).reg(); adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0) - .icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).listen(l).reg(); + .icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).listen(l).layout(R.layout.drawer_list_layer).reg(); adapter.item(R.string.layer_gpx_layer).selected( - app.getSelectedGpxHelper().isShowingAnyGpxFiles()? 1 : 0) + app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0) // .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light) .icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light) - .listen(l).reg(); - adapter.item(R.string.layer_transport).selected( settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0) - .icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).reg(); + .listen(l).layout(R.layout.drawer_list_layer).reg(); + adapter.item(R.string.layer_transport).selected(settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0) + .icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).layout(R.layout.drawer_list_layer).reg(); if(TransportRouteHelper.getInstance().routeIsCalculated()){ adapter.item(R.string.layer_transport_route).selected(1) - .icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).reg(); + .icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).layout(R.layout.drawer_list_layer).reg(); } OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity); @@ -120,8 +120,8 @@ public class ConfigureMapMenu { activity.getMapView().refreshMap(true); } - private void createRenderingAttributeItems(ContextMenuAdapter adapter, final MapActivity activity) { - adapter.item(R.string.map_widget_map_rendering).setCategory(true).reg(); + private void createRenderingAttributeItems(final ContextMenuAdapter adapter, final MapActivity activity) { + adapter.item(R.string.map_widget_map_rendering).setCategory(true).layout(R.layout.drawer_list_sub_header).reg(); adapter.item(R.string.map_widget_renderer).listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) { @@ -160,9 +160,9 @@ public class ConfigureMapMenu { bld.show(); return false; } - }).reg(); + }).layout(R.layout.drawer_list_rendering).reg(); - adapter.item(R.string.map_widget_day_night).listen(new OnContextMenuClick() { + adapter.item(R.string.map_widget_day_night).description(activity.getMyApplication().getSettings().DAYNIGHT_MODE.get().toHumanString(activity)).listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) { final OsmandMapTileView view = activity.getMapView(); @@ -184,7 +184,7 @@ public class ConfigureMapMenu { bld.show(); return false; } - }).reg(); + }).layout(R.layout.drawer_list_rendering).reg(); adapter.item(R.string.text_size).listen(new OnContextMenuClick() { @Override @@ -193,7 +193,7 @@ public class ConfigureMapMenu { AlertDialog.Builder b = new AlertDialog.Builder(view.getContext()); // test old descr as title b.setTitle(R.string.text_size); - final Float[] txtValues = new Float[] { 0.75f, 1f, 1.25f, 1.5f, 2f, 3f }; + final Float[] txtValues = new Float[]{0.75f, 1f, 1.25f, 1.5f, 2f, 3f}; int selected = -1; final String[] txtNames = new String[txtValues.length]; for (int i = 0; i < txtNames.length; i++) { @@ -212,7 +212,7 @@ public class ConfigureMapMenu { b.show(); return false; } - }).reg(); + }).layout(R.layout.drawer_list_rendering).reg(); RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer(); if (renderer != null) { @@ -223,7 +223,7 @@ public class ConfigureMapMenu { private void createCustomRenderingProperties(RenderingRulesStorage renderer, ContextMenuAdapter adapter , final MapActivity activity){ final OsmandMapTileView view = activity.getMapView(); - adapter.item(R.string.map_widget_vector_attributes).setCategory(true).reg(); + adapter.item(R.string.map_widget_vector_attributes).setCategory(true).layout(R.layout.drawer_list_sub_header).reg(); final OsmandApplication app = view.getApplication(); List customRules = renderer.PROPS.getCustomRules(); for (final RenderingRuleProperty p : customRules) { @@ -236,19 +236,19 @@ public class ConfigureMapMenu { final OsmandSettings.CommonPreference pref = view.getApplication().getSettings() .getCustomRenderBooleanProperty(p.getAttrName()); adapter.item(propertyName).listen(new OnContextMenuClick() { - + @Override public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) { pref.set(!pref.get()); refreshMapComplete(activity); return false; } - }).selected(pref.get() ? 1 : 0).reg(); + }).selected(pref.get() ? 1 : 0).layout(R.layout.drawer_list_rendering).reg(); } else { final OsmandSettings.CommonPreference pref = view.getApplication().getSettings() .getCustomRenderProperty(p.getAttrName()); adapter.item(propertyName).listen(new OnContextMenuClick() { - + @Override public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) { AlertDialog.Builder b = new AlertDialog.Builder(view.getContext()); @@ -276,7 +276,7 @@ public class ConfigureMapMenu { b.show(); return false; } - }).reg(); + }).layout(R.layout.drawer_list_rendering).reg(); } } } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index a69cb056a6..6512b494e8 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -103,7 +103,7 @@ public class SRTMPlugin extends OsmandPlugin { } }; adapter.item(R.string.layer_hillshade).selected(HILLSHADE.get()? 1 : 0) - .icons( R.drawable.ic_action_hillshade_dark, R.drawable.ic_action_hillshade_light).listen(listener).position(9).reg(); + .icons( R.drawable.ic_action_hillshade_dark, R.drawable.ic_action_hillshade_light).listen(listener).position(9).layout(R.layout.drawer_list_layer).reg(); } @Override