diff --git a/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java b/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java index 6b8ca44bfe..a863364318 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/OsmAndCustomizationConstants.java @@ -40,6 +40,7 @@ public interface OsmAndCustomizationConstants { String RECORDING_LAYER = SHOW_ITEMS_ID_SCHEME + "recording_layer"; String MAPILLARY = SHOW_ITEMS_ID_SCHEME + "mapillary"; String OSM_NOTES = SHOW_ITEMS_ID_SCHEME + "osm_notes"; + String OSM_EDITS = SHOW_ITEMS_ID_SCHEME + "osm_edits"; String OVERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "overlay_map"; String UNDERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "underlay_map"; String CONTOUR_LINES = SHOW_ITEMS_ID_SCHEME + "contour_lines"; diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 01e2934cf2..92fcb2ef80 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + OSM Edits You can apply this change to all profiles or only to selected. Shared Prefer unpaved roads diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index b44add42a8..7580a69044 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1707,6 +1707,7 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeGlobal(); + public final OsmandPreference SHOW_OSM_EDITS = new BooleanPreference("show_osm_edits", true).makeProfile().cache(); public final CommonPreference SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeGlobal(); public final CommonPreference SHOW_OSM_BUGS_MIN_ZOOM = new IntPreference("show_osm_bugs_min_zoom", 8).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 80eb92b415..e6bbe9ea4a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -52,6 +52,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_M import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MODIFY_OSM_NOTE; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MODIFY_POI; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE; +import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES; @@ -140,8 +141,12 @@ public class OsmEditingPlugin extends OsmandPlugin { if (osmBugsLayer == null) { registerLayers(activity); } - if (!mapView.getLayers().contains(osmEditsLayer)) { - activity.getMapView().addLayer(osmEditsLayer, 3.5f); + if (mapView.getLayers().contains(osmEditsLayer) != settings.SHOW_OSM_EDITS.get()) { + if (settings.SHOW_OSM_EDITS.get()) { + mapView.addLayer(osmEditsLayer, 3.5f); + } else { + mapView.removeLayer(osmEditsLayer); + } } if (mapView.getLayers().contains(osmBugsLayer) != settings.SHOW_OSM_BUGS.get()) { if (settings.SHOW_OSM_BUGS.get()) { @@ -338,6 +343,28 @@ public class OsmEditingPlugin extends OsmandPlugin { }) .setPosition(16) .createItem()); + + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(OSM_EDITS) + .setTitleId(R.string.layer_osm_edits, mapActivity) + .setSelected(settings.SHOW_OSM_EDITS.get()) + .setIcon(R.drawable.ic_action_openstreetmap_logo) + .setColor(settings.SHOW_OSM_EDITS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setListener(new ContextMenuAdapter.OnRowItemClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { + if (itemId == R.string.layer_osm_edits) { + OsmandSettings.OsmandPreference showOsmEdits = settings.SHOW_OSM_EDITS; + showOsmEdits.set(isChecked); + adapter.getItem(pos).setColorRes(showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); + adapter.notifyDataSetChanged(); + updateLayers(mapActivity.getMapView(), mapActivity); + } + return true; + } + }) + .setPosition(17) + .createItem()); } @Override