From 2929cab845844e719afb936c843226bea0007afb Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 21 Jan 2016 17:47:02 +0300 Subject: [PATCH] Added new FAB mode to context menu + popup dialog for routing preparation and following modes --- .../plus/mapcontextmenu/MapContextMenu.java | 17 ++++++++++++++++- .../mapcontextmenu/MapContextMenuFragment.java | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index b70fe0fe05..998817d745 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -22,6 +22,7 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.MenuType; @@ -32,6 +33,7 @@ import net.osmand.plus.mapcontextmenu.editors.PointEditor; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor; import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu; +import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.util.MapUtils; @@ -414,10 +416,23 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } } + public int getFabIconId() { + RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper(); + if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) { + return R.drawable.map_action_flag_dark; + } else { + return R.drawable.map_directions; + } + } + public void fabPressed() { hide(); final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper(); - if (targets.getIntermediatePoints().isEmpty()) { + RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper(); + if (routingHelper.isFollowingMode() || routingHelper.isRoutePlanningMode()) { + DirectionsDialogs.addWaypointDialogAndLaunchMap(mapActivity, latLon.getLatitude(), + latLon.getLongitude(), getPointDescriptionForTarget()); + } else if (targets.getIntermediatePoints().isEmpty()) { targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget()); mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index dbe811f5e5..3a295e79de 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -339,6 +339,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { // FAB fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view); if (menu.fabVisible()) { + fabView.setImageDrawable(iconsCache.getIcon(menu.getFabIconId(), 0, 0f)); if (menu.isLandscapeLayout()) { FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) fabView.getLayoutParams(); params.setMargins(0, 0, dpToPx(28f), 0);