Improve route cards ui

This commit is contained in:
Chumva 2018-12-17 17:44:03 +02:00
parent 28d9289956
commit d16920b60c
5 changed files with 37 additions and 22 deletions

View file

@ -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">

View file

@ -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">
<LinearLayout
android:id="@+id/card_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/list_item_divider" />
</LinearLayout>
<View
android:id="@+id/top_divider"
@ -90,11 +98,11 @@
</LinearLayout>
<include
android:id="@+id/shadow"
layout="@layout/card_bottom_divider"
<ImageView
android:id="@+id/bottom_shadow"
android:layout_width="match_parent"
android:layout_height="2dp"
android:visibility="visible" />
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -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" />

View file

@ -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<TransportRoutePlanner.TransportRouteResult> 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();
}

View file

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