private void createLayersItems(ContextMenuAdapter adapter, MapActivity activity) { OsmandApplication app = activity.getMyApplication(); OsmandSettings settings = app.getSettings(); LayerMenuListener l = new LayerMenuListener(activity, adapter); adapter .item(R.string.shared_string_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.SELECTED_POI_FILTER_FOR_MAP.get() != null ? 1 : 0) .iconColor(R.drawable.ic_action_info_dark) .listen(l) .reg(); adapter .item(R.string.layer_amenity_label) .selected(settings.SHOW_POI_LABEL.get() ? 1 : 0) .iconColor(R.drawable.ic_action_text_dark) .listen(l) .reg(); adapter .item(R.string.shared_string_favorites) .selected(settings.SHOW_FAVORITES.get() ? 1 : 0) .iconColor(R.drawable.ic_action_fav_dark) .listen(l) .reg(); adapter .item(R.string.layer_gpx_layer) .selected(app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0) .iconColor(R.drawable.ic_action_polygom_dark) .listen(l) .reg(); adapter.item(R.string.layer_map).iconColor(R.drawable.ic_world_globe_dark).listen(l).reg(); if (TransportRouteHelper.getInstance().routeIsCalculated()) { adapter .item(R.string.layer_transport_route) .selected(1) .iconColor(R.drawable.ic_action_bus_dark) .listen(l) .reg(); } OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity); app.getAppCustomization().prepareLayerContextMenu(activity, adapter); }
@Override public void registerMapContextMenuActions( final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, Object selectedObj) { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() { @Override public boolean onContextMenuClick( ArrayAdapter<ContextMenuItem> adapter, int resId, int pos, boolean isChecked) { if (resId == R.string.context_menu_item_add_waypoint) { mapActivity.getContextMenu().addWptPt(); } else if (resId == R.string.context_menu_item_edit_waypoint) { mapActivity.getContextMenu().editWptPt(); } return true; } }; adapter.addItem( new ContextMenuItem.ItemBuilder() .setTitleId(R.string.context_menu_item_add_waypoint, mapActivity) .setIcon(R.drawable.ic_action_gnew_label_dark) .setListener(listener) .createItem()); if (selectedObj instanceof WptPt) { WptPt pt = (WptPt) selectedObj; if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) { adapter.addItem( new ContextMenuItem.ItemBuilder() .setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity) .setIcon(R.drawable.ic_action_edit_dark) .setListener(listener) .createItem()); } } }