Fix current location route & voice prompts in planning mode

This commit is contained in:
vshcherb 2014-03-30 21:51:41 +02:00
parent e6580e8829
commit 8cb90bbce3
5 changed files with 23 additions and 10 deletions

View file

@ -416,8 +416,8 @@ public class OsmandApplication extends Application implements ClientContext {
} }
private void initVoiceDataInDifferentThread(final Activity uiContext, final String voiceProvider, final Runnable run, boolean showDialog) { private void initVoiceDataInDifferentThread(final Activity uiContext, final String voiceProvider, final Runnable run, boolean showDialog) {
final ProgressDialog dlg = showDialog ? null : ProgressDialog.show(uiContext, getString(R.string.loading_data), final ProgressDialog dlg = showDialog ? ProgressDialog.show(uiContext, getString(R.string.loading_data),
getString(R.string.voice_data_initializing)); getString(R.string.voice_data_initializing)) : null;
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {

View file

@ -500,8 +500,8 @@ public class MapActivityActions implements DialogProvider {
if(mode == ApplicationMode.DEFAULT) { if(mode == ApplicationMode.DEFAULT) {
mode = ApplicationMode.CAR; mode = ApplicationMode.CAR;
} }
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
app.initVoiceCommandPlayer(mapActivity);
TargetPointsHelper targets = app.getTargetPointsHelper(); TargetPointsHelper targets = app.getTargetPointsHelper();
app.getSettings().APPLICATION_MODE.set(mode); app.getSettings().APPLICATION_MODE.set(mode);
app.getRoutingHelper().setAppMode(mode); app.getRoutingHelper().setAppMode(mode);

View file

@ -434,5 +434,6 @@ public class NavigateAction {
routingHelper.setFinalAndCurrentLocation(finalLocation, intermediatePoints, currentLocation, gpxRoute); routingHelper.setFinalAndCurrentLocation(finalLocation, intermediatePoints, currentLocation, gpxRoute);
app.initVoiceCommandPlayer(mapActivity); app.initVoiceCommandPlayer(mapActivity);
} }
} }

View file

@ -231,7 +231,6 @@ public class RoutingHelper {
if (finished) { if (finished) {
return null; return null;
} }
announceGpxWaypoints(currentLocation);
List<Location> routeNodes = route.getImmutableLocations(); List<Location> routeNodes = route.getImmutableLocations();
int currentRoute = route.currentRoute; int currentRoute = route.currentRoute;
@ -257,11 +256,15 @@ public class RoutingHelper {
// 4. Identify if UTurn is needed // 4. Identify if UTurn is needed
boolean uTurnIsNeeded = identifyUTurnIsNeeded(currentLocation, posTolerance); boolean uTurnIsNeeded = identifyUTurnIsNeeded(currentLocation, posTolerance);
// 5. Update Voice router // 5. Update Voice router
boolean inRecalc = calculateRoute || isRouteBeingCalculated(); if (isFollowingMode) {
if (!inRecalc && !uTurnIsNeeded && !wrongMovementDirection) { // don't update in route planing mode
voiceRouter.updateStatus(currentLocation, false); announceGpxWaypoints(currentLocation);
} else if (uTurnIsNeeded) { boolean inRecalc = calculateRoute || isRouteBeingCalculated();
voiceRouter.makeUTStatus(); if (!inRecalc && !uTurnIsNeeded && !wrongMovementDirection) {
voiceRouter.updateStatus(currentLocation, false);
} else if (uTurnIsNeeded) {
voiceRouter.makeUTStatus();
}
} }
// calculate projection of current location // calculate projection of current location
@ -534,7 +537,9 @@ public class RoutingHelper {
// trigger voice prompt only if new route is in forward direction // trigger voice prompt only if new route is in forward direction
// If route is in wrong direction after one more setLocation it will be recalculated // If route is in wrong direction after one more setLocation it will be recalculated
if (!wrongMovementDirection || newRoute) { if (!wrongMovementDirection || newRoute) {
voiceRouter.newRouteIsCalculated(newRoute); if(isFollowingMode) {
voiceRouter.newRouteIsCalculated(newRoute);
}
} }
} }
@ -890,4 +895,10 @@ public class RoutingHelper {
} }
public void notifyIfRouteIsCalculated() {
if(route.isCalculated()) {
voiceRouter.newRouteIsCalculated(true) ;
}
}
} }

View file

@ -46,6 +46,7 @@ public class MapNavigateControl extends MapControls {
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode(); mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false); routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
app.initVoiceCommandPlayer(mapActivity); app.initVoiceCommandPlayer(mapActivity);
app.getRoutingHelper().notifyIfRouteIsCalculated();
} }
} }
} }