Create MapillaryMenu and add it to the Configure Map

This commit is contained in:
Alexander Sytnyk 2017-06-14 16:29:24 +03:00
parent 16d217a8fe
commit 481c663183
3 changed files with 35 additions and 5 deletions

View file

@ -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) {

View file

@ -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;
}
}

View file

@ -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<ContextMenuItem> 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<ContextMenuItem> 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());