Prepare include prompting of route-recalculated in direction detection mechanism

This commit is contained in:
sonora 2012-03-02 17:39:51 +01:00
parent c63ca153e8
commit 69bf6474a4
3 changed files with 19 additions and 15 deletions

View file

@ -28,7 +28,7 @@ public class RoutingHelper {
public static interface IRouteInformationListener {
public void newRouteIsCalculated(boolean updateRoute, boolean makeUturnWhenpossible);
public void newRouteIsCalculated(boolean updateRoute, boolean suppressTurnPrompt);
public void routeWasCancelled();
}
@ -69,12 +69,17 @@ public class RoutingHelper {
private Handler uiHandler;
public static boolean makeUturnWhenPossible = false;
public static boolean suppressTurnPrompt = false;
public static int turnImminent = 0;
public static boolean makeUturnWhenPossible() {
return makeUturnWhenPossible;
}
public static boolean suppressTurnPrompt() {
return suppressTurnPrompt;
}
public static int turnImminent() {
return turnImminent;
}
@ -212,13 +217,14 @@ public class RoutingHelper {
public void setCurrentLocation(Location currentLocation) {
if(finalLocation == null || currentLocation == null){
makeUturnWhenPossible = false;
suppressTurnPrompt = false;
turnImminent = 0;
return;
}
makeUturnWhenPossible = false;
boolean calculateRoute = false;
boolean suppressTurnPrompt = false;
suppressTurnPrompt = false;
boolean calculateRoute = false;
synchronized (this) {
if(routeNodes.isEmpty() || routeNodes.size() <= currentRoute){
calculateRoute = true;
@ -385,13 +391,13 @@ public class RoutingHelper {
currentDirectionInfo = 0;
currentRoute = 0;
if(isFollowingMode){
voiceRouter.newRouteIsCalculated(updateRoute, makeUturnWhenPossible);
voiceRouter.newRouteIsCalculated(updateRoute, suppressTurnPrompt);
}
uiHandler.post(new Runnable() {
@Override
public void run() {
for (IRouteInformationListener l : listeners) {
l.newRouteIsCalculated(updateRoute, makeUturnWhenPossible);
l.newRouteIsCalculated(updateRoute, suppressTurnPrompt);
}
}
});
@ -461,9 +467,9 @@ public class RoutingHelper {
dist += lastFixedLocation.distanceTo(routeNodes.get(currentRoute));
}
if (dist < 100 || makeUturnWhenPossible == true) {
if (dist <= 100 || makeUturnWhenPossible == true) {
turnImminent = 1;
} else if (dist < 3000) {
} else if (dist <= 3000) {
turnImminent = 0;
} else {
turnImminent = -1;

View file

@ -286,8 +286,6 @@ public class VoiceRouter {
}
}
private void playMakeTurn(RouteDirectionInfo next, RouteDirectionInfo nextNext) {
CommandBuilder play = getNewCommandPlayerToPlay();
if(play != null){
@ -350,15 +348,15 @@ public class VoiceRouter {
}
}
public void newRouteIsCalculated(boolean updateRoute, boolean makeUturnWhenPossible) {
public void newRouteIsCalculated(boolean updateRoute, boolean suppressTurnPrompt) {
CommandBuilder play = getNewCommandPlayerToPlay();
if (play != null) {
if (updateRoute) {
//suppress "route recalculated" prompt while makeUturnWhenPossible is active
if (makeUturnWhenPossible == false) {
//suppress "route recaluated" prompt for 60sec
//suppress "route recalculated" prompt while suppressTurnPrompt is active
if (suppressTurnPrompt == false) {
//suppress "route recalculated" prompt for 60sec
if (System.currentTimeMillis() - lastTimeRouteRecalcAnnounced > 60000) {
//suppress "route recaluated" prompt for GPX-routing, it makes no sense
//suppress "route recalculated" prompt for GPX-routing, it makes no sense
if (router.getCurrentGPXRoute() == null) {
play.routeRecalculated(router.getLeftDistance()).play();
lastTimeRouteRecalcAnnounced = System.currentTimeMillis();

View file

@ -135,7 +135,7 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
}
@Override
public void newRouteIsCalculated(boolean updateRoute, boolean makeUturnWhenPossible) {
public void newRouteIsCalculated(boolean updateRoute, boolean suppressTurnPrompt) {
directionInfo = -1;
if (!routingHelper.isFollowingMode()) {
visible = true;