diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java index cb40a2a192..4403d512f4 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java @@ -25,6 +25,8 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem; +import net.osmand.plus.onlinerouting.VehicleType; +import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.widgets.OsmandTextFieldBoxes; @@ -135,14 +137,23 @@ public class OnlineRoutingCard extends BaseCard { if (callback.processResult(item)) { adapter.setSelectedItem(item); } + Object obj = item.getObject(); + updateBottomMarginSelectionMenu(obj); } }); + Object item = adapter.getItemByTitle(selectedItemTitle).getObject(); + updateBottomMarginSelectionMenu(item); rvSelectionMenu.setAdapter(adapter); } - public void updateBottomMarginSelectionMenu(int bottomMargin) { - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) rvSelectionMenu.getLayoutParams(); - params.bottomMargin = bottomMargin; + private void updateBottomMarginSelectionMenu(Object item) { + if (item instanceof VehicleType) { + VehicleType vt = (VehicleType) item; + boolean hasPadding = vt.equals(OnlineRoutingEngine.CUSTOM_VEHICLE); + ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) rvSelectionMenu.getLayoutParams(); + int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding); + params.bottomMargin = hasPadding ? contentPadding : 0; + } } public void setDescription(@NonNull String description) { diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java index 433fda973c..4c0bca61a6 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingEngineFragment.java @@ -342,7 +342,11 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment { apiKeyCard.setOnTextChangedListener(new OnTextChangedListener() { @Override public void onTextChanged(boolean editedByUser, @NonNull String text) { - engine.put(EngineParameter.API_KEY, text); + if (Algorithms.isBlank(text)) { + engine.remove(EngineParameter.API_KEY); + } else { + engine.put(EngineParameter.API_KEY, text); + } updateCardViews(exampleCard); } });