diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 72fb10e393..cd194a60a5 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + You can use Elevation data for consideration of Ascent / Descent for your trip OsmAnd shows photos from several sources:\nOpenPlaceReviews - POI photos;\nMapillary - street-level imagery;\nWeb / Wikimedia - POI photos specified in OpenStreetMap data. Use dev.openstreetmap.org Switch to use "dev.openstreetmap.org" instead of "openstreetmap.org" to testing uploading OSM Note / POI / GPX. diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index d18537bfb8..d2f01fe4c2 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -46,15 +46,20 @@ import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.bottomsheets.ElevationDateBottomSheet; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.router.GeneralRouter; import net.osmand.util.Algorithms; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE; +import static net.osmand.plus.settings.fragments.RouteParametersFragment.RELIEF_SMOOTHNESS_FACTOR; +import static net.osmand.router.GeneralRouter.USE_HEIGHT_OBSTACLES; public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { @@ -436,18 +441,27 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { } else { builder.setChecked(parameter.isSelected(settings)); } + builder.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter); - boolean selected = !parameter.isSelected(settings); - routingOptionsHelper.applyRoutingParameter(parameter, selected); - item[0].setChecked(selected); - int iconId = selected ? parameter.getActiveIconId() : parameter.getDisabledIconId(); - if (iconId != -1) { - item[0].setIcon(getContentIcon(iconId)); + GeneralRouter router = app.getRouter(applicationMode); + List reliefFactorParameters = new ArrayList(); + Map parameters = router.getParameters(); + for (Map.Entry e : parameters.entrySet()) { + GeneralRouter.RoutingParameter routingParameter = e.getValue(); + if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) { + reliefFactorParameters.add(routingParameter); + } + } + if (!reliefFactorParameters.isEmpty() && parameter.getKey().equals(USE_HEIGHT_OBSTACLES)) { + FragmentManager fragmentManager = getFragmentManager(); + if (fragmentManager != null) { + ElevationDateBottomSheet.showInstance(fragmentManager, reliefFactorParameters, applicationMode, RouteOptionsBottomSheet.this, false); + } + } else { + applyParameter(item[0], parameter); } - updateMenu(); } }); } @@ -459,6 +473,18 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { } } + private void applyParameter(BottomSheetItemWithCompoundButton bottomSheetItem, LocalRoutingParameter parameter) { + routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter); + boolean selected = !parameter.isSelected(settings); + routingOptionsHelper.applyRoutingParameter(parameter, selected); + bottomSheetItem.setChecked(selected); + int iconId = selected ? parameter.getActiveIconId() : parameter.getDisabledIconId(); + if (iconId != -1) { + bottomSheetItem.setIcon(getContentIcon(iconId)); + } + updateMenu(); + } + private void updateMenu() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 065fd2113a..90c63d3334 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -97,7 +97,7 @@ public class OsmandSettings { private static String CUSTOM_SHARED_PREFERENCES_NAME; private static final String RENDERER_PREFERENCE_PREFIX = "nrenderer_"; - private static final String ROUTING_PREFERENCE_PREFIX = "prouting_"; + public static final String ROUTING_PREFERENCE_PREFIX = "prouting_"; /// Settings variables private final OsmandApplication ctx; diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index 3730833d4d..98c4397327 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -9,21 +9,22 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.BooleanPreference; -import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.BooleanPreference; +import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.fragments.ApplyQueryType; import net.osmand.plus.settings.fragments.OnConfirmPreferenceChange; import net.osmand.plus.settings.fragments.OnPreferenceChanged; @@ -39,7 +40,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { @Override public void createMenuItems(Bundle savedInstanceState) { - OsmandApplication app = getMyApplication(); + final OsmandApplication app = getMyApplication(); if (app == null) { return; } @@ -72,7 +73,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { .setChecked(checked) .setTitle(checked ? on : off) .setTitleColorId(checked ? activeColor : disabledColor) - .setCustomView(getCustomButtonView(checked)) + .setCustomView(getCustomButtonView(app, getAppMode(), checked, nightMode)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -91,7 +92,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { preferenceBtn[0].setTitle(newValue ? on : off); preferenceBtn[0].setChecked(newValue); preferenceBtn[0].setTitleColorId(newValue ? activeColor : disabledColor); - updateCustomButtonView(v, newValue); + updateCustomButtonView(app, getAppMode(), v, newValue, nightMode); if (targetFragment instanceof OnPreferenceChanged) { ((OnPreferenceChanged) targetFragment).onPreferenceChanged(switchPreference.getKey()); @@ -121,25 +122,24 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { return R.string.shared_string_cancel; } - protected View getCustomButtonView(boolean checked) { - View customView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.bottom_sheet_item_preference_switch, null); - updateCustomButtonView(customView, checked); + protected static View getCustomButtonView(OsmandApplication app, ApplicationMode mode, boolean checked, boolean nightMode) { + View customView = UiUtilities.getInflater(app, nightMode).inflate(R.layout.bottom_sheet_item_preference_switch, null); + updateCustomButtonView(app, mode, customView, checked, nightMode); return customView; } - protected void updateCustomButtonView(View customView, boolean checked) { - OsmandApplication app = requiredMyApplication(); + protected static void updateCustomButtonView(OsmandApplication app, ApplicationMode mode, View customView, boolean checked, boolean nightMode) { Context themedCtx = UiUtilities.getThemedContext(app, nightMode); View buttonView = customView.findViewById(R.id.button_container); - int colorRes = getAppMode().getIconColorInfo().getColor(nightMode); - int color = checked ? getResolvedColor(colorRes) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic); + int colorRes = mode.getIconColorInfo().getColor(nightMode); + int color = checked ? ContextCompat.getColor(themedCtx, colorRes) : AndroidUtils.getColorFromAttr(themedCtx, R.attr.divider_color_basic); int bgColor = UiUtilities.getColorWithAlpha(color, checked ? 0.1f : 0.5f); int selectedColor = UiUtilities.getColorWithAlpha(color, checked ? 0.3f : 0.5f); + int bgResId = R.drawable.rectangle_rounded_right; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { - int bgResId = R.drawable.rectangle_rounded_right; int selectableResId = R.drawable.ripple_rectangle_rounded_right; Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor); @@ -147,7 +147,6 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { Drawable[] layers = {bgDrawable, selectable}; AndroidUtils.setBackground(buttonView, new LayerDrawable(layers)); } else { - int bgResId = R.drawable.rectangle_rounded_right; Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor); AndroidUtils.setBackground(buttonView, bgDrawable); } @@ -158,8 +157,8 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { } public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap, - @Nullable ApplicationMode appMode, ApplyQueryType applyQueryType, - boolean profileDependent) { + @Nullable ApplicationMode appMode, ApplyQueryType applyQueryType, + boolean profileDependent) { try { if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) { Bundle args = new Bundle(); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java new file mode 100644 index 0000000000..49785bda09 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java @@ -0,0 +1,195 @@ +package net.osmand.plus.settings.bottomsheets; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; + +import net.osmand.AndroidUtils; +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; +import net.osmand.plus.routing.RoutingHelper; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.BooleanPreference; +import net.osmand.plus.settings.fragments.BaseSettingsFragment; +import net.osmand.plus.settings.fragments.OnPreferenceChanged; +import net.osmand.router.GeneralRouter.RoutingParameter; + +import org.apache.commons.logging.Log; + +import java.util.ArrayList; +import java.util.List; + +import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView; +import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView; +import static net.osmand.plus.settings.fragments.RouteParametersFragment.setRoutingParameterSelected; +import static net.osmand.router.GeneralRouter.USE_HEIGHT_OBSTACLES; + +public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment { + + public static final String TAG = ElevationDateBottomSheet.class.getSimpleName(); + + private static final Log LOG = PlatformUtil.getLog(ElevationDateBottomSheet.class); + + private OsmandApplication app; + private ApplicationMode appMode; + private List reliefFactorParameters = new ArrayList(); + private static final String SELECTED_ENTRY_INDEX_KEY = "selected_entry_index_key"; + + private final List reliefFactorButtons = new ArrayList<>(); + private int selectedEntryIndex = -1; + + public void setAppMode(ApplicationMode appMode) { + this.appMode = appMode; + } + + public ApplicationMode getAppMode() { + return appMode != null ? appMode : app.getSettings().getApplicationMode(); + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + app = requiredMyApplication(); + Context ctx = requireContext(); + int contentPaddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small); + + final BooleanPreference pref = (BooleanPreference) app.getSettings().getCustomRoutingBooleanProperty(USE_HEIGHT_OBSTACLES, false); + + Context themedCtx = UiUtilities.getThemedContext(ctx, nightMode); + + final String on = getString(R.string.shared_string_enable); + final String off = getString(R.string.shared_string_disable); + final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); + final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); + if (savedInstanceState != null) { + selectedEntryIndex = savedInstanceState.getInt(SELECTED_ENTRY_INDEX_KEY); + } + boolean checked = pref.getModeValue(getAppMode()); + final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1]; + preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() + .setChecked(checked) + .setTitle(checked ? on : off) + .setTitleColorId(checked ? activeColor : disabledColor) + .setCustomView(getCustomButtonView(app, getAppMode(), checked, nightMode)) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean newValue = !pref.getModeValue(getAppMode()); + enableItems(newValue); + Fragment targetFragment = getTargetFragment(); + pref.setModeValue(getAppMode(), newValue); + + preferenceBtn[0].setTitle(newValue ? on : off); + preferenceBtn[0].setChecked(newValue); + preferenceBtn[0].setTitleColorId(newValue ? activeColor : disabledColor); + updateCustomButtonView(app, getAppMode(), v, newValue, nightMode); + + if (targetFragment instanceof OnPreferenceChanged) { + ((OnPreferenceChanged) targetFragment).onPreferenceChanged(pref.getId()); + } + if (targetFragment instanceof BaseSettingsFragment) { + ((BaseSettingsFragment) targetFragment).updateSetting(pref.getId()); + } + } + }) + .create(); + preferenceBtn[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode)); + items.add(new TitleItem(getString(R.string.routing_attr_height_obstacles_name))); + items.add(preferenceBtn[0]); + items.add(new DividerSpaceItem(getMyApplication(), contentPaddingSmall)); + items.add(new LongDescriptionItem(getString(R.string.elevation_data))); + items.add(new DividerSpaceItem(getMyApplication(), contentPaddingSmall)); + + for (int i = 0; i < reliefFactorParameters.size(); i++) { + RoutingParameter parameter = reliefFactorParameters.get(i); + final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1]; + preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() + .setChecked(i == selectedEntryIndex) + .setButtonTintList(AndroidUtils.createCheckedColorStateList(ctx, R.color.icon_color_default_light, getAppMode().getIconColorInfo().getColor(nightMode))) + .setTitle(getRoutingParameterTitle(app, parameter)) + .setTag(i) + .setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectedEntryIndex = (int) preferenceItem[0].getTag(); + if (selectedEntryIndex >= 0) { + RoutingParameter parameter = reliefFactorParameters.get(selectedEntryIndex); + + String selectedParameterId = parameter.getId(); + for (RoutingParameter p : reliefFactorParameters) { + String parameterId = p.getId(); + setRoutingParameterSelected(app.getSettings(), appMode, parameterId, p.getDefaultBoolean(), parameterId.equals(selectedParameterId)); + } + recalculateRoute(); + + Fragment targetFragment = getTargetFragment(); + if (targetFragment instanceof OnPreferenceChanged) { + ((OnPreferenceChanged) targetFragment).onPreferenceChanged(pref.getId()); + } + } + updateItems(); + } + }) + .create(); + reliefFactorButtons.add(preferenceItem[0]); + items.add(preferenceItem[0]); + } + } + + private void recalculateRoute() { + RoutingHelper routingHelper = app.getRoutingHelper(); + if (getAppMode().equals(routingHelper.getAppMode()) + && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) { + routingHelper.recalculateRouteDueToSettingsChange(); + } + } + + private String getRoutingParameterTitle(Context context, RoutingParameter parameter) { + return AndroidUtils.getRoutingStringPropertyName(context, parameter.getId(), parameter.getName()); + } + + private void updateItems() { + for (BaseBottomSheetItem item : reliefFactorButtons) { + if (item instanceof BottomSheetItemWithCompoundButton) { + boolean checked = item.getTag().equals(selectedEntryIndex); + ((BottomSheetItemWithCompoundButton) item).setChecked(checked); + } + } + } + + private void enableItems(boolean enable) { + for (BaseBottomSheetItem item : reliefFactorButtons) { + if (item instanceof BottomSheetItemWithCompoundButton) { + item.getView().setEnabled(enable); + } + } + } + + public static void showInstance(FragmentManager fm, List reliefFactorParameters, + ApplicationMode appMode, Fragment target, boolean usedOnMap) { + try { + if (fm.findFragmentByTag(ElevationDateBottomSheet.TAG) == null) { + ElevationDateBottomSheet fragment = new ElevationDateBottomSheet(); + fragment.setAppMode(appMode); + fragment.setUsedOnMap(usedOnMap); + fragment.reliefFactorParameters.addAll(reliefFactorParameters); + fragment.setTargetFragment(target, 0); + fragment.show(fm, ScreenTimeoutBottomSheet.TAG); + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); + } + } +} + diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java index d2679564a8..99fb5fa73a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java @@ -111,7 +111,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot .setCompoundButtonColorId(appModeColorId) .setTitle(enabled ? on : off) .setTitleColorId(enabled ? activeColor : disabledColor) - .setCustomView(getCustomButtonView(enabled)) + .setCustomView(getCustomButtonView(app, getAppMode(), enabled, nightMode)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -123,7 +123,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot preferenceBtn[0].setChecked(enabled); getDefaultValue(); updateSliderView(); - updateCustomButtonView(v, enabled); + updateCustomButtonView(app, getAppMode(), v, enabled, nightMode); Fragment target = getTargetFragment(); float newValue = enabled ? DEFAULT_MODE : DISABLE_MODE; if (target instanceof OnConfirmPreferenceChange) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index b688d5dab4..223ad25083 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -38,6 +38,7 @@ import net.osmand.plus.settings.backend.BooleanPreference; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.bottomsheets.ElevationDateBottomSheet; import net.osmand.plus.settings.bottomsheets.RecalculateRouteInDeviationBottomSheet; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference; @@ -54,6 +55,8 @@ import java.util.Map; import java.util.Set; import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE; +import static net.osmand.plus.settings.backend.OsmandSettings.ROUTING_PREFERENCE_PREFIX; +import static net.osmand.router.GeneralRouter.USE_HEIGHT_OBSTACLES; public class RouteParametersFragment extends BaseSettingsFragment implements OnPreferenceChanged { @@ -63,7 +66,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP private static final String PREFER_ROUTING_PARAMETER_PREFIX = "prefer_"; private static final String ROUTE_PARAMETERS_INFO = "route_parameters_info"; private static final String ROUTE_PARAMETERS_IMAGE = "route_parameters_image"; - private static final String RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor"; + public static final String RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor"; private static final String ROUTING_SHORT_WAY = "prouting_short_way"; private static final String ROUTING_RECALC_DISTANCE = "routing_recalc_distance"; private static final String ROUTING_RECALC_WRONG_DIRECTION = "disable_wrong_direction_recalc"; @@ -275,12 +278,6 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP MultiSelectBooleanPreference preferRouting = createRoutingBooleanMultiSelectPref(PREFER_ROUTING_PARAMETER_PREFIX, title, "", preferParameters); screen.addPreference(preferRouting); } - if (reliefFactorParameters.size() > 0) { - ListPreferenceEx reliefFactorRouting = createRoutingBooleanListPreference(RELIEF_SMOOTHNESS_FACTOR, reliefFactorParameters); - reliefFactorRouting.setDescription(R.string.relief_smoothness_factor_descr); - - screen.addPreference(reliefFactorRouting); - } for (RoutingParameter p : otherRoutingParameters) { String title = AndroidUtils.getRoutingStringPropertyName(app, p.getId(), p.getName()); String description = AndroidUtils.getRoutingStringPropertyDescription(app, p.getId(), p.getDescription()); @@ -390,6 +387,12 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP if (fragmentManager != null) { RecalculateRouteInDeviationBottomSheet.showInstance(getFragmentManager(), preference.getKey(), this, false, getSelectedAppMode()); } + } else if (!reliefFactorParameters.isEmpty() && preference.getKey().equals(ROUTING_PREFERENCE_PREFIX + USE_HEIGHT_OBSTACLES)) { + FragmentManager fragmentManager = getFragmentManager(); + if (fragmentManager != null) { + ApplicationMode appMode = getSelectedAppMode(); + ElevationDateBottomSheet.showInstance(fragmentManager, reliefFactorParameters, appMode, this, false); + } } else { super.onDisplayPreferenceDialog(preference); } @@ -658,8 +661,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP } } - private void setRoutingParameterSelected(OsmandSettings settings, ApplicationMode mode, - String parameterId, boolean defaultBoolean, boolean isChecked) { + public static void setRoutingParameterSelected(OsmandSettings settings, ApplicationMode mode, + String parameterId, boolean defaultBoolean, boolean isChecked) { CommonPreference property = settings.getCustomRoutingBooleanProperty(parameterId, defaultBoolean); if (mode != null) { property.setModeValue(mode, isChecked); @@ -678,9 +681,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP Drawable disabled = getContentIcon(R.drawable.ic_action_avoid_motorways); Drawable enabled = getActiveIcon(R.drawable.ic_action_motorways); return getPersistentPrefIcon(enabled, disabled); - case GeneralRouter.USE_HEIGHT_OBSTACLES: + case USE_HEIGHT_OBSTACLES: case RELIEF_SMOOTHNESS_FACTOR: - return getPersistentPrefIcon(R.drawable.ic_action_elevation); + return getPersistentPrefIcon(R.drawable.ic_action_altitude_average); case AVOID_ROUTING_PARAMETER_PREFIX: return getPersistentPrefIcon(R.drawable.ic_action_alert); case DRIVING_STYLE: