From c5447af09c9f18ccb825cca3b50ec90ded84a15a Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 18 Jan 2021 15:58:14 +0200 Subject: [PATCH] fix descrease padding below scroll buttons in "Vehicle" block; fix saving api key. --- .../onlinerouting/ui/OnlineRoutingCard.java | 17 ++++++++++++++--- .../ui/OnlineRoutingEngineFragment.java | 6 +++++- 2 files changed, 19 insertions(+), 4 deletions(-) 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 d362898275..03ad725444 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); } });