diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index ba3a2b4719..98ba3e0442 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1631,6 +1631,18 @@ public class OsmandSettings { .commit(); } + public boolean restorePointToStart() { + if (settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT_BACKUP, 0) == 0) { + settingsAPI.edit(globalPreferences) + .putFloat(START_POINT_LAT, settingsAPI.getFloat(globalPreferences, START_POINT_LAT_BACKUP, 0)) + .putFloat(START_POINT_LON, settingsAPI.getFloat(globalPreferences, START_POINT_LON_BACKUP, 0)) + .commit(); + return true; + } else { + return false; + } + } + public LatLon getPointToNavigate() { float lat = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LAT, 0); float lon = settingsAPI.getFloat(globalPreferences, POINT_NAVIGATE_LON, 0); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index bd9891abdd..ba331126dc 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -305,6 +305,10 @@ public class MapActivityActions implements DialogProvider { mapActivity.startActivity(intent); } else if (standardId == R.string.context_menu_item_directions_from) { mapActivity.getContextMenu().hide(); + if (settings.USE_MAP_MARKERS.get() + && getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) { + setFirstMapMarkerAsTarget(); + } enterRoutePlanningMode(new LatLon(latitude, longitude), mapActivity.getContextMenu().getPointDescription()); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 978f791328..1ef562b82b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -26,6 +26,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dialogs.DirectionsDialogs; @@ -501,8 +502,14 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL DirectionsDialogs.addWaypointDialogAndLaunchMap(mapActivity, latLon.getLatitude(), latLon.getLongitude(), getPointDescriptionForTarget()); } else if (targets.getIntermediatePoints().isEmpty()) { + boolean hasPointToStart = settings.restorePointToStart(); targets.navigateToPoint(latLon, true, -1, getPointDescriptionForTarget()); - mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true); + if (!hasPointToStart) { + mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, null, null, true, true); + } else { + TargetPoint start = targets.getPointToStart(); + mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(null, start.point, start.getOriginalPointDescription(), true, true); + } close(); } else { Builder bld = new AlertDialog.Builder(mapActivity);