From 04ad9899384842dd45804bc83d76843d5bdb0ad7 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 29 May 2012 19:44:18 +0200 Subject: [PATCH] Add left side navigation option and let user be aware of offline navigation turned off --- OsmAnd/res/values/strings.xml | 3 +++ OsmAnd/res/xml/settings_pref.xml | 7 +++++-- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 ++ .../net/osmand/plus/activities/SettingsActivity.java | 8 +++++++- OsmAnd/src/net/osmand/plus/routing/RouteProvider.java | 11 ++++++++--- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f824634617..3d30c6600e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -8,6 +8,9 @@ If you are making/correcting english translations make sure : 1. All your modified/created strings are in the top of the file (to make easier find what's translated). --> + Osmand offline navigation is temporarily not available. + Left Side Navigation + Turn on if you navigate in left side countries Download or update offline data. \nTo see more details click on the item, to deactivate or delete offline data press and hold. \nCurrent data on device (%1$s free): Starting location is not yet determined Position not yet known diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index 494f60865b..1a4f0c1906 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -27,9 +27,12 @@ + android:key="use_osmand_routing_service"> + --> + + diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 367bbb79f2..58c6291e75 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -565,6 +565,8 @@ public class OsmandSettings { // make cloudmade by default why osmand is not stable enough public final OsmandPreference ROUTER_SERVICE = new EnumIntPreference("router_service", RouteService.CLOUDMADE, false, RouteService.values()); + + public final CommonPreference LEFT_SIDE_NAVIGATION = new BooleanPreference("left_side_navigation", false, true); // this value string is synchronized with settings_pref.xml preference name diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 453b74b77c..4d91e6796d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -235,7 +235,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference registerBooleanPreference(osmandSettings.USE_ENGLISH_NAMES,screen); registerBooleanPreference(osmandSettings.AUTO_ZOOM_MAP,screen); registerBooleanPreference(osmandSettings.FAST_ROUTE_MODE,screen); - registerBooleanPreference(osmandSettings.USE_OSMAND_ROUTING_SERVICE_ALWAYS,screen); + registerBooleanPreference(osmandSettings.USE_OSMAND_ROUTING_SERVICE_ALWAYS,screen); + registerBooleanPreference(osmandSettings.LEFT_SIDE_NAVIGATION,screen); registerBooleanPreference(osmandSettings.SHOW_ALTITUDE_INFO,screen); @@ -509,6 +510,11 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference } else { getMyApplication().showDialogInitializingCommandPlayer(this, false); } + } else if (listPref.getId().equals(osmandSettings.ROUTER_SERVICE.getId())) { + // TO Delete when it will be available + if (osmandSettings.ROUTER_SERVICE.get() == RouteService.OSMAND) { + AccessibleToast.makeText(this, R.string.offline_navigation_not_available, Toast.LENGTH_LONG).show(); + } } else if (listPref.getId().equals(osmandSettings.APPLICATION_MODE.getId())) { updateAllSettings(); } else if (listPref.getId().equals(osmandSettings.PREFERRED_LOCALE.getId())) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index df7738706e..6826120723 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -25,6 +25,7 @@ import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.LogUtil; import net.osmand.OsmAndFormatter; +import net.osmand.access.AccessibleToast; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; @@ -50,6 +51,7 @@ import org.xml.sax.SAXException; import android.content.Context; import android.location.Location; +import android.widget.Toast; public class RouteProvider { private static final org.apache.commons.logging.Log log = LogUtil.getLog(RouteProvider.class); @@ -268,10 +270,13 @@ public class RouteProvider { } else if (type == RouteService.ORS) { res = findORSRoute(start, end, mode, fast); addMissingTurnsToRoute(res, start, end, mode, ctx); - } else if (type == RouteService.OSMAND) { - res = findVectorMapsRoute(start, end, mode, fast, (OsmandApplication)ctx.getApplicationContext()); - addMissingTurnsToRoute(res, start, end, mode, ctx); +// } else if (type == RouteService.OSMAND) { +// res = findVectorMapsRoute(start, end, mode, fast, (OsmandApplication)ctx.getApplicationContext()); +// addMissingTurnsToRoute(res, start, end, mode, ctx); } else { + if (type == RouteService.OSMAND) { + AccessibleToast.makeText(ctx, R.string.offline_navigation_not_available, Toast.LENGTH_LONG).show(); + } res = findCloudMadeRoute(start, end, mode, ctx, fast); // for test purpose addMissingTurnsToRoute(res, start, end, mode, ctx);