fix descrease padding below scroll buttons in "Vehicle" block;

fix saving api key.
This commit is contained in:
Skalii 2021-01-18 15:58:14 +02:00
parent 1cc116fe49
commit c5447af09c
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) {
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();
params.bottomMargin = bottomMargin;
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) {
if (Algorithms.isBlank(text)) {
engine.remove(EngineParameter.API_KEY);
} else {
engine.put(EngineParameter.API_KEY, text);
}
updateCardViews(exampleCard);
}
});