Improve route cards ui
This commit is contained in:
parent
28d9289956
commit
d16920b60c
5 changed files with 37 additions and 22 deletions
|
@ -504,6 +504,7 @@
|
||||||
android:id="@+id/route_menu_cards_container"
|
android:id="@+id/route_menu_cards_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="60dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:background="?attr/ctx_menu_info_view_bg">
|
tools:background="?attr/ctx_menu_info_view_bg">
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,16 @@
|
||||||
android:id="@+id/route_info_details_card"
|
android:id="@+id/route_info_details_card"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="10dp">
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/card_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<include layout="@layout/list_item_divider" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/top_divider"
|
android:id="@+id/top_divider"
|
||||||
|
@ -90,11 +98,11 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<include
|
<ImageView
|
||||||
android:id="@+id/shadow"
|
android:id="@+id/bottom_shadow"
|
||||||
layout="@layout/card_bottom_divider"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="visible" />
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/bg_shadow_list_bottom" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -22,9 +22,8 @@
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="@color/color_white"
|
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"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="3" />
|
tools:text="3" />
|
||||||
|
|
||||||
|
|
|
@ -353,14 +353,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
updateOptionsButtons(main);
|
updateOptionsButtons(main);
|
||||||
|
|
||||||
routeCards.clear();
|
routeCards.clear();
|
||||||
if (isRouteCalculated()) {
|
if (isBasicRouteCalculated()) {
|
||||||
GPXUtilities.GPXFile gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
|
GPXUtilities.GPXFile gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
|
||||||
if (gpx != null) {
|
if (gpx != null) {
|
||||||
routeCards.add(new SimpleRouteCard(mapActivity, nightMode, gpx));
|
routeCards.add(new SimpleRouteCard(mapActivity, nightMode, gpx));
|
||||||
LinearLayout bottomView = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container);
|
LinearLayout cardsContainer = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container);
|
||||||
build(bottomView);
|
build(cardsContainer);
|
||||||
}
|
}
|
||||||
} else if ((routingHelper.isPublicTransportMode() && transportHelper.getRoutes() != null)) {
|
} else if (isTransportRouteCalculated()) {
|
||||||
List<TransportRoutePlanner.TransportRouteResult> routes = transportHelper.getRoutes();
|
List<TransportRoutePlanner.TransportRouteResult> routes = transportHelper.getRoutes();
|
||||||
for (int i = 0; i < routes.size(); i++) {
|
for (int i = 0; i < routes.size(); i++) {
|
||||||
PublicTransportCard card = new PublicTransportCard(mapActivity, nightMode, routes.get(i), i);
|
PublicTransportCard card = new PublicTransportCard(mapActivity, nightMode, routes.get(i), i);
|
||||||
|
@ -369,14 +369,22 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
}
|
}
|
||||||
routeCards.add(card);
|
routeCards.add(card);
|
||||||
}
|
}
|
||||||
LinearLayout bottomView = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container);
|
LinearLayout cardsContainer = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container);
|
||||||
build(bottomView);
|
build(cardsContainer);
|
||||||
} else {
|
} else {
|
||||||
updateRouteCalcProgress(main);
|
updateRouteCalcProgress(main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRouteCalculated() {
|
public boolean isRouteCalculated() {
|
||||||
|
return isBasicRouteCalculated() || isTransportRouteCalculated();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTransportRouteCalculated() {
|
||||||
|
return routingHelper.isPublicTransportMode() && transportHelper.getRoutes() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBasicRouteCalculated() {
|
||||||
return routingHelper.getFinalLocation() != null && routingHelper.isRouteCalculated();
|
return routingHelper.getFinalLocation() != null && routingHelper.isRouteCalculated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,18 +66,17 @@ public class PublicTransportCard extends BaseRouteCard {
|
||||||
fromLine.setText(getFirstLineDescrSpan());
|
fromLine.setText(getFirstLineDescrSpan());
|
||||||
wayLine.setText(getSecondLineDescrSpan());
|
wayLine.setText(getSecondLineDescrSpan());
|
||||||
|
|
||||||
FrameLayout detailsButton = view.findViewById(R.id.details_button);
|
view.findViewById(R.id.details_button).setOnClickListener(new View.OnClickListener() {
|
||||||
detailsButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
transportHelper.setCurrentRoute(routeId);
|
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();
|
applyDayNightMode();
|
||||||
if (isLastItem) {
|
|
||||||
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom() + AndroidUtils.dpToPx(app, 60));
|
|
||||||
}
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ public class PublicTransportCard extends BaseRouteCard {
|
||||||
double walkTime = getWalkTime(s.walkDist, routeResult.getWalkSpeed());
|
double walkTime = getWalkTime(s.walkDist, routeResult.getWalkSpeed());
|
||||||
if (walkTime > MIN_WALK_TIME) {
|
if (walkTime > MIN_WALK_TIME) {
|
||||||
String walkTimeS = OsmAndFormatter.getFormattedDuration((int) walkTime, app);
|
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));
|
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +170,7 @@ public class PublicTransportCard extends BaseRouteCard {
|
||||||
if (walkTime2 > MIN_WALK_TIME) {
|
if (walkTime2 > MIN_WALK_TIME) {
|
||||||
String walkTimeS = OsmAndFormatter.getFormattedDuration((int) walkTime2, app);
|
String walkTimeS = OsmAndFormatter.getFormattedDuration((int) walkTime2, app);
|
||||||
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
routesBadges.addView(createArrow(), new FlowLayout.LayoutParams(itemsSpacing, itemsSpacing));
|
||||||
routesBadges.addView(createWalkRouteBadge(walkTimeS.toLowerCase()));
|
routesBadges.addView(createWalkRouteBadge(walkTimeS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue