diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 40cd1dcf28..890a1025ae 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -108,6 +108,12 @@ public class RouteCalculationResult { if(turn != null) { RouteDirectionInfo info = new RouteDirectionInfo(s.getSegmentSpeed(), turn); + if(routeInd + 1< list.size()) { + RouteSegmentResult next = list.get(routeInd); + info.setRef(next.getObject().getRef()); + info.setStreetName(next.getObject().getName()); + } + String description = toString(turn, ctx); info.setDescriptionRoute(description); info.routePointOffset = prevLocationSize; @@ -448,7 +454,7 @@ public class RouteCalculationResult { } public List getDirections() { - return directions ; + return directions; } @@ -458,7 +464,23 @@ public class RouteCalculationResult { } return Collections.emptyList(); } - + + public RouteSegmentResult getCurrentSegmentResult() { + int cs = currentRoute > 0 ? currentRoute - 1 : 0; + if(cs < segments.size()) { + return segments.get(cs); + } + return null; + } + + public float getCurrentMaxSpeed() { + RouteSegmentResult res = getCurrentSegmentResult(); + if(res != null) { + return res.getObject().getMaximumSpeed(); + } + return 0; + } + public int[] getListDistance() { return listDistance; diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index d79f4655bd..72934d90ad 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -164,6 +164,7 @@ public class MapInfoLayer extends OsmandMapLayer { leftStack.addStackView(createNextInfoControl()); leftStack.addStackView(createMiniMapControl()); leftStack.addStackView(createNextNextInfoControl()); +// leftStack.addStackView(createAlarmInfoControl()); // 2. Preparations Rect topRectPadding = new Rect(); @@ -548,6 +549,55 @@ public class MapInfoLayer extends OsmandMapLayer { return nextTurnInfo; } + private NextTurnInfoControl createAlarmInfoControl() { + final RoutingHelper routingHelper = routeLayer.getHelper(); + final NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintSmallText, paintSmallSubText, true) { + @Override + public boolean updateInfo() { + boolean visible = false; + if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) { + boolean uturnWhenPossible = routingHelper.makeUturnWhenPossible(); + int d; + if(uturnWhenPossible) { + d = routingHelper.getDistanceToNextRouteDirection() ; + } else { + d = routingHelper.getDistanceToNextNextRouteDirection(); + } + if (d >= 0 && !showMiniMap) { + visible = true; + RouteDirectionInfo next = uturnWhenPossible? routingHelper.getNextRouteDirectionInfo() : + routingHelper.getNextNextRouteDirectionInfo(); + if (next == null) { + if (turnType != null) { + turnType = null; + invalidate(); + } + } else if (!Algoritms.objectEquals(turnType, next.getTurnType())) { + turnType = next.getTurnType(); + TurnPathHelper.calcTurnPath(pathForTurn, turnType, pathTransform); + invalidate(); + } + if (distChanged(d, nextTurnDirection)) { + invalidate(); + nextTurnDirection = d; + } + int imminent = uturnWhenPossible? routingHelper.getNextTurnImminent() : routingHelper.getNextNextTurnImminent(); + if (turnImminent != imminent) { + turnImminent = imminent; + invalidate(); + } + } + } + updateVisibility(visible); + + return true; + } + }; + // initial state +// nextTurnInfo.setVisibility(View.GONE); + return nextTurnInfo; + } + private NextTurnInfoControl createNextInfoControl() { final RoutingHelper routingHelper = routeLayer.getHelper(); final NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintText, paintSubText, false) {