From ae249e1185cc6b2a7262b29484e71d5ed1bf8407 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 16:57:41 +0200 Subject: [PATCH] Add constant for "public_transport" --- .../java/net/osmand/router/TransportRoutingConfiguration.java | 2 -- .../osmand/plus/measurementtool/MeasurementToolFragment.java | 3 ++- OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java | 4 +++- .../RouteBetweenPointsBottomSheetDialogFragment.java | 3 ++- .../src/net/osmand/plus/routing/TransportRoutingHelper.java | 2 ++ .../src/net/osmand/plus/settings/backend/OsmandSettings.java | 3 ++- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java index c350204b52..9b61aec963 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java @@ -10,8 +10,6 @@ import net.osmand.router.GeneralRouter.RouteDataObjectAttribute; public class TransportRoutingConfiguration { - public static final String KEY = "public_transport"; - public int ZOOM_TO_LOAD_TILES = 15; public int walkRadius = 1500; // ? 3000 diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 38a24b37a5..6165e0e4bc 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -106,6 +106,7 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, @@ -897,7 +898,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route case SnapTrackWarningFragment.CONTINUE_RESULT_CODE: if (mapActivity != null) { ApplicationMode mode = editingCtx.getAppMode(); - if (mode == ApplicationMode.DEFAULT || "public_transport".equals(mode.getRoutingProfile())) { + if (mode == ApplicationMode.DEFAULT || PUBLIC_TRANSPORT_KEY.equals(mode.getRoutingProfile())) { mode = null; } List> pointsSegments = editingCtx.getPointsSegments(true, false); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java index 179ad54645..8b6d615d9c 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; + public class ProfileCard extends BaseCard { private ApplicationMode selectedMode; @@ -42,7 +44,7 @@ public class ProfileCard extends BaseCard { Iterator iterator = modes.iterator(); while (iterator.hasNext()) { ApplicationMode mode = iterator.next(); - if ("public_transport".equals(mode.getRoutingProfile())) { + if (PUBLIC_TRANSPORT_KEY.equals(mode.getRoutingProfile())) { iterator.remove(); } } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java index 12eff78327..fec2f6379d 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java @@ -35,6 +35,7 @@ import static net.osmand.plus.UiUtilities.CustomRadioButtonType.END; import static net.osmand.plus.UiUtilities.CustomRadioButtonType.START; import static net.osmand.plus.measurementtool.MeasurementEditingContext.DEFAULT_APP_MODE; import static net.osmand.plus.measurementtool.SelectFileBottomSheet.BOTTOM_SHEET_HEIGHT_DP; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBehaviourDialogFragment { @@ -116,7 +117,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBeha for (int i = 0; i < modes.size(); i++) { ApplicationMode mode = modes.get(i); - if (!"public_transport".equals(mode.getRoutingProfile())) { + if (!PUBLIC_TRANSPORT_KEY.equals(mode.getRoutingProfile())) { icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); addProfileView(navigationType, onClickListener, i, icon, mode.toHumanString(), mode.equals(appMode)); } diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 637e3078e7..9f56f6d633 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -55,6 +55,8 @@ public class TransportRoutingHelper { private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(TransportRoutingHelper.class); + public static final String PUBLIC_TRANSPORT_KEY = "public_transport"; + private List> listeners = new LinkedList<>(); private final OsmandApplication app; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index ec7d2b067f..4b9d981c59 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -84,6 +84,7 @@ import java.util.StringTokenizer; import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONFIGURE_MAP_ITEM_ID_SCHEME; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ACTIONS; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class OsmandSettings { @@ -998,7 +999,7 @@ public class OsmandSettings { ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.CAR, "car"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BICYCLE, "bicycle"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, "pedestrian"); - ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, "public_transport"); + ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, PUBLIC_TRANSPORT_KEY); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BOAT, "boat"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.AIRCRAFT, "STRAIGHT_LINE_MODE"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.SKI, "ski");