From 79fe50cd2f34f1ea41ea8dd4d0241da498db453c Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 17 Aug 2016 11:20:13 +0200 Subject: [PATCH] Fix #2960 --- .../src/net/osmand/plus/CurrentPositionHelper.java | 7 ++++++- .../views/mapwidgets/MapInfoWidgetsFactory.java | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 1a2330af76..a6b603ffd2 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -38,6 +38,11 @@ public class CurrentPositionHelper { this.app = app; } + + public Location getLastAskedLocation() { + return lastAskedLocation; + } + public boolean getRouteSegment(Location loc, ResultMatcher result) { return scheduleRouteSegmentFind(loc, false, null, result); } @@ -245,7 +250,7 @@ public class CurrentPositionHelper { }); } - private static double getOrthogonalDistance(RouteDataObject r, Location loc){ + public static double getOrthogonalDistance(RouteDataObject r, Location loc){ double d = 1000; if (r.getPointsLength() > 0) { double pLt = MapUtils.get31LatitudeY(r.getPoint31YTile(0)); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 672d758ba3..a4f4dae451 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -15,6 +15,7 @@ import android.widget.TextView; import net.osmand.Location; import net.osmand.ValueHolder; import net.osmand.binary.RouteDataObject; +import net.osmand.plus.CurrentPositionHelper; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider; @@ -37,6 +38,7 @@ import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable; import net.osmand.router.TurnType; +import net.osmand.util.Algorithms; import java.util.Iterator; import java.util.LinkedList; @@ -584,8 +586,16 @@ public class MapInfoWidgetsFactory { if (text == null) { text = ""; } else { - type[0] = TurnType.valueOf(TurnType.C, false); - turnDrawable.setColor(R.color.color_myloc_distance); + if(!Algorithms.isEmpty(text) && locationProvider.getLastKnownLocation() != null) { + double dist = + CurrentPositionHelper.getOrthogonalDistance(rt, locationProvider.getLastKnownLocation()); + if(dist < 50) { + type[0] = TurnType.valueOf(TurnType.C, false); + turnDrawable.setColor(R.color.color_myloc_distance); + } else { + text = map.getResources().getString(R.string.shared_string_near) + " " + text; + } + } } } if (map.isTopToolbarActive()) {