Add items to osm notes menu; add functionality for show/hide closed notes and notes in general
This commit is contained in:
parent
9dbe9c1c7e
commit
8ae1c4f910
4 changed files with 81 additions and 0 deletions
|
@ -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
|
||||
-->
|
||||
<string name="show_closed_notes">Show closed notes</string>
|
||||
<string name="switch_osm_notes_visibility_desc">Show/Hide OSM Notes on the map.</string>
|
||||
<string name="gpx_file_desc">GPX - suitable for export to JOSM or other OSM editors.</string>
|
||||
<string name="osc_file_desc">OSC - suitable for export to OpenStreetMap.</string>
|
||||
<string name="gpx_file">GPX file</string>
|
||||
|
|
|
@ -1161,6 +1161,7 @@ public class OsmandSettings {
|
|||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeGlobal();
|
||||
|
||||
public final CommonPreference<String> MAP_INFO_CONTROLS = new StringPreference("map_info_controls", "").makeProfile();
|
||||
{
|
||||
|
|
|
@ -127,7 +127,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
List<OpenStreetNote> fullObjects = new ArrayList<>();
|
||||
List<LatLon> fullObjectsLatLon = new ArrayList<>();
|
||||
List<LatLon> 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) {
|
||||
|
|
|
@ -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<Boolean> showOsmBugsPref = settings.SHOW_OSM_BUGS;
|
||||
final CommonPreference<Boolean> showClosedOsmBugsPref = settings.SHOW_CLOSED_OSM_BUGS;
|
||||
|
||||
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> 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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue