Show toast when trying to switch start/finish and finish empty

This commit is contained in:
crimean 2019-02-18 17:23:34 +03:00
parent a3aa837ff5
commit fdad323ab0
3 changed files with 31 additions and 24 deletions

View file

@ -10,6 +10,7 @@
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy
-->
<string name="add_destination_query">Please add Destination first</string>
<string name="previous_route">Previous route</string>
<string name="add_home">Add home</string>
<string name="add_work">Add work</string>

View file

@ -242,19 +242,23 @@ public class WaypointDialogHelper {
public static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish,
Activity ctx, TargetPoint start, OsmandApplication app,
WaypointDialogHelper helper) {
targetPointsHelper.setStartPoint(new LatLon(finish.getLatitude(),
finish.getLongitude()), false, finish.getPointDescription(ctx));
if (start == null) {
Location loc = app.getLocationProvider().getLastKnownLocation();
if (loc != null) {
targetPointsHelper.navigateToPoint(new LatLon(loc.getLatitude(),
loc.getLongitude()), true, -1);
}
if (finish == null) {
app.showShortToastMessage(R.string.add_destination_query);
} else {
targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(),
start.getLongitude()), true, -1, start.getPointDescription(ctx));
targetPointsHelper.setStartPoint(new LatLon(finish.getLatitude(),
finish.getLongitude()), false, finish.getPointDescription(ctx));
if (start == null) {
Location loc = app.getLocationProvider().getLastKnownLocation();
if (loc != null) {
targetPointsHelper.navigateToPoint(new LatLon(loc.getLatitude(),
loc.getLongitude()), true, -1);
}
} else {
targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(),
start.getLongitude()), true, -1, start.getPointDescription(ctx));
}
updateControls(ctx, helper);
}
updateControls(ctx, helper);
}
public static void updateControls(Activity ctx, WaypointDialogHelper helper) {

View file

@ -1049,20 +1049,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
TargetPointsHelper targetPointsHelper = getTargets();
TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
if (startPoint == null) {
Location loc = mapActivity.getMyApplication().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 (endPoint == null) {
app.showShortToastMessage(R.string.add_destination_query);
} else {
if (startPoint == null) {
Location loc = mapActivity.getMyApplication().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) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true);
}
}
if (startPoint != null && endPoint != null) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true);
}
}
});