diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index da7d276afb..d7355cd6a5 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 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 --> + Show closed notes + Show/Hide OSM Notes on the map. GPX - suitable for export to JOSM or other OSM editors. OSC - suitable for export to OpenStreetMap. GPX file diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 9b7c0012ae..411748abec 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1161,6 +1161,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 CommonPreference SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeGlobal(); public final CommonPreference MAP_INFO_CONTROLS = new StringPreference("map_info_controls", "").makeProfile(); { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index c84a7aa825..37670867f0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -127,7 +127,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider List fullObjects = new ArrayList<>(); List fullObjectsLatLon = new ArrayList<>(); List smallObjectsLatLon = new ArrayList<>(); + boolean showClosed = activity.getMyApplication().getSettings().SHOW_CLOSED_OSM_BUGS.get(); for (OpenStreetNote o : objects) { + if (!o.isOpened() && !showClosed) { + continue; + } float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); @@ -146,6 +150,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } } for (OpenStreetNote o : fullObjects) { + if (!o.isOpened() && !showClosed) { + continue; + } float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); Bitmap b; @@ -200,9 +207,13 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider final int rad = getRadiusBug(tb); int radius = rad * 3 / 2; int small = rad * 3 / 4; + boolean showClosed = activity.getMyApplication().getSettings().SHOW_CLOSED_OSM_BUGS.get(); try { for (int i = 0; i < objects.size(); i++) { OpenStreetNote n = objects.get(i); + if (!n.isOpened() && !showClosed) { + continue; + } int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude()); int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude()); if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java index 6b87268520..6b548f03e5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java @@ -1,6 +1,14 @@ package net.osmand.plus.osmedit; +import android.widget.ArrayAdapter; +import android.widget.Toast; + import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.ContextMenuItem; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.OsmandSettings.CommonPreference; +import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -14,6 +22,65 @@ public class OsmNotesMenu { } private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) { + final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); + final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (plugin == null) { + return; + } + + final int osmNotesStringId = R.string.layer_osm_bugs; + final int showZoomLevelStringId = R.string.show_from_zoom_level; + final int showClosedNotesStringId = R.string.show_closed_notes; + + final OsmandPreference showOsmBugsPref = settings.SHOW_OSM_BUGS; + final CommonPreference showClosedOsmBugsPref = settings.SHOW_CLOSED_OSM_BUGS; + + ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, + int position, boolean isChecked, int[] viewCoordinates) { + if (itemId == osmNotesStringId) { + showOsmBugsPref.set(isChecked); + plugin.updateLayers(mapActivity.getMapView(), mapActivity); + mapActivity.refreshMap(); + } else if (itemId == showZoomLevelStringId) { + Toast.makeText(mapActivity, "show zoom level", Toast.LENGTH_SHORT).show(); //todo + } else if (itemId == showClosedNotesStringId) { + showClosedOsmBugsPref.set(isChecked); + mapActivity.refreshMap(); + } + return false; + } + }; + + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(osmNotesStringId, mapActivity) + .setDescription(mapActivity.getString(R.string.switch_osm_notes_visibility_desc)) + .setIcon(R.drawable.ic_action_bug_dark) + .setListener(l) + .setSelected(showOsmBugsPref.get()) + .createItem()); + + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(showZoomLevelStringId, mapActivity) + .setDescription("11") //todo + .setLayout(R.layout.list_item_single_line_descrition_narrow) + .setIcon(R.drawable.ic_action_map_magnifier) + .setListener(l) + .createItem()); + + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(showClosedNotesStringId, mapActivity) + .setIcon(R.drawable.ic_action_note_dark) + .setListener(l) + .setSelected(showClosedOsmBugsPref.get()) + .hideDivider(true) + .createItem()); + + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setLayout(R.layout.card_bottom_divider) + .setClickable(false) + .createItem()); } }