From 85bda858845ffefa922a57e513c3bc474e52470f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 3 Aug 2013 20:19:55 +0200 Subject: [PATCH] Speak destination point --- .../net/osmand/plus/routing/RoutingHelper.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 8e7c27ee87..bc764583c9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -386,15 +386,19 @@ public class RoutingHelper { // 2. check if intermediate found if(route.getIntermediatePointsToPass() > 0 && route.getDistanceToNextIntermediate(lastFixedLocation) < POSITION_TOLERANCE * 2) { showMessage(app.getString(R.string.arrived_at_intermediate_point)); - TargetPointsHelper targets = app.getInternalAPI().getTargetPointsHelper(); -// List ns = targets.getIntermediatePointNames(); names are not really suitable for voice - voiceRouter.arrivedIntermediatePoint(""); route.passIntermediatePoint(); + + TargetPointsHelper targets = app.getInternalAPI().getTargetPointsHelper(); + List ns = targets.getIntermediatePointNames(); int toDel = targets.getIntermediatePoints().size() - route.getIntermediatePointsToPass(); + int currentIndex = toDel - 1; + String name = currentIndex < 0 || currentIndex >= ns.size() || ns.get(currentIndex ) == null ? "" : ns.get(currentIndex ); + voiceRouter.arrivedIntermediatePoint(name); while(toDel > 0) { targets.removeWayPoint(false, 0); toDel--; } + while(intermediatePoints != null && route.getIntermediatePointsToPass() < intermediatePoints.size()) { intermediatePoints.remove(0); } @@ -404,9 +408,11 @@ public class RoutingHelper { Location lastPoint = routeNodes.get(routeNodes.size() - 1); if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < POSITION_TOLERANCE * 1.5) { showMessage(app.getString(R.string.arrived_at_destination)); - voiceRouter.arrivedDestinationPoint(""); + TargetPointsHelper targets = app.getInternalAPI().getTargetPointsHelper(); + String description = targets.getPointNavigateDescription(); + voiceRouter.arrivedDestinationPoint(description); clearCurrentRoute(null, null); - // TargetPointsHelper targets = app.getInternalAPI().getTargetPointsHelper(); + // targets.clearPointToNavigate(false); return true; }