From d16920b60c267b383796d4af1fc669d2b43902cb Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 17 Dec 2018 17:44:03 +0200 Subject: [PATCH] Improve route cards ui --- OsmAnd/res/layout/plan_route_info.xml | 1 + OsmAnd/res/layout/transport_route_card.xml | 22 +++++++++++++------ .../transport_stop_route_item_with_icon.xml | 3 +-- .../MapRouteInfoMenu.java | 20 ++++++++++++----- .../routeCards/PublicTransportCard.java | 13 +++++------ 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/OsmAnd/res/layout/plan_route_info.xml b/OsmAnd/res/layout/plan_route_info.xml index 29a4b02e55..ec86da6467 100644 --- a/OsmAnd/res/layout/plan_route_info.xml +++ b/OsmAnd/res/layout/plan_route_info.xml @@ -504,6 +504,7 @@ android:id="@+id/route_menu_cards_container" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingBottom="60dp" android:orientation="vertical" tools:background="?attr/ctx_menu_info_view_bg"> diff --git a/OsmAnd/res/layout/transport_route_card.xml b/OsmAnd/res/layout/transport_route_card.xml index afd806be95..672b1c4d3e 100644 --- a/OsmAnd/res/layout/transport_route_card.xml +++ b/OsmAnd/res/layout/transport_route_card.xml @@ -5,8 +5,16 @@ android:id="@+id/route_info_details_card" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical" - android:paddingBottom="10dp"> + android:orientation="vertical"> + + + + + + - + android:layout_height="wrap_content" + android:scaleType="fitXY" + android:src="@drawable/bg_shadow_list_bottom" /> \ No newline at end of file diff --git a/OsmAnd/res/layout/transport_stop_route_item_with_icon.xml b/OsmAnd/res/layout/transport_stop_route_item_with_icon.xml index 3fe38487c6..1588b41775 100644 --- a/OsmAnd/res/layout/transport_stop_route_item_with_icon.xml +++ b/OsmAnd/res/layout/transport_stop_route_item_with_icon.xml @@ -22,9 +22,8 @@ android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:gravity="center" - android:textAllCaps="true" android:textColor="@color/color_white" - android:textSize="@dimen/default_sub_text_size_small" + android:textSize="@dimen/default_desc_text_size" osmand:typeface="@string/font_roboto_medium" tools:text="3" /> diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 8f64e8ff04..5fc3c02f1b 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -353,14 +353,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener { updateOptionsButtons(main); routeCards.clear(); - if (isRouteCalculated()) { + if (isBasicRouteCalculated()) { GPXUtilities.GPXFile gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute()); if (gpx != null) { routeCards.add(new SimpleRouteCard(mapActivity, nightMode, gpx)); - LinearLayout bottomView = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container); - build(bottomView); + LinearLayout cardsContainer = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container); + build(cardsContainer); } - } else if ((routingHelper.isPublicTransportMode() && transportHelper.getRoutes() != null)) { + } else if (isTransportRouteCalculated()) { List routes = transportHelper.getRoutes(); for (int i = 0; i < routes.size(); i++) { PublicTransportCard card = new PublicTransportCard(mapActivity, nightMode, routes.get(i), i); @@ -369,14 +369,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } routeCards.add(card); } - LinearLayout bottomView = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container); - build(bottomView); + LinearLayout cardsContainer = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container); + build(cardsContainer); } else { updateRouteCalcProgress(main); } } public boolean isRouteCalculated() { + return isBasicRouteCalculated() || isTransportRouteCalculated(); + } + + private boolean isTransportRouteCalculated() { + return routingHelper.isPublicTransportMode() && transportHelper.getRoutes() != null; + } + + private boolean isBasicRouteCalculated() { return routingHelper.getFinalLocation() != null && routingHelper.isRouteCalculated(); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/routeCards/PublicTransportCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/routeCards/PublicTransportCard.java index 91e0496d3a..bc4bec3305 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/routeCards/PublicTransportCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/routeCards/PublicTransportCard.java @@ -66,18 +66,17 @@ public class PublicTransportCard extends BaseRouteCard { fromLine.setText(getFirstLineDescrSpan()); wayLine.setText(getSecondLineDescrSpan()); - FrameLayout detailsButton = view.findViewById(R.id.details_button); - detailsButton.setOnClickListener(new View.OnClickListener() { + view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { transportHelper.setCurrentRoute(routeId); } }); + view.findViewById(R.id.bottom_shadow).setVisibility(isLastItem ? View.VISIBLE : View.GONE); + view.findViewById(R.id.card_divider).setVisibility(routeId != 0 ? View.VISIBLE : View.GONE); applyDayNightMode(); - if (isLastItem) { - view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom() + AndroidUtils.dpToPx(app, 60)); - } + return view; } @@ -157,7 +156,7 @@ public class PublicTransportCard extends BaseRouteCard { double walkTime = getWalkTime(s.walkDist, routeResult.getWalkSpeed()); if (walkTime > MIN_WALK_TIME) { String walkTimeS = OsmAndFormatter.getFormattedDuration((int) walkTime, app); - routesBadges.addView(createWalkRouteBadge(walkTimeS.toLowerCase()), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing)); + routesBadges.addView(createWalkRouteBadge(walkTimeS), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing)); routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing)); } } @@ -171,7 +170,7 @@ public class PublicTransportCard extends BaseRouteCard { if (walkTime2 > MIN_WALK_TIME) { String walkTimeS = OsmAndFormatter.getFormattedDuration((int) walkTime2, app); routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing)); - routesBadges.addView(createWalkRouteBadge(walkTimeS.toLowerCase())); + routesBadges.addView(createWalkRouteBadge(walkTimeS)); } } }