diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index eb9f77b110..551cb2727f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -143,6 +143,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents, private AppInitializeListener initListener; private IMapDownloaderCallback downloaderCallback; private DrawerLayout drawerLayout; + private boolean drawerDisabled; private Notification getNotification() { Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); @@ -1034,13 +1035,19 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents, } public void disableDrawer() { + drawerDisabled = true; drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } public void enableDrawer() { + drawerDisabled = false; drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); } + public boolean isDrawerDisabled() { + return drawerDisabled; + } + public void closeDrawer() { drawerLayout.closeDrawer(Gravity.LEFT); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 573d434307..74ba12e046 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -416,9 +416,7 @@ public class MapActivityActions implements DialogProvider { app.getRoutingHelper().setFollowingMode(false); app.getRoutingHelper().setRoutePlanningMode(true); // reset start point - if (targets.getPointToStart() == null) { - targets.setStartPoint(from, false, fromName); - } + targets.setStartPoint(from, false, fromName); // then set gpx setGPXRouteParams(gpxFile); // then update start and destination point diff --git a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java index aac072837f..74bff32fb2 100644 --- a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java +++ b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java @@ -168,7 +168,9 @@ public class FailSafeFuntions { app.getSettings().FOLLOW_THE_GPX_ROUTE.set(null); } routingHelper.setGpxParams(gpxRoute); - app.getTargetPointsHelper().setStartPoint(null, false, null); + if (app.getTargetPointsHelper().getPointToStart() == null) { + app.getTargetPointsHelper().setStartPoint(null, false, null); + } app.getSettings().FOLLOW_THE_ROUTE.set(true); routingHelper.setFollowingMode(true); app.getTargetPointsHelper().updateRouteAndRefresh(true); diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 45b40f3de2..98b9c29f98 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -1,6 +1,7 @@ package net.osmand.plus.base; -import java.util.List; +import android.content.Context; +import android.view.WindowManager; import net.osmand.Location; import net.osmand.StateChangedListener; @@ -16,7 +17,6 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.AutoZoomMap; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper.TargetPoint; -import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.routing.RoutingHelper; @@ -24,8 +24,8 @@ import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.MapUtils; -import android.content.Context; -import android.view.WindowManager; + +import java.util.List; public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, IRouteInformationListener { private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4; @@ -272,7 +272,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc app.runMessageInUIThreadAndCancelPrevious(AUTO_FOLLOW_MSG_ID, new Runnable() { @Override public void run() { - if (mapView != null && !isMapLinkedToLocation()) { + if (mapView != null && !isMapLinkedToLocation() && contextMenu == null) { app.showToastMessage(R.string.auto_follow_location_enabled); backToLocationImpl(); } @@ -285,9 +285,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc } public void setMapLinkedToLocation(boolean isMapLinkedToLocation) { - if(!isMapLinkedToLocation){ + if (!isMapLinkedToLocation) { int autoFollow = settings.AUTO_FOLLOW_ROUTE.get(); - if(autoFollow > 0 && app.getRoutingHelper().isFollowingMode() && !routePlanningMode){ + if (autoFollow > 0 && app.getRoutingHelper().isFollowingMode() && !routePlanningMode) { backToLocationWithDelay(autoFollow); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 6263dcbe7f..c35a101d2c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -95,6 +95,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { private boolean nightMode; private boolean centered; private boolean initLayout = true; + private boolean wasDrawerDisabled; private float skipHalfScreenStateLimit; @@ -657,14 +658,21 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { return; } screenOrientation = DashLocationFragment.getScreenOrientation(getActivity()); - if (menu.displayDistanceDirection()) { - getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); + getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); + getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false); + wasDrawerDisabled = getMapActivity().isDrawerDisabled(); + if (!wasDrawerDisabled) { + getMapActivity().disableDrawer(); } } @Override public void onPause() { getMapActivity().getMapViewTrackingUtilities().setContextMenu(null); + getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false); + if (!wasDrawerDisabled) { + getMapActivity().enableDrawer(); + } super.onPause(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java index b997bc426f..c97a4775dd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java @@ -24,29 +24,30 @@ public class TargetPointMenuController extends MenuController { final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size(); RoutingHelper routingHelper = getMapActivity().getMyApplication().getRoutingHelper(); final boolean nav = routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode(); - if (!targetPoint.start) { - leftTitleButtonController = new TitleButtonController() { - @Override - public void buttonPressed() { - TargetPoint tp = getTargetPoint(); - if (tp.intermediate) { - targetPointsHelper.removeWayPoint(true, tp.index); - } else { - targetPointsHelper.removeWayPoint(true, -1); - } - getMapActivity().getContextMenu().close(); - if (nav && intermediatePointsCount == 0) { - getMapActivity().getMapActions().stopNavigationWithoutConfirm(); - } + leftTitleButtonController = new TitleButtonController() { + @Override + public void buttonPressed() { + TargetPoint tp = getTargetPoint(); + if (tp.start) { + getMapActivity().getMyApplication().getTargetPointsHelper().clearStartPoint(true); + } else if (tp.intermediate) { + targetPointsHelper.removeWayPoint(true, tp.index); + } else { + targetPointsHelper.removeWayPoint(true, -1); + } + getMapActivity().getContextMenu().close(); + if (nav && intermediatePointsCount == 0 && !tp.start) { + getMapActivity().getMapActions().stopNavigationWithoutConfirm(); + getMapActivity().getMyApplication().getTargetPointsHelper().clearStartPoint(false); } - }; - if (nav && intermediatePointsCount == 0) { - leftTitleButtonController.caption = getMapActivity().getString(R.string.cancel_navigation); - leftTitleButtonController.leftIconId = R.drawable.ic_action_remove_dark; - } else { - leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_remove); - leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; } + }; + if (nav && intermediatePointsCount == 0 && !targetPoint.start) { + leftTitleButtonController.caption = getMapActivity().getString(R.string.cancel_navigation); + leftTitleButtonController.leftIconId = R.drawable.ic_action_remove_dark; + } else { + leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_remove); + leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java index 2b2df76341..2dba4f7f6e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java @@ -37,6 +37,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi private ArrayAdapter listAdapter; private MapMultiSelectionMenu menu; private boolean dismissing = false; + private boolean wasDrawerDisabled; @Nullable @Override @@ -67,6 +68,10 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi @Override public void onStart() { super.onStart(); + wasDrawerDisabled = menu.getMapActivity().isDrawerDisabled(); + if (!wasDrawerDisabled) { + menu.getMapActivity().disableDrawer(); + } menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false); menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(false); } @@ -79,6 +84,9 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi } menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(true); menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true); + if (!wasDrawerDisabled) { + menu.getMapActivity().enableDrawer(); + } } public static void showInstance(final MapActivity mapActivity) {