From 5a62f55a5b304911123d531af1727b28c54e7b8d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 13 Feb 2020 16:54:41 +0200 Subject: [PATCH] Custom routing config initial commit --- .../src/net/osmand/plus/AppInitializer.java | 27 +++++++----- .../osmand/plus/CurrentPositionHelper.java | 4 +- .../net/osmand/plus/OsmandApplication.java | 42 ++++++++++++------- .../SettingsNavigationActivity.java | 4 +- .../plus/helpers/AvoidSpecificRoads.java | 8 ++-- .../net/osmand/plus/helpers/ImportHelper.java | 9 ++-- ...electProfileBottomSheetDialogFragment.java | 5 ++- .../RoutingOptionsHelper.java | 8 ++-- .../osmand/plus/routing/RouteProvider.java | 6 +-- .../plus/routing/TransportRoutingHelper.java | 2 +- .../plus/settings/NavigationFragment.java | 42 +++++++++++-------- .../settings/RouteParametersFragment.java | 2 +- .../settings/VehicleParametersFragment.java | 6 ++- 13 files changed, 97 insertions(+), 68 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index a73fb8aa4f..cc3c472880 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -69,8 +69,10 @@ import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Random; import btools.routingapp.BRouterServiceConnection; @@ -593,19 +595,23 @@ public class AppInitializer implements IProgress { } public static void loadRoutingFiles(final OsmandApplication app, final LoadRoutingFilesCallback callback) { - new AsyncTask() { - + new AsyncTask>() { + @Override - protected RoutingConfiguration.Builder doInBackground(Void... voids) { + protected Map doInBackground(Void... voids) { + Map customConfigs = new HashMap<>(); File routingFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR); - RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault(); + RoutingConfiguration.Builder defaultBuilder = RoutingConfiguration.getDefault(); if (routingFolder.isDirectory()) { File[] fl = routingFolder.listFiles(); if (fl != null && fl.length > 0) { for (File f : fl) { - if (f.isFile() && f.getName().endsWith(".xml") && f.canRead()) { + if (f.isFile() && f.getName().endsWith(IndexConstants.ROUTING_FILE_EXT) && f.canRead()) { try { - RoutingConfiguration.parseFromInputStream(new FileInputStream(f), f.getName(), builder); + String fileName = f.getName(); + RoutingConfiguration.Builder builder = new RoutingConfiguration.Builder(); + RoutingConfiguration.parseFromInputStream(new FileInputStream(f), fileName, builder); + customConfigs.put(fileName, builder); } catch (XmlPullParserException | IOException e) { throw new IllegalStateException(e); } @@ -613,13 +619,14 @@ public class AppInitializer implements IProgress { } } } - return builder; + return customConfigs; } @Override - protected void onPostExecute(RoutingConfiguration.Builder builder) { - super.onPostExecute(builder); - app.updateRoutingConfig(builder); + protected void onPostExecute(Map customConfigs) { + if (!customConfigs.isEmpty()) { + app.getCustomRoutingConfigs().putAll(customConfigs); + } callback.onRoutingFilesLoaded(); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 5787b62a44..7bf295d4d8 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -137,11 +137,11 @@ public class CurrentPositionHelper { for (BinaryMapReaderResource rep : checkReaders) { rs[i++] = rep.getReader(BinaryMapReaderResourceType.STREET_LOOKUP); } - RoutingConfiguration cfg = app.getRoutingConfig().build(p, 10, + RoutingConfiguration cfg = app.getRoutingConfigForMode(am).build(p, 10, new HashMap()); cfg.routeCalculationTime = System.currentTimeMillis(); ctx = new RoutePlannerFrontEnd().buildRoutingContext(cfg, null, rs); - RoutingConfiguration defCfg = app.getRoutingConfig().build("geocoding", 10, + RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build("geocoding", 10, new HashMap()); defCtx = new RoutePlannerFrontEnd().buildRoutingContext(defCfg, null, rs); } else { diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 1fa59571b7..245e786059 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -25,12 +25,9 @@ import android.support.v7.app.AlertDialog; import android.text.format.DateFormat; import android.view.View; import android.view.accessibility.AccessibilityManager; -import android.widget.ImageView; -import android.widget.TextView; import android.widget.Toast; import net.osmand.AndroidUtils; -import net.osmand.CallbackWithObject; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.access.AccessibilityPlugin; @@ -59,7 +56,6 @@ import net.osmand.plus.helpers.AvoidSpecificRoads; import net.osmand.plus.helpers.LockHelper; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; -import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.monitoring.LiveMonitoringHelper; import net.osmand.plus.poi.PoiFiltersHelper; @@ -84,11 +80,15 @@ import java.io.PrintStream; import java.lang.Thread.UncaughtExceptionHandler; import java.util.ArrayList; import java.util.Locale; +import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import btools.routingapp.BRouterServiceConnection; import btools.routingapp.IBRouterService; +import static net.osmand.IndexConstants.ROUTING_FILE_EXT; + public class OsmandApplication extends MultiDexApplication { public static final String EXCEPTION_PATH = "exception.log"; public static final String OSMAND_PRIVACY_POLICY_URL = "https://osmand.net/help-online/privacy-policy"; @@ -143,7 +143,8 @@ public class OsmandApplication extends MultiDexApplication { private Resources localizedResources; - private RoutingConfiguration.Builder routingConfig; + private Map customRoutingConfigs = new ConcurrentHashMap<>(); + private Locale preferredLocale = null; private Locale defaultLocale; private File externalStorageDirectory; @@ -810,18 +811,29 @@ public class OsmandApplication extends MultiDexApplication { return localizedResources != null ? localizedResources : super.getResources(); } - public synchronized RoutingConfiguration.Builder getRoutingConfig() { - RoutingConfiguration.Builder rc; - if(routingConfig == null) { - rc = new RoutingConfiguration.Builder(); - } else { - rc = routingConfig; - } - return rc; + public RoutingConfiguration.Builder getDefaultRoutingConfig() { + return RoutingConfiguration.getDefault(); } - public void updateRoutingConfig(Builder update) { - routingConfig = update; + public Map getCustomRoutingConfigs() { + return customRoutingConfigs; + } + + public RoutingConfiguration.Builder getCustomRoutingConfig(String key) { + return customRoutingConfigs.get(key); + } + + public synchronized RoutingConfiguration.Builder getRoutingConfigForMode(ApplicationMode mode) { + RoutingConfiguration.Builder builder = null; + String routingProfileKey = mode.getRoutingProfile(); + if (!Algorithms.isEmpty(routingProfileKey)) { + int index = routingProfileKey.indexOf(ROUTING_FILE_EXT); + if (index != -1) { + String configKey = routingProfileKey.substring(0, index + ROUTING_FILE_EXT.length()); + builder = customRoutingConfigs.get(configKey); + } + } + return builder != null ? builder : getDefaultRoutingConfig(); } public OsmandRegions getRegions() { diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 669570e088..fc7a73a7fc 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -314,7 +314,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { cat.addPreference(fastRoute); } else { ApplicationMode am = settings.getApplicationMode(); - GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am); + GeneralRouter router = getRouter(getMyApplication().getRoutingConfigForMode(am), am); clearParameters(); if (router != null) { GeneralRouterProfile routerProfile = router.getProfile(); @@ -728,7 +728,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandSettings settings = app.getSettings(); - GeneralRouter router = getRouter(app.getRoutingConfig(), mode); + GeneralRouter router = getRouter(app.getRoutingConfigForMode(mode), mode); SpeedConstants units = settings.SPEED_SYSTEM.getModeValue(mode); String speedUnits = units.toShortString(activity); final float[] ratio = new float[1]; diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index d8cc1f4def..0ee97d3b69 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -162,7 +162,7 @@ public class AvoidSpecificRoads { app.getSettings().removeImpassableRoad(latLon); RouteDataObject obj = impassableRoads.remove(latLon); if (obj != null) { - app.getRoutingConfig().removeImpassableRoad(obj); + app.getDefaultRoutingConfig().removeImpassableRoad(obj); } } @@ -288,7 +288,7 @@ public class AvoidSpecificRoads { final LatLon oldLoc = getLocation(currentObject); app.getSettings().moveImpassableRoad(oldLoc, newLoc); impassableRoads.remove(oldLoc); - app.getRoutingConfig().removeImpassableRoad(currentObject); + app.getDefaultRoutingConfig().removeImpassableRoad(currentObject); addImpassableRoadInternal(object, ll, showDialog, activity, newLoc); if (callback != null) { @@ -310,7 +310,7 @@ public class AvoidSpecificRoads { boolean showDialog, @Nullable MapActivity activity, @NonNull LatLon loc) { - if (app.getRoutingConfig().addImpassableRoad(object, ll)) { + if (app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) { impassableRoads.put(loc, object); } else { LatLon location = getLocation(object); @@ -339,7 +339,7 @@ public class AvoidSpecificRoads { } public LatLon getLocation(RouteDataObject object) { - Location location = app.getRoutingConfig().getImpassableRoadLocations().get(object.getId()); + Location location = app.getDefaultRoutingConfig().getImpassableRoadLocations().get(object.getId()); return location == null ? null : new LatLon(location.getLatitude(), location.getLongitude()); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index ecdfdf49aa..adf0707463 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -55,7 +55,6 @@ import net.osmand.router.RoutingConfiguration; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; -import org.xmlpull.v1.XmlPullParserException; import java.io.ByteArrayInputStream; import java.io.File; @@ -661,7 +660,7 @@ public class ImportHelper { } @SuppressLint("StaticFieldLeak") - private void handleRoutingFileImport(final Uri uri, final String fileName, final CallbackWithObject callback) { + private void handleRoutingFileImport(final Uri uri, final String fileName, final CallbackWithObject callback) { final AsyncTask routingImportTask = new AsyncTask() { String mFileName; @@ -698,11 +697,11 @@ public class ImportHelper { if (isActivityNotDestroyed(activity)) { progress.dismiss(); } - String profileKey = app.getRoutingConfig().getRoutingProfileKeyByFileName(mFileName); - if (profileKey != null) { + RoutingConfiguration.Builder builder = app.getCustomRoutingConfig(mFileName); + if (builder != null) { app.showShortToastMessage(app.getString(R.string.file_imported_successfully, mFileName)); if (callback != null) { - callback.processResult(profileKey); + callback.processResult(builder); } } else { app.showToastMessage(app.getString(R.string.file_does_not_contain_routing_rules, mFileName)); diff --git a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java index f968291d6e..1d7b25c1f1 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SelectProfileBottomSheetDialogFragment.java @@ -30,6 +30,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.settings.MainSettingsFragment; import net.osmand.plus.settings.NavigationFragment; import net.osmand.plus.settings.ProfileAppearanceFragment; +import net.osmand.router.RoutingConfiguration; import org.apache.commons.logging.Log; @@ -160,9 +161,9 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo return; } mapActivity.getImportHelper().chooseFileToImport(ROUTING, false, - new CallbackWithObject() { + new CallbackWithObject() { @Override - public boolean processResult(String profileKey) { + public boolean processResult(RoutingConfiguration.Builder builder) { refreshView(); return false; } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index eae018184e..8e9613c844 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -409,7 +409,7 @@ public class RoutingOptionsHelper { public LocalRoutingParameter getRoutingParameterInnerById(ApplicationMode am, String parameterId) { RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute(); - GeneralRouter rm = getRouter(app.getRoutingConfig(), am); + GeneralRouter rm = getRouter(app.getRoutingConfigForMode(am), am); if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) { return null; } @@ -493,7 +493,7 @@ public class RoutingOptionsHelper { RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute(); List list = new ArrayList(getGpxRouterParameters(am)); - GeneralRouter rm = SettingsNavigationActivity.getRouter(app.getRoutingConfig(), am); + GeneralRouter rm = SettingsNavigationActivity.getRouter(app.getRoutingConfigForMode(am), am); if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) { return list; } @@ -583,7 +583,7 @@ public class RoutingOptionsHelper { public List getAvoidRoutingPrefsForAppMode(ApplicationMode applicationMode) { List avoidParameters = new ArrayList(); - GeneralRouter router = getRouter(app.getRoutingConfig(), applicationMode); + GeneralRouter router = getRouter(app.getRoutingConfigForMode(applicationMode), applicationMode); if (router != null) { for (Map.Entry e : router.getParameters().entrySet()) { String param = e.getKey(); @@ -597,7 +597,7 @@ public class RoutingOptionsHelper { } public GeneralRouter.RoutingParameter getRoutingPrefsForAppModeById(ApplicationMode applicationMode, String parameterId) { - GeneralRouter router = getRouter(app.getRoutingConfig(), applicationMode); + GeneralRouter router = getRouter(app.getRoutingConfigForMode(applicationMode), applicationMode); GeneralRouter.RoutingParameter parameter = null; if (router != null) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index f24a47851a..649e008c19 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -597,10 +597,10 @@ public class RouteProvider { RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(); OsmandSettings settings = params.ctx.getSettings(); router.setUseFastRecalculation(settings.USE_FAST_RECALCULATION.get()); - - RoutingConfiguration.Builder config = params.ctx.getRoutingConfig(); + + RoutingConfiguration.Builder config = params.ctx.getRoutingConfigForMode(params.mode); GeneralRouter generalRouter = SettingsNavigationActivity.getRouter(config, params.mode); - if(generalRouter == null) { + if (generalRouter == null) { return applicationModeNotSupported(params); } RoutingConfiguration cf = initOsmAndRoutingConfig(config, params, settings, generalRouter); diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 368daa4793..c1d4616cb9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -452,7 +452,7 @@ public class TransportRoutingHelper { } private List calculateRouteImpl(TransportRouteCalculationParams params) throws IOException, InterruptedException { - RoutingConfiguration.Builder config = params.ctx.getRoutingConfig(); + RoutingConfiguration.Builder config = params.ctx.getRoutingConfigForMode(params.mode); BinaryMapIndexReader[] files = params.ctx.getResourceManager().getTransportRoutingMapFiles(); params.params.clear(); OsmandSettings settings = params.ctx.getSettings(); diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 82f80519eb..5bcc1eab81 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -19,6 +19,7 @@ import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment; import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.router.GeneralRouter; +import net.osmand.router.RoutingConfiguration; import net.osmand.util.Algorithms; import java.util.ArrayList; @@ -158,7 +159,7 @@ public class NavigationFragment extends BaseSettingsFragment { RouteProvider.RouteService routeService; if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) { routeService = RouteProvider.RouteService.STRAIGHT; - } else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())){ + } else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())) { routeService = RouteProvider.RouteService.DIRECT_TO; } else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) { routeService = RouteProvider.RouteService.BROUTER; @@ -227,26 +228,33 @@ public class NavigationFragment extends BaseSettingsFragment { false, null)); } - Map inputProfiles = context.getRoutingConfig().getAllRouters(); - for (Map.Entry e : inputProfiles.entrySet()) { - if (!e.getKey().equals("geocoding")) { - int iconRes = R.drawable.ic_action_gdirections_dark; - String name = e.getValue().getProfileName(); - String description = context.getString(R.string.osmand_default_routing); - if (!Algorithms.isEmpty(e.getValue().getFilename())) { - description = e.getValue().getFilename(); - } else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) { - iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes(); - name = context - .getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes()); - } - profilesObjects.put(e.getKey(), new RoutingProfileDataObject(e.getKey(), name, description, - iconRes, false, e.getValue().getFilename())); - } + collectRoutingProfilesFromConfig(context, context.getDefaultRoutingConfig(), profilesObjects); + for (RoutingConfiguration.Builder builder : context.getCustomRoutingConfigs().values()) { + collectRoutingProfilesFromConfig(context, builder, profilesObjects); } return profilesObjects; } + private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder, Map profilesObjects) { + for (Map.Entry entry : builder.getAllRouters().entrySet()) { + String routerKey = entry.getKey(); + GeneralRouter router = entry.getValue(); + if (!routerKey.equals("geocoding")) { + int iconRes = R.drawable.ic_action_gdirections_dark; + String name = router.getProfileName(); + String description = app.getString(R.string.osmand_default_routing); + if (!Algorithms.isEmpty(router.getFilename())) { + description = router.getFilename(); + } else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) { + iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes(); + name = app.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes()); + } + profilesObjects.put(routerKey, new RoutingProfileDataObject(routerKey, name, description, + iconRes, false, router.getFilename())); + } + } + } + public static List getBaseProfiles(Context ctx) { List profiles = new ArrayList<>(); for (ApplicationMode mode : ApplicationMode.getDefaultValues()) { diff --git a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java index 43ff4efddc..247028b150 100644 --- a/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/RouteParametersFragment.java @@ -140,7 +140,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP if (am.getRouteService() != RouteProvider.RouteService.OSMAND) { screen.addPreference(fastRoute); } else { - GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am); + GeneralRouter router = getRouter(app.getRoutingConfigForMode(am), am); clearParameters(); if (router != null) { Map parameters = router.getParameters(); diff --git a/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java index 35abeb4911..8bef67b69a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java @@ -6,6 +6,7 @@ import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceViewHolder; import android.widget.ImageView; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -38,9 +39,10 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark)); vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString())); - RouteService routeService = getSelectedAppMode().getRouteService(); + ApplicationMode mode = getSelectedAppMode(); + RouteService routeService = mode.getRouteService(); if (routeService == RouteService.OSMAND) { - GeneralRouter router = getRouter(app.getRoutingConfig(), getSelectedAppMode()); + GeneralRouter router = getRouter(app.getRoutingConfigForMode(mode), mode); if (router != null) { Map parameters = router.getParameters();