diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 5ad4ed0a5b..77bb5a012a 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -49,6 +49,7 @@ import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuItem; +import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -581,11 +582,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { + final int defaultColor = IconsCache.getDefaultColorRes(mapActivity); ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { if (itemId == R.string.layer_recordings) { SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get()); + adapter.getItem(pos).setColorRes(SHOW_RECORDINGS.get() ? + R.color.osmand_orange : defaultColor); + adapter.notifyDataSetChanged(); updateLayers(mapView, mapActivity); } return true; @@ -594,6 +599,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_recordings, app) .setSelected(SHOW_RECORDINGS.get()) .setIcon(R.drawable.ic_action_micro_dark) + .setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : defaultColor) .setPosition(12) .setListener(listener).createItem()); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index df6cdcd041..eaa23f1cf1 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -4,11 +4,13 @@ import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnMultiChoiceClickListener; import android.content.Intent; +import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.annotation.StringRes; import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.ArrayAdapter; +import android.widget.CompoundButton; import android.widget.Toast; import net.osmand.PlatformUtil; @@ -19,6 +21,7 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -82,10 +85,12 @@ public class ConfigureMapMenu { private final class LayerMenuListener extends OnRowItemClick { private MapActivity ma; private ContextMenuAdapter cm; + @ColorRes final int defaultColor; private LayerMenuListener(MapActivity ma, ContextMenuAdapter cm) { this.ma = ma; this.cm = cm; + defaultColor = IconsCache.getDefaultColorRes(ma); } private List getAlreadySelectedGpx() { @@ -107,13 +112,26 @@ public class ConfigureMapMenu { ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView()); return false; } else { - return super.onRowItemClick(adapter, view, itemId, pos); + CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item); + if (btn != null && btn.getVisibility() == View.VISIBLE) { + btn.setChecked(!btn.isChecked()); + cm.getItem(pos).setColorRes(btn.isChecked() ? R.color.osmand_orange : defaultColor); + adapter.notifyDataSetChanged(); + return false; + } else { + return onContextMenuClick(adapter, itemId, pos, false); + } } } @Override public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) { final OsmandSettings settings = ma.getMyApplication().getSettings(); + final ContextMenuItem item = cm.getItem(pos); + if (item.getSelected() != null) { + item.setColorRes(isChecked ? R.color.osmand_orange : defaultColor); + adapter.notifyDataSetChanged(); + } if (itemId == R.string.layer_poi) { settings.SELECTED_POI_FILTER_FOR_MAP.set(null); if (isChecked) { @@ -134,7 +152,8 @@ public class ConfigureMapMenu { public void onDismiss(DialogInterface dialog) { boolean areAnyGpxTracksVisible = ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles(); - cm.getItem(pos).setSelected(areAnyGpxTracksVisible); + item.setSelected(areAnyGpxTracksVisible); + item.setColorRes(areAnyGpxTracksVisible ? R.color.osmand_orange : defaultColor); adapter.notifyDataSetChanged(); } }); @@ -169,6 +188,7 @@ public class ConfigureMapMenu { } private void createLayersItems(ContextMenuAdapter adapter, MapActivity activity) { + @ColorRes final int defaultColor = IconsCache.getDefaultColorRes(activity); OsmandApplication app = activity.getMyApplication(); OsmandSettings settings = app.getSettings(); LayerMenuListener l = new LayerMenuListener(activity, adapter); @@ -176,25 +196,33 @@ public class ConfigureMapMenu { .setTitleId(R.string.shared_string_show, activity) .setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem()); // String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] "; - adapter.addItem(new ContextMenuItem.ItemBuilder() - .setTitleId(R.string.layer_poi, activity) - .setSelected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null) - .setIcon(R.drawable.ic_action_info_dark) - .setSecondaryIcon(R.drawable.ic_action_additional_option) - .setListener(l).createItem()); - adapter.addItem(new ContextMenuItem.ItemBuilder() - .setTitleId(R.string.layer_amenity_label, activity) - .setSelected(settings.SHOW_POI_LABEL.get()) - .setIcon(R.drawable.ic_action_text_dark) - .setListener(l).createItem()); + boolean selected = settings.SHOW_FAVORITES.get(); adapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.shared_string_favorites, activity) .setSelected(settings.SHOW_FAVORITES.get()) + .setColor(selected ? R.color.osmand_orange : defaultColor) .setIcon(R.drawable.ic_action_fav_dark) .setListener(l).createItem()); + selected = settings.SELECTED_POI_FILTER_FOR_MAP.get() != null; + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(R.string.layer_poi, activity) + .setSelected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null) + .setColor(selected ? R.color.osmand_orange : defaultColor) + .setIcon(R.drawable.ic_action_info_dark) + .setSecondaryIcon(R.drawable.ic_action_additional_option) + .setListener(l).createItem()); + selected = settings.SHOW_POI_LABEL.get(); + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(R.string.layer_amenity_label, activity) + .setSelected(settings.SHOW_POI_LABEL.get()) + .setColor(selected ? R.color.osmand_orange : defaultColor) + .setIcon(R.drawable.ic_action_text_dark) + .setListener(l).createItem()); + selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles(); adapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.layer_gpx_layer, activity) .setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles()) + .setColor(selected ? R.color.osmand_orange : defaultColor) .setIcon(R.drawable.ic_action_polygom_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(l).createItem()); @@ -203,9 +231,11 @@ public class ConfigureMapMenu { .setIcon(R.drawable.ic_world_globe_dark) .setListener(l).createItem()); if (TransportRouteHelper.getInstance().routeIsCalculated()) { + selected = true; adapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.layer_transport_route, activity) .setSelected(true) + .setColor(selected ? R.color.osmand_orange : defaultColor) .setIcon(R.drawable.ic_action_bus_dark) .setListener(l).createItem()); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index d78d616c1f..9ffa99379c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -22,6 +22,7 @@ import net.osmand.osm.edit.Node; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuItem; +import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -257,15 +258,21 @@ public class OsmEditingPlugin extends OsmandPlugin { @Override public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { + final int defaultColor = IconsCache.getDefaultColorRes(mapActivity); adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_osm_bugs, mapActivity) .setSelected(settings.SHOW_OSM_BUGS.get()) .setIcon(R.drawable.ic_action_bug_dark) + .setColor(settings.SHOW_OSM_BUGS.get() ? R.color.osmand_orange : defaultColor) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { if (itemId == R.string.layer_osm_bugs) { - settings.SHOW_OSM_BUGS.set(isChecked); + OsmandSettings.OsmandPreference showOsmBugs = settings.SHOW_OSM_BUGS; + showOsmBugs.set(isChecked); + adapter.getItem(pos).setColorRes(showOsmBugs.get() ? + R.color.osmand_orange : defaultColor); + adapter.notifyDataSetChanged(); updateLayers(mapActivity.getMapView(), mapActivity); } return true; diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 23a79411f9..c6c2c2d0d4 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -25,6 +25,7 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuItem; +import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -235,6 +236,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { + final int defaultColor = IconsCache.getDefaultColorRes(mapActivity); + final MapActivityLayers layers = mapActivity.getMapLayers(); ContextMenuAdapter.ItemClickListener listener = new ItemClickListener() { @Override @@ -259,6 +262,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_overlay, mapActivity) .setDescription(overlayMapDescr) .setSelected(hasOverlayDescription) + .setColor(hasOverlayDescription ? R.color.osmand_orange : defaultColor) .setIcon(R.drawable.ic_layer_top_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener) @@ -270,6 +274,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_underlay, mapActivity) .setDescription(underlayMapDescr) .setSelected(hasUnderlayDescription) + .setColor(hasUnderlayDescription ? R.color.osmand_orange : defaultColor) .setIcon(R.drawable.ic_layer_bottom_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener) diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index 5a89098365..22e302d78f 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -7,6 +7,7 @@ import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuItem; +import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -105,11 +106,15 @@ public class SRTMPlugin extends OsmandPlugin { @Override public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { + final int defaultColor = IconsCache.getDefaultColorRes(mapActivity); ItemClickListener listener = new ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { if (itemId == R.string.layer_hillshade) { HILLSHADE.set(!HILLSHADE.get()); + adapter.getItem(pos).setColorRes(HILLSHADE.get() ? R.color.osmand_orange + : defaultColor); + adapter.notifyDataSetChanged(); updateLayers(mapView, mapActivity); } return true; @@ -118,6 +123,7 @@ public class SRTMPlugin extends OsmandPlugin { adapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.layer_hillshade, mapActivity) .setSelected(HILLSHADE.get()) + .setColor(HILLSHADE.get() ? R.color.osmand_orange : defaultColor) .setIcon(R.drawable.ic_action_hillshade_dark) .setListener(listener) .setPosition(13)