add continue with previous route

git-svn-id: https://osmand.googlecode.com/svn/trunk@374 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-20 07:44:19 +00:00
parent 66bd6c43f8
commit 95e7d9be61
6 changed files with 44 additions and 6 deletions

View file

@ -17,12 +17,10 @@ public class ToDoConstants {
// Improvement : progress while loading tiles // Improvement : progress while loading tiles
// Improvement : download with wget // Improvement : download with wget
// Yandex traffic : http://jgo.maps.yandex.net/tiles?l=trf
// Imrpovement : show vehicle for calculating route // Imrpovement : show vehicle for calculating route
// Improvement : show detailed route on the map with turns and show route information directly (like in gmaps) // Improvement : show detailed route on the map with turns and show route information directly (like in gmaps)
// Improvement : show route info after route is calculated (-) // Improvement : show route info after route is calculated (-)
// Improvement : after return if there was previous route (continue follow)
// Not clear if it is really needed // Not clear if it is really needed
// 69. Add phone information to POI // 69. Add phone information to POI
@ -31,7 +29,7 @@ public class ToDoConstants {
// Unscheduled (complex) // Unscheduled (complex)
// 66. Transport routing (show next stop, total distance, show stop get out) (?). // 66. Transport routing (show next stop, total distance, show stop get out) (?).
// 64. Traffic information (?) - rmaps? // 64. Traffic information (?) - rmaps (http://jgo.maps.yandex.net/tiles?l=trf)?
// 65. Intermediate points - for better control routing, to avoid traffic jams ...(?) // 65. Intermediate points - for better control routing, to avoid traffic jams ...(?)
// 40. Support simple vector road rendering (require new index file) (?) // 40. Support simple vector road rendering (require new index file) (?)
// 63. Support simple offline routing(require new index file) (?) // 63. Support simple offline routing(require new index file) (?)

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="continue_follow_previous_route">Предыдущий маршрут был не закончен. Продолжить следовать по нему?</string>
<string name="context_menu_item_search_poi">Искать POI</string> <string name="context_menu_item_search_poi">Искать POI</string>
<string name="context_menu_item_show_route">Маршрут от точки</string> <string name="context_menu_item_show_route">Маршрут от точки</string>
<string name="use_trackball_descr">Использовать трекбол, чтобы перемещать карту</string> <string name="use_trackball_descr">Использовать трекбол, чтобы перемещать карту</string>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="continue_follow_previous_route">Previous route was unfinished. Do you want to continue follow with it? </string>
<string name="context_menu_item_search_poi">Search POI</string> <string name="context_menu_item_search_poi">Search POI</string>
<string name="context_menu_item_show_route">Show route from</string> <string name="context_menu_item_show_route">Show route from</string>
<string name="use_trackball_descr">Use trackball to move map</string> <string name="use_trackball_descr">Use trackball to move map</string>

View file

@ -602,6 +602,18 @@ public class OsmandSettings {
} }
public static final String FOLLOW_TO_THE_ROUTE = "follow_to_route"; //$NON-NLS-1$
public static boolean isFollowingByRoute(Context ctx){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.getBoolean(FOLLOW_TO_THE_ROUTE, false);
}
public static boolean setFollowingByRoute(Context ctx, boolean val){
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.edit().putBoolean(FOLLOW_TO_THE_ROUTE, val).commit();
}
} }

View file

@ -212,6 +212,29 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
routingHelper.setFinalAndCurrentLocation(pointToNavigate, null); routingHelper.setFinalAndCurrentLocation(pointToNavigate, null);
} }
if(OsmandSettings.isFollowingByRoute(this)){
if(pointToNavigate == null){
OsmandSettings.setFollowingByRoute(this, false);
} else if(!routingHelper.isRouteCalculated()){
Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.continue_follow_previous_route);
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
routingHelper.setFollowingMode(true);
}
});
builder.setNegativeButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
routingHelper.setFinalLocation(null);
mapView.refreshMap();
}
});
builder.show();
}
}
navigationLayer.setPointToNavigate(pointToNavigate); navigationLayer.setPointToNavigate(pointToNavigate);
@ -752,7 +775,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
private void updateNavigateToPointMenu(){ private void updateNavigateToPointMenu(){
if (navigateToPointMenu != null) { if (navigateToPointMenu != null) {
navigateToPointMenu.setTitle(routingHelper.getFinalLocation() != null ? R.string.stop_routing : R.string.stop_navigation); navigateToPointMenu.setTitle(routingHelper.isRouteCalculated() ? R.string.stop_routing : R.string.stop_navigation);
if (OsmandSettings.getPointToNavigate(this) != null) { if (OsmandSettings.getPointToNavigate(this) != null) {
navigateToPointMenu.setVisible(true); navigateToPointMenu.setVisible(true);
} else { } else {
@ -815,10 +838,9 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
return true; return true;
} else if (item.getItemId() == R.id.map_navigate_to_point) { } else if (item.getItemId() == R.id.map_navigate_to_point) {
if(navigationLayer.getPointToNavigate() != null){ if(navigationLayer.getPointToNavigate() != null){
if(routingHelper.getFinalLocation() != null){ if(routingHelper.isRouteCalculated()){
routingHelper.setFinalAndCurrentLocation(null, null); routingHelper.setFinalAndCurrentLocation(null, null);
routingHelper.setFollowingMode(false); routingHelper.setFollowingMode(false);
mapView.refreshMap();
updateNavigateToPointMenu(); updateNavigateToPointMenu();
} else { } else {
navigateToPoint(null); navigateToPoint(null);
@ -826,6 +848,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
} else { } else {
navigateToPoint(new LatLon(mapView.getLatitude(), mapView.getLongitude())); navigateToPoint(new LatLon(mapView.getLatitude(), mapView.getLongitude()));
} }
mapView.refreshMap();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -849,6 +872,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
} }
routingHelper.setFollowingMode(true); routingHelper.setFollowingMode(true);
routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), location); routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), location);
OsmandSettings.setFollowingByRoute(MapActivity.this, true);
updateNavigateToPointMenu(); updateNavigateToPointMenu();
} }
}); });

View file

@ -133,10 +133,12 @@ public class RoutingHelper {
if(currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < 60){ if(currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < 60){
if(lastFixedLocation != null && lastFixedLocation.distanceTo(lastPoint) < 60){ if(lastFixedLocation != null && lastFixedLocation.distanceTo(lastPoint) < 60){
showMessage(context.getString(R.string.arrived_at_destination)); showMessage(context.getString(R.string.arrived_at_destination));
OsmandSettings.setFollowingByRoute(context, false);
voiceRouter.arrivedDestinationPoint(); voiceRouter.arrivedDestinationPoint();
updateCurrentRoute(routeNodes.size() - 1); updateCurrentRoute(routeNodes.size() - 1);
// clear final location to prevent all time showing message // clear final location to prevent all time showing message
finalLocation = null; finalLocation = null;
} }
lastFixedLocation = currentLocation; lastFixedLocation = currentLocation;
return true; return true;