Merge pull request #10613 from osmandapp/fix_online_routing_ui_p2

Fix online routing UI p2
This commit is contained in:
Vitaliy 2021-01-18 17:55:59 +02:00 committed by GitHub
commit 59f0d08ba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -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) {

View file

@ -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);
}
});