diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java index 38370242c33..115db7d83bf 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java @@ -54,6 +54,7 @@ public class ApplicationMode { private ApplicationMode parentAppMode; private int iconRes = R.drawable.ic_world_globe_dark; + private float maxSpeedConfigLimit = 0f; private ApplicationMode(int key, @NonNull String stringKey) { this.keyName = key; @@ -65,49 +66,61 @@ private ApplicationMode(int key, @NonNull String stringKey) { public static final ApplicationMode CAR = createBase(R.string.app_mode_car, "car") .icon(R.drawable.ic_action_car_dark) + .setMaxSpeedConfigLimit(36.11111f) .description(R.string.base_profile_descr_car).reg(); public static final ApplicationMode BICYCLE = createBase(R.string.app_mode_bicycle, "bicycle") .icon(R.drawable.ic_action_bicycle_dark) + .setMaxSpeedConfigLimit(9.166667f) .description(R.string.base_profile_descr_bicycle).reg(); public static final ApplicationMode PEDESTRIAN = createBase(R.string.app_mode_pedestrian, "pedestrian") .icon(R.drawable.ic_action_pedestrian_dark) + .setMaxSpeedConfigLimit(2.777778f) .description(R.string.base_profile_descr_pedestrian).reg(); public static final ApplicationMode TRUCK = create(CAR, R.string.app_mode_truck, "truck") .icon(R.drawable.ic_action_truck_dark) + .setMaxSpeedConfigLimit(36.11111f) .description(R.string.app_mode_truck).reg(); public static final ApplicationMode MOTORCYCLE = create(CAR, R.string.app_mode_motorcycle, "motorcycle") .icon(R.drawable.ic_action_motorcycle_dark) + .setMaxSpeedConfigLimit(36.11111f) .description(R.string.app_mode_motorcycle).reg(); public static final ApplicationMode MOPED = create(BICYCLE, R.string.app_mode_moped, "moped") + .setMaxSpeedConfigLimit(9.722222f) .icon(R.drawable.ic_action_motor_scooter) .description(R.string.app_mode_bicycle).reg(); public static final ApplicationMode PUBLIC_TRANSPORT = createBase(R.string.app_mode_public_transport, "public_transport") .icon(R.drawable.ic_action_bus_dark) + .setMaxSpeedConfigLimit(26.388889f) .description(R.string.base_profile_descr_public_transport).reg(); public static final ApplicationMode TRAIN = createBase(R.string.app_mode_train, "train") .icon(R.drawable.ic_action_train) + .setMaxSpeedConfigLimit(47.222225f) .description(R.string.app_mode_train).reg(); public static final ApplicationMode BOAT = createBase(R.string.app_mode_boat, "boat") .icon(R.drawable.ic_action_sail_boat_dark) + .setMaxSpeedConfigLimit(18.527777f) .description(R.string.base_profile_descr_boat).reg(); public static final ApplicationMode AIRCRAFT = createBase(R.string.app_mode_aircraft, "aircraft") .icon(R.drawable.ic_action_aircraft) + .setMaxSpeedConfigLimit(200f) .description(R.string.base_profile_descr_aircraft).reg(); public static final ApplicationMode SKI = createBase(R.string.app_mode_skiing, "ski") .icon(R.drawable.ic_action_skiing) + .setMaxSpeedConfigLimit(41.666668f) .description(R.string.base_profile_descr_ski).reg(); public static final ApplicationMode HORSE = createBase(R.string.horseback_riding, "horse") .icon(R.drawable.ic_action_horse) + .setMaxSpeedConfigLimit(8.333334f) .description(R.string.horseback_riding).reg(); public static List values(@NonNull OsmandApplication app) { @@ -455,6 +468,10 @@ public void setVersion(int version) { app.getSettings().APP_MODE_VERSION.setModeValue(this, version); } + public float getMaxSpeedConfigLimit() { + return maxSpeedConfigLimit; + } + public static void onApplicationStart(OsmandApplication app) { initCustomModes(app); initModesParams(app); @@ -733,6 +750,11 @@ public ApplicationModeBuilder icon(int iconRes) { return this; } + public ApplicationModeBuilder setMaxSpeedConfigLimit(float maxSpeedConfigLimit) { + applicationMode.maxSpeedConfigLimit = maxSpeedConfigLimit; + return this; + } + public ApplicationModeBuilder description(int strId) { applicationMode.descriptionId = strId; return this; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java index 57ce4a39ac8..626eb51f066 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java @@ -272,7 +272,7 @@ private void showSeekbarSettingsDialog(@NonNull Activity activity, boolean defau float settingsDefaultSpeed = mode.getDefaultSpeed(); boolean decimalPrecision = !defaultSpeedOnly && router != null - && router.getMaxSpeed() <= ApplicationMode.FAST_SPEED_THRESHOLD; + && mode.getMaxSpeedConfigLimit() <= ApplicationMode.FAST_SPEED_THRESHOLD; float[] defaultValue = {roundSpeed(settingsDefaultSpeed * ratio[0], decimalPrecision)}; float[] minValue = new float[1]; @@ -284,17 +284,17 @@ private void showSeekbarSettingsDialog(@NonNull Activity activity, boolean defau minValue[0] = Math.round(Math.min(1, settingsDefaultSpeed) * ratio[0]); maxValue[0] = Math.round(Math.max(300, settingsDefaultSpeed) * ratio[0]); min = (int) minValue[0]; - max = (int) maxValue[0]; } else { float minSpeedValue = settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed(); - float maxSpeedValue = settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed(); + float maxSpeedValue = settingsMaxSpeed > 0 ? settingsMaxSpeed : mode.getMaxSpeedConfigLimit(); minValue[0] = roundSpeed(Math.min(minSpeedValue, settingsDefaultSpeed) * ratio[0], decimalPrecision); maxValue[0] = roundSpeed(Math.max(maxSpeedValue, settingsDefaultSpeed) * ratio[0], decimalPrecision); min = Math.round(Math.min(minValue[0], router.getMinSpeed() * ratio[0] / 2f)); - max = Math.round(Math.max(maxValue[0], router.getMaxSpeed() * ratio[0] * 1.5f)); } + max = Math.round(Math.max(maxValue[0], mode.getMaxSpeedConfigLimit() * ratio[0] * 1.5f)); + max = Math.max(min, max); boolean nightMode = !app.getSettings().isLightContentForMode(mode); Context themedContext = UiUtilities.getThemedContext(activity, nightMode);