diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 8affa58f36..f38eba8d81 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,9 @@
Thx - Hardy
-->
+ Add start and end points
+ Add start point
+ Select start point
Unpaved
Sand
Grass
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index ce5eb6f8e4..dc90ca9256 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -42,6 +42,7 @@ import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarker;
+import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
@@ -1412,21 +1413,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
- if (endPoint == null) {
+ Location loc = app.getLocationProvider().getLastKnownLocation();
+ if (loc == null && startPoint == null && endPoint == null) {
+ app.showShortToastMessage(R.string.add_start_and_end_points);
+ } else if (endPoint == null) {
app.showShortToastMessage(R.string.mark_final_location_first);
} else {
- if (startPoint == null) {
- Location loc = app.getLocationProvider().getLastKnownLocation();
- if (loc != null) {
- startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()),
- new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION,
- mapActivity.getString(R.string.shared_string_my_location)));
- }
+ if (startPoint == null && loc != null) {
+ startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()),
+ new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActivity.getString(R.string.shared_string_my_location)));
}
if (startPoint != null) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true);
+ } else {
+ app.showShortToastMessage(R.string.route_add_start_point);
}
}
}
@@ -1751,7 +1753,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (start != null) {
fromText.setText(name);
} else {
- fromText.setText(R.string.shared_string_my_location);
+ if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
+ fromText.setText(R.string.shared_string_my_location);
+ } else {
+ fromText.setText(R.string.route_descr_select_start_point);
+ }
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java
index 174e72be42..04cc4b80e3 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java
@@ -390,15 +390,7 @@ public class MapControlsLayer extends OsmandMapLayer {
public void doRoute(boolean hasTargets) {
this.hasTargets = hasTargets;
- if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
- onNavigationClick();
- } else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
- app.showToastMessage(R.string.ask_for_location_permission);
- } else {
- ActivityCompat.requestPermissions(mapActivity,
- new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
- REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION);
- }
+ onNavigationClick();
}
public void doNavigate() {