From 416f824455599adf7ec2fa2a0cec50563dc5748e Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 8 Oct 2014 19:31:14 +0300 Subject: [PATCH] Added command to announce back on route --- OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java | 7 +++++++ OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java | 7 +++++++ OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java | 7 +++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 16de41202b..4a91d14962 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -72,6 +72,8 @@ public class RoutingHelper { private RouteCalculationProgressCallback progressRoute; + private boolean announceBackOnRoute = false; + // private ProgressBar progress; // private Handler progressHandler; @@ -272,6 +274,7 @@ public class RoutingHelper { } if(dist > 350) { voiceRouter.announceOffRoute(dist); + announceBackOnRoute = true; } } // 3. Identify wrong movement direction @@ -321,6 +324,10 @@ public class RoutingHelper { if(!thread.isParamsChanged()) { thread.stopCalculation(); } + if (announceBackOnRoute){ + voiceRouter.announceBackOnRoute(); + announceBackOnRoute = false; + } } } diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 6c0a21c0cb..c8b99273a8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -222,6 +222,13 @@ public class VoiceRouter { } } + public void announceBackOnRoute() { + CommandBuilder p = getNewCommandPlayerToPlay(); + if (p != null) { + p.backOnRoute().play(); + } + } + public void announceWaypoint(List points) { CommandBuilder p = getNewCommandPlayerToPlay(); if (p == null){ diff --git a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java index 11e2656626..79f6f9465f 100644 --- a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java +++ b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java @@ -37,6 +37,7 @@ public class CommandBuilder { protected static final String C_SPEAD_ALARM = "speed_alarm"; //$NON-NLS-1$ protected static final String C_ATTENTION = "attention"; //$NON-NLS-1$ protected static final String C_OFF_ROUTE = "off_route"; //$NON-NLS-1$ + protected static final String C_BACK_ON_ROUTE ="back_on_route"; //$NON-NLS-1$ protected static final String C_BEAR_LEFT = "bear_left"; //$NON-NLS-1$ @@ -133,8 +134,10 @@ public class CommandBuilder { public CommandBuilder offRoute(double dist){ return addCommand(C_OFF_ROUTE, dist); } - - + + public CommandBuilder backOnRoute(){ + return addCommand(C_BACK_ON_ROUTE); + } public CommandBuilder makeUT(double dist, Term streetName){ return alt(prepareStruct(C_MAKE_UT, dist, streetName), prepareStruct(C_MAKE_UT, dist));