From c4c3eb55d261ffb59045ec75bc8ae6c92dd05012 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 3 Nov 2016 10:35:47 +0300 Subject: [PATCH] Added next turn distance to notification --- .../plus/notifications/NavigationNotification.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java index d5794c1470..0c82d147f0 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/NavigationNotification.java @@ -129,6 +129,7 @@ public class NavigationNotification extends OsmandNotification { boolean deviatedFromRoute; int turnImminent = 0; int nextTurnDistance = 0; + int nextNextTurnDistance = 0; RouteDirectionInfo ri = null; if (routingHelper.isRouteCalculated() && followingMode) { deviatedFromRoute = routingHelper.isDeviatedFromRoute(); @@ -138,12 +139,15 @@ public class NavigationNotification extends OsmandNotification { turnType = TurnType.valueOf(TurnType.OFFR, leftSide); nextTurnDistance = (int) routingHelper.getRouteDeviation(); } else { - NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(new NextDirectionInfo(), true); + NextDirectionInfo calc1 = new NextDirectionInfo(); + NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true); if (r != null && r.distanceTo > 0 && r.directionInfo != null) { ri = r.directionInfo; turnType = r.directionInfo.getTurnType(); nextTurnDistance = r.distanceTo; turnImminent = r.imminent; + NextDirectionInfo next = routingHelper.getNextRouteDirectionInfoAfter(r, calc1, true); + nextNextTurnDistance = next.distanceTo; } } @@ -161,6 +165,9 @@ public class NavigationNotification extends OsmandNotification { + (turnType != null ? " • " + RouteCalculationResult.toString(turnType, app) : ""); if (ri != null && !Algorithms.isEmpty(ri.getDescriptionRoutePart())) { notificationText.append(ri.getDescriptionRoutePart()); + if (nextNextTurnDistance > 0) { + notificationText.append(" ").append(OsmAndFormatter.getFormattedDistance(nextNextTurnDistance, app)); + } notificationText.append("\n"); }