From 481c66318390858befa3ee1c447c6d81ad1f8840 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 14 Jun 2017 16:29:24 +0300 Subject: [PATCH] Create MapillaryMenu and add it to the Configure Map --- .../osmand/plus/dashboard/DashboardOnMap.java | 8 +++++++- .../osmand/plus/mapillary/MapillaryMenu.java | 14 ++++++++++++++ .../osmand/plus/mapillary/MapillaryPlugin.java | 18 ++++++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 2e91bf64c4..c587f83883 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -74,7 +74,7 @@ import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter; -import net.osmand.plus.mapillary.MapillaryPlugin; +import net.osmand.plus.mapillary.MapillaryMenu; import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routing.RoutingHelper; @@ -188,6 +188,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis DASHBOARD, OVERLAY_MAP, UNDERLAY_MAP, + MAPILLARY, CONTOUR_LINES, HILLSHADE, MAP_MARKERS, @@ -462,6 +463,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis tv.setText(R.string.map_markers); } else if (visibleType == DashboardType.MAP_MARKERS_SELECTION) { tv.setText(R.string.select_map_markers); + } else if (visibleType == DashboardType.MAPILLARY) { + tv.setText(R.string.mapillary); } else if (visibleType == DashboardType.CONTOUR_LINES) { tv.setText(R.string.srtm_plugin_name); } else if (visibleType == DashboardType.HILLSHADE) { @@ -903,6 +906,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis && visibleType != DashboardType.MAP_MARKERS_SELECTION && visibleType != DashboardType.CONFIGURE_SCREEN && visibleType != DashboardType.CONFIGURE_MAP + && visibleType != DashboardType.MAPILLARY && visibleType != DashboardType.CONTOUR_LINES && visibleType != DashboardType.HILLSHADE) { listView.setDivider(dividerDrawable); @@ -980,6 +984,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY); } else if (visibleType == DashboardType.OVERLAY_MAP) { cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY); + } else if (visibleType == DashboardType.MAPILLARY) { + cm = MapillaryMenu.createListAdapter(mapActivity); } else if (visibleType == DashboardType.CONTOUR_LINES) { cm = ContourLinesMenu.createListAdapter(mapActivity); } else if (visibleType == DashboardType.HILLSHADE) { diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java new file mode 100644 index 0000000000..1d943fc908 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java @@ -0,0 +1,14 @@ +package net.osmand.plus.mapillary; + +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; + +public class MapillaryMenu { + + public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) { + ContextMenuAdapter adapter = new ContextMenuAdapter(); + adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); + return adapter; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index 151b397ad3..da3220afb5 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -26,6 +26,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.base.BottomSheetDialogFragment; +import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; @@ -130,11 +131,18 @@ public class MapillaryPlugin extends OsmandPlugin { } @Override - public void registerLayerContextMenuActions(final OsmandMapTileView mapView, - ContextMenuAdapter adapter, - final MapActivity mapActivity) { + public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() { + @Override + public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) { + if (itemId == R.string.mapillary) { + mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAPILLARY); + return false; + } + return true; + } + @Override public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) { final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); @@ -157,10 +165,12 @@ public class MapillaryPlugin extends OsmandPlugin { if (rasterLayer.getMap() == null) { settings.SHOW_MAPILLARY.set(false); } - adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.mapillary, mapActivity) + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(R.string.mapillary, mapActivity) .setSelected(settings.SHOW_MAPILLARY.get()) .setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setIcon(R.drawable.ic_action_mapillary) + .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(listener) .setPosition(11) .createItem());