From 1e8983ce58b2218f8455f1d2c2f3b31714334ffc Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Wed, 9 Dec 2020 13:15:04 +0200 Subject: [PATCH] Truck profile --- .../plus/profiles/RoutingProfileDataObject.java | 1 + .../routepreparationmenu/RoutingOptionsHelper.java | 3 +++ .../plus/settings/backend/ApplicationMode.java | 14 +++++++++----- .../plus/settings/backend/OsmandSettings.java | 5 +++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java b/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java index 3cd3c74293..da6e370fde 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java +++ b/OsmAnd/src/net/osmand/plus/profiles/RoutingProfileDataObject.java @@ -29,6 +29,7 @@ public class RoutingProfileDataObject extends ProfileDataObject { SKI(R.string.routing_profile_ski, R.drawable.ic_action_skiing), PUBLIC_TRANSPORT(R.string.app_mode_public_transport, R.drawable.ic_action_bus_dark), BOAT(R.string.app_mode_boat, R.drawable.ic_action_sail_boat_dark), + TRUCK(R.string.app_mode_truck, R.drawable.ic_action_truck_dark), GEOCODING(R.string.routing_profile_geocoding, R.drawable.ic_action_world_globe); int stringRes; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index d34144cbdc..de3924fe0f 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -1050,6 +1050,7 @@ public class RoutingOptionsHelper { BOAT(MuteSoundRoutingParameter.KEY), AIRCRAFT(MuteSoundRoutingParameter.KEY), SKI(MuteSoundRoutingParameter.KEY, DRIVING_STYLE, GeneralRouter.USE_HEIGHT_OBSTACLES), + TRUCK(MuteSoundRoutingParameter.KEY, AvoidRoadsRoutingParameter.KEY), OTHER(MuteSoundRoutingParameter.KEY); List routingParameters; @@ -1078,6 +1079,8 @@ public class RoutingOptionsHelper { return PermanentAppModeOptions.AIRCRAFT.routingParameters; } else if (appMode.isDerivedRoutingFrom(ApplicationMode.SKI)) { return PermanentAppModeOptions.SKI.routingParameters; + } else if (appMode.isDerivedRoutingFrom(ApplicationMode.TRUCK)) { + return PermanentAppModeOptions.TRUCK.routingParameters; } else { return PermanentAppModeOptions.OTHER.routingParameters; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java index 8c64654b41..b1b98e17f2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java @@ -108,6 +108,10 @@ public class ApplicationMode { .icon(R.drawable.ic_action_skiing) .description(R.string.base_profile_descr_ski).reg(); + public static final ApplicationMode TRUCK = createBase(R.string.app_mode_truck, "ic_action_truck_dark") + .icon(R.drawable.ic_action_truck_dark) + .description(R.string.app_mode_truck).reg(); + public static List values(OsmandApplication app) { if (customizationListener == null) { customizationListener = new OsmAndAppCustomization.OsmAndAppCustomizationListener() { @@ -179,13 +183,13 @@ public class ApplicationMode { } private static void initRegVisibility() { - // DEFAULT, CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI - ApplicationMode[] exceptDefault = new ApplicationMode[] {CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI}; + // DEFAULT, CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI, TRUCK + ApplicationMode[] exceptDefault = new ApplicationMode[] {CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI, TRUCK}; ApplicationMode[] all = null; ApplicationMode[] none = new ApplicationMode[] {}; // left - ApplicationMode[] navigationSet1 = new ApplicationMode[] {CAR, BICYCLE, BOAT, SKI}; + ApplicationMode[] navigationSet1 = new ApplicationMode[] {CAR, BICYCLE, BOAT, SKI, TRUCK}; ApplicationMode[] navigationSet2 = new ApplicationMode[] {PEDESTRIAN, PUBLIC_TRANSPORT, AIRCRAFT}; regWidgetVisibility(WIDGET_NEXT_TURN, navigationSet1); @@ -200,8 +204,8 @@ public class ApplicationMode { regWidgetVisibility(WIDGET_DISTANCE, all); regWidgetVisibility(WIDGET_TIME, all); regWidgetVisibility(WIDGET_INTERMEDIATE_TIME, all); - regWidgetVisibility(WIDGET_SPEED, CAR, BICYCLE, BOAT, SKI, PUBLIC_TRANSPORT, AIRCRAFT); - regWidgetVisibility(WIDGET_MAX_SPEED, CAR); + regWidgetVisibility(WIDGET_SPEED, CAR, BICYCLE, BOAT, SKI, PUBLIC_TRANSPORT, AIRCRAFT, TRUCK); + regWidgetVisibility(WIDGET_MAX_SPEED, CAR, TRUCK); regWidgetVisibility(WIDGET_ALTITUDE, PEDESTRIAN, BICYCLE); regWidgetAvailability(WIDGET_INTERMEDIATE_DISTANCE, all); regWidgetAvailability(WIDGET_DISTANCE, all); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 90c63d3334..f5283854b6 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -936,6 +936,7 @@ public class OsmandSettings { DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.BOAT, 1.38f); DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.AIRCRAFT, 40f); DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.SKI, 1.38f); + DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.TRUCK, 10.5f); } public final OsmandPreference MIN_SPEED = new FloatPreference(this, @@ -955,6 +956,7 @@ public class OsmandSettings { ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BOAT, "ic_action_sail_boat_dark"); ICON_RES_NAME.setModeDefaultValue(ApplicationMode.AIRCRAFT, "ic_action_aircraft"); ICON_RES_NAME.setModeDefaultValue(ApplicationMode.SKI, "ic_action_skiing"); + ICON_RES_NAME.setModeDefaultValue(ApplicationMode.TRUCK, "ic_action_truck_dark"); } public final CommonPreference ICON_COLOR = new EnumStringPreference<>(this, @@ -974,6 +976,7 @@ public class OsmandSettings { ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BOAT, "boat"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.AIRCRAFT, "STRAIGHT_LINE_MODE"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.SKI, "ski"); + ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.TRUCK, "truck"); } public final CommonPreference ROUTE_SERVICE = new EnumStringPreference<>(this, "route_service", RouteService.OSMAND, RouteService.values()).makeProfile().cache(); @@ -992,6 +995,7 @@ public class OsmandSettings { NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.BOAT, NavigationIcon.NAUTICAL); NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.AIRCRAFT, NavigationIcon.DEFAULT); NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.SKI, NavigationIcon.DEFAULT); + NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.TRUCK,NavigationIcon.DEFAULT); } public final CommonPreference LOCATION_ICON = new EnumStringPreference<>(this, "location_icon", LocationIcon.DEFAULT, LocationIcon.values()).makeProfile().cache(); @@ -1003,6 +1007,7 @@ public class OsmandSettings { LOCATION_ICON.setModeDefaultValue(ApplicationMode.BOAT, LocationIcon.DEFAULT); LOCATION_ICON.setModeDefaultValue(ApplicationMode.AIRCRAFT, LocationIcon.CAR); LOCATION_ICON.setModeDefaultValue(ApplicationMode.SKI, LocationIcon.BICYCLE); + LOCATION_ICON.setModeDefaultValue(ApplicationMode.TRUCK, LocationIcon.CAR); } public final CommonPreference APP_MODE_ORDER = new IntPreference(this, "app_mode_order", 0).makeProfile().cache();