From 0d3238d1751f42a5ea3241fce98841c95d0b276d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 26 Mar 2015 23:54:14 +0100 Subject: [PATCH] Sort from current location --- OsmAnd/res/values/strings.xml | 2 +- .../plus/activities/IntermediatePointsDialog.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 18b3bf5a4d..66bac6e842 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -755,7 +755,7 @@ \n\t* Support OSM Notes Search street in neighborhood cities - Intermediate waypoints resorted to optimize their order on the way to the destination. + Intermediate waypoints resorted to optimize their order on the way from current location to the destination. Sort (door-to-door) OSM change file successfully generated %1$s Backup OSM changes failed diff --git a/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java b/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java index 2ed3996621..7598270c37 100644 --- a/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/IntermediatePointsDialog.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import net.osmand.Location; import net.osmand.TspAnt; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.data.LatLon; @@ -18,6 +19,7 @@ import net.osmand.util.MapUtils; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; +import android.app.Application; import android.app.Dialog; import android.content.DialogInterface; import android.content.DialogInterface.OnShowListener; @@ -139,11 +141,17 @@ public class IntermediatePointsDialog { }; protected int[] doInBackground(Void[] params) { + OsmandApplication app = (OsmandApplication) activity.getApplication(); + Location cll = app.getLocationProvider().getLastKnownLocation(); ArrayList lt = new ArrayList(intermediates); TargetPoint start ; - if(activity instanceof MapActivity) { - LatLon ll = new LatLon(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity).getMapView().getLongitude()); + + if(cll != null) { + LatLon ll = new LatLon(cll.getLatitude(), cll.getLongitude()); start = TargetPoint.create(ll, null); +// } else if(activity instanceof MapActivity) { +// LatLon ll = new LatLon(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity).getMapView().getLongitude()); +// start = TargetPoint.create(ll, null); } else { start = lt.get(0); }