Added top badges card for selected route
This commit is contained in:
parent
7574a4aa82
commit
136907eb35
4 changed files with 62 additions and 4 deletions
|
@ -36,14 +36,20 @@
|
||||||
<net.osmand.plus.widgets.FlowLayout
|
<net.osmand.plus.widgets.FlowLayout
|
||||||
android:id="@+id/routes_badges"
|
android:id="@+id/routes_badges"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_marginBottom="4dp" />
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/badges_padding"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/routes_info"
|
android:id="@+id/route_info"
|
||||||
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:layout_marginTop="4dp"
|
||||||
android:paddingBottom="14dp">
|
android:paddingBottom="14dp">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
@ -68,6 +74,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/route_buttons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="@dimen/route_info_details_padding"
|
android:layout_marginBottom="@dimen/route_info_details_padding"
|
||||||
|
|
|
@ -147,6 +147,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
|
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private boolean switched;
|
private boolean switched;
|
||||||
|
private boolean routeSelected;
|
||||||
|
|
||||||
private AddressLookupRequest startPointRequest;
|
private AddressLookupRequest startPointRequest;
|
||||||
private AddressLookupRequest targetPointRequest;
|
private AddressLookupRequest targetPointRequest;
|
||||||
|
@ -335,6 +336,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRouteSelected() {
|
||||||
|
return routeSelected;
|
||||||
|
}
|
||||||
|
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (showMenu) {
|
if (showMenu) {
|
||||||
|
@ -528,12 +533,26 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
LatLon endLocation = transportRoutingHelper.getEndLocation();
|
LatLon endLocation = transportRoutingHelper.getEndLocation();
|
||||||
int approxPedestrianTime = (int) MapUtils.getDistance(startLocation, endLocation);
|
int approxPedestrianTime = (int) MapUtils.getDistance(startLocation, endLocation);
|
||||||
boolean showPedestrianCard = approxPedestrianTime < travelTime + 60 && approxPedestrianTime < MAX_PEDESTRIAN_ROUTE_DURATION;
|
boolean showPedestrianCard = approxPedestrianTime < travelTime + 60 && approxPedestrianTime < MAX_PEDESTRIAN_ROUTE_DURATION;
|
||||||
|
boolean hasTopCard = false;
|
||||||
|
if (routes.size() > 1 && routeSelected) {
|
||||||
|
int currentRoute = app.getTransportRoutingHelper().getCurrentRoute();
|
||||||
|
if (currentRoute >= 0 && currentRoute < routes.size()) {
|
||||||
|
route = routes.get(currentRoute);
|
||||||
|
PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, currentRoute);
|
||||||
|
card.setRouteInfoVisible(false);
|
||||||
|
card.setRouteButtonsVisible(false);
|
||||||
|
card.setShowBottomShadow(false);
|
||||||
|
card.setShowTopShadow(false);
|
||||||
|
menuCards.add(card);
|
||||||
|
hasTopCard = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (int i = 0; i < routes.size(); i++) {
|
for (int i = 0; i < routes.size(); i++) {
|
||||||
route = routes.get(i);
|
route = routes.get(i);
|
||||||
PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, i);
|
PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, i);
|
||||||
card.setShowButtonCustomTitle(mapActivity.getString(R.string.shared_string_show_on_map));
|
card.setShowButtonCustomTitle(mapActivity.getString(R.string.shared_string_show_on_map));
|
||||||
card.setShowBottomShadow(i == routes.size() - 1 && !showPedestrianCard);
|
card.setShowBottomShadow(i == routes.size() - 1 && !showPedestrianCard);
|
||||||
card.setShowTopShadow(i != 0);
|
card.setShowTopShadow(i != 0 || hasTopCard);
|
||||||
card.setListener(this);
|
card.setListener(this);
|
||||||
menuCards.add(card);
|
menuCards.add(card);
|
||||||
}
|
}
|
||||||
|
@ -1901,6 +1920,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
@Override
|
@Override
|
||||||
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
|
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
|
||||||
directionInfo = -1;
|
directionInfo = -1;
|
||||||
|
routeSelected = false;
|
||||||
updateMenu();
|
updateMenu();
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
showToast.value = false;
|
showToast.value = false;
|
||||||
|
@ -2067,6 +2087,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
}
|
}
|
||||||
removeTargetPointListener();
|
removeTargetPointListener();
|
||||||
} else if (fragment instanceof ChooseRouteFragment) {
|
} else if (fragment instanceof ChooseRouteFragment) {
|
||||||
|
routeSelected = true;
|
||||||
MapRouteMenuStateHolder holder = new MapRouteMenuStateHolder(MapRouteMenuType.ROUTE_DETAILS, currentMenuState, fragment.getArguments());
|
MapRouteMenuStateHolder holder = new MapRouteMenuStateHolder(MapRouteMenuType.ROUTE_DETAILS, currentMenuState, fragment.getArguments());
|
||||||
if (!menuBackStack.empty() && menuBackStack.peek().type == holder.type) {
|
if (!menuBackStack.empty() && menuBackStack.peek().type == holder.type) {
|
||||||
menuBackStack.pop();
|
menuBackStack.pop();
|
||||||
|
|
|
@ -250,6 +250,14 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight()
|
menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight()
|
||||||
+ view.findViewById(R.id.control_buttons).getHeight()
|
+ view.findViewById(R.id.control_buttons).getHeight()
|
||||||
- view.findViewById(R.id.buttons_shadow).getHeight();
|
- view.findViewById(R.id.buttons_shadow).getHeight();
|
||||||
|
LinearLayout cardsContainer = getCardsContainer();
|
||||||
|
if (menu != null && cardsContainer != null && cardsContainer.getChildCount() > 0 && menu.isRouteSelected()) {
|
||||||
|
View topRouteCard = cardsContainer.getChildAt(0);
|
||||||
|
View badgesView = topRouteCard.findViewById(R.id.routes_badges);
|
||||||
|
View badgesPaddingView = topRouteCard.findViewById(R.id.badges_padding);
|
||||||
|
int paddingHeight = badgesPaddingView != null ? badgesPaddingView.getHeight() : 0;
|
||||||
|
menuTitleHeight += badgesView != null ? badgesView.getBottom() + paddingHeight : 0;
|
||||||
|
}
|
||||||
super.calculateLayout(view, initLayout);
|
super.calculateLayout(view, initLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class PublicTransportCard extends BaseCard {
|
||||||
|
|
||||||
private int routeId;
|
private int routeId;
|
||||||
private String showButtonCustomTitle;
|
private String showButtonCustomTitle;
|
||||||
|
private boolean routeInfoVisible = true;
|
||||||
|
private boolean routeButtonsVisible = true;
|
||||||
|
|
||||||
public interface PublicTransportCardListener {
|
public interface PublicTransportCardListener {
|
||||||
void onPublicTransportCardBadgePressed(@NonNull PublicTransportCard card, @NonNull TransportRouteResultSegment segment);
|
void onPublicTransportCardBadgePressed(@NonNull PublicTransportCard card, @NonNull TransportRouteResultSegment segment);
|
||||||
|
@ -85,11 +87,31 @@ public class PublicTransportCard extends BaseCard {
|
||||||
this.showButtonCustomTitle = showButtonCustomTitle;
|
this.showButtonCustomTitle = showButtonCustomTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRouteInfoVisible() {
|
||||||
|
return routeInfoVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRouteInfoVisible(boolean routeInfoVisible) {
|
||||||
|
this.routeInfoVisible = routeInfoVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRouteButtonsVisible() {
|
||||||
|
return routeButtonsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRouteButtonsVisible(boolean routeButtonsVisible) {
|
||||||
|
this.routeButtonsVisible = routeButtonsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateContent() {
|
protected void updateContent() {
|
||||||
List<TransportRouteResultSegment> segments = routeResult.getSegments();
|
List<TransportRouteResultSegment> segments = routeResult.getSegments();
|
||||||
createRouteBadges(segments);
|
createRouteBadges(segments);
|
||||||
|
|
||||||
|
view.findViewById(R.id.route_info).setVisibility(routeInfoVisible ? View.VISIBLE : View.GONE);
|
||||||
|
view.findViewById(R.id.route_buttons).setVisibility(routeButtonsVisible ? View.VISIBLE : View.GONE);
|
||||||
|
view.findViewById(R.id.badges_padding).setVisibility(!routeInfoVisible && !routeButtonsVisible ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
|
TextView fromLine = (TextView) view.findViewById(R.id.from_line);
|
||||||
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
|
TextView wayLine = (TextView) view.findViewById(R.id.way_line);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue