diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 0ab8ce48dc..885e8940a4 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -1,5 +1,12 @@ package net.osmand.plus; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + import net.osmand.Location; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; @@ -14,18 +21,12 @@ import net.osmand.router.RoutingConfiguration; import net.osmand.router.RoutingContext; import net.osmand.util.MapUtils; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - public class CurrentPositionHelper { private RouteDataObject lastFound; private Location lastAskedLocation = null; private RoutingContext ctx; + private RoutingContext defCtx; private OsmandApplication app; private ApplicationMode am; @@ -48,6 +49,9 @@ public class CurrentPositionHelper { RoutingConfiguration cfg = app.getDefaultRoutingConfig().build(p.name().toLowerCase(), 10, new HashMap()); ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getResourceManager().getRoutingMapFiles()); + RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build(GeneralRouterProfile.CAR.name().toLowerCase(), 10, + new HashMap()); + defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, app.getResourceManager().getRoutingMapFiles()); } @@ -59,7 +63,8 @@ public class CurrentPositionHelper { @Override public void run() { try { - final List gr = runUpdateInThread(loc.getLatitude(), loc.getLongitude()); + final List gr = runUpdateInThread(loc.getLatitude(), loc.getLongitude(), + geoCoding != null); if (storeFound) { lastAskedLocation = loc; lastFound = gr.isEmpty() ? null : gr.get(0).point.getRoad(); @@ -116,6 +121,9 @@ public class CurrentPositionHelper { } } Collections.sort(complete, GeocodingUtilities.DISTANCE_COMPARATOR); +// for(GeocodingResult rt : complete) { +// System.out.println(rt.toString()); +// } final GeocodingResult rts = complete.size() > 0 ? complete.get(0) : new GeocodingResult(); app.runInUIThread(new Runnable() { public void run() { @@ -175,13 +183,13 @@ public class CurrentPositionHelper { } - private synchronized List runUpdateInThread(double lat, double lon) throws IOException { + private synchronized List runUpdateInThread(double lat, double lon, boolean geocoding) throws IOException { if (ctx == null || am != app.getSettings().getApplicationMode()) { initCtx(app); if (ctx == null) { return null; } } - return new GeocodingUtilities().reverseGeocodingSearch(ctx, lat, lon); + return new GeocodingUtilities().reverseGeocodingSearch(geocoding ? defCtx : ctx, lat, lon); } } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index c7f8b0d9c8..3fd6ea564c 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -929,7 +929,6 @@ public class OsmAndLocationProvider implements SensorEventListener { public static boolean isLocationPermissionAvailable(Context context) { if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - Toast.makeText(context, R.string.no_location_permission, Toast.LENGTH_LONG).show(); return false; } return true; diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 18edc4eb6d..af92836a54 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -328,7 +328,7 @@ public class MapControlsLayer extends OsmandMapLayer { mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); } else { ActivityCompat.requestPermissions(mapActivity, - new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION); } }