diff --git a/OsmAnd/res/layout/route_ped_info.xml b/OsmAnd/res/layout/route_ped_info.xml
new file mode 100644
index 0000000000..30b87231fc
--- /dev/null
+++ b/OsmAnd/res/layout/route_ped_info.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 73c73a75da..ae0641a2eb 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,7 @@
Thx - Hardy
-->
+ The route by foot is approximately %1$s and it could be faster than by public transport
Unfortunately, OsmAnd could not find a route suitable for your settings.
Try the pedestrian navigation.
Try changing the settings.
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index 52e1cbd138..2d71bd0ce1 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -73,6 +73,7 @@ import net.osmand.plus.routepreparationmenu.cards.HistoryCard;
import net.osmand.plus.routepreparationmenu.cards.HomeWorkCard;
import net.osmand.plus.routepreparationmenu.cards.LongDistanceWarningCard;
import net.osmand.plus.routepreparationmenu.cards.MapMarkersCard;
+import net.osmand.plus.routepreparationmenu.cards.PedestrianRouteCard;
import net.osmand.plus.routepreparationmenu.cards.PreviousRouteCard;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportBetaWarningCard;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard;
@@ -90,6 +91,7 @@ import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.router.TransportRoutePlanner.TransportRouteResult;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.SearchResult;
+import net.osmand.util.MapUtils;
import java.io.IOException;
import java.lang.ref.WeakReference;
@@ -106,6 +108,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
private static final int BUTTON_ANIMATION_DELAY = 2000;
public static final int DEFAULT_MENU_STATE = 0;
+ private static final int MAX_PEDESTRIAN_ROUTE_DURATION = 30 * 60;
public static int directionInfo = -1;
public static boolean chooseRoutesVisible = false;
@@ -507,14 +510,28 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper();
List routes = transportRoutingHelper.getRoutes();
if (routes != null && routes.size() > 0) {
+ TransportRouteResult route = routes.get(0);
+ int walkTimeReal = transportRoutingHelper.getWalkingTime(route.getSegments());
+ int walkTimePT = (int) route.getWalkTime();
+ int walkTime = walkTimeReal > 0 ? walkTimeReal : walkTimePT;
+ int travelTime = (int) route.getTravelTime() + walkTime;
+ LatLon startLocation = transportRoutingHelper.getStartLocation();
+ LatLon endLocation = transportRoutingHelper.getEndLocation();
+ int approxPedestrianTime = (int) MapUtils.getDistance(startLocation, endLocation);
+ boolean showPedestrianCard = approxPedestrianTime < travelTime + 60 && approxPedestrianTime < MAX_PEDESTRIAN_ROUTE_DURATION;
for (int i = 0; i < routes.size(); i++) {
- PublicTransportCard card = new PublicTransportCard(mapActivity, transportRoutingHelper.getStartLocation(),
- transportRoutingHelper.getEndLocation(), routes.get(i), i);
- card.setShowBottomShadow(i == routes.size() - 1);
+ route = routes.get(i);
+ PublicTransportCard card = new PublicTransportCard(mapActivity, startLocation, endLocation, route, i);
+ card.setShowBottomShadow(i == routes.size() - 1 && !showPedestrianCard);
card.setShowTopShadow(i != 0);
card.setListener(this);
menuCards.add(card);
}
+ if (showPedestrianCard) {
+ PedestrianRouteCard pedestrianRouteCard = new PedestrianRouteCard(mapActivity, approxPedestrianTime);
+ pedestrianRouteCard.setListener(this);
+ menuCards.add(pedestrianRouteCard);
+ }
bottomShadowVisible = routes.size() == 0;
} else {
RouteMenuAppModes mode = app.getRoutingOptionsHelper().modes.get(routingHelper.getAppMode());
@@ -659,6 +676,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
} else if (card instanceof PublicTransportNotFoundSettingsWarningCard) {
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
+ } else if (card instanceof PedestrianRouteCard) {
+ updateApplicationMode(null, ApplicationMode.PEDESTRIAN);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java
index fd7a83fddc..a75a44ca42 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java
@@ -35,7 +35,6 @@ import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider;
-import com.github.mikephil.charting.listener.ChartTouchListener;
import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
import com.github.mikephil.charting.renderer.HorizontalBarChartRenderer;
import com.github.mikephil.charting.utils.ViewPortHandler;
@@ -214,6 +213,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.VISIBLE);
if (routeDetailsMenu != null) {
routeDetailsMenu.setMapActivity(null);
+ mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(null);
}
}
super.onPause();
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PedestrianRouteCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PedestrianRouteCard.java
new file mode 100644
index 0000000000..03608c7ca5
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PedestrianRouteCard.java
@@ -0,0 +1,64 @@
+package net.osmand.plus.routepreparationmenu.cards;
+
+import android.graphics.Typeface;
+import android.os.Build;
+import android.support.annotation.NonNull;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.style.StyleSpan;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+
+import net.osmand.AndroidUtils;
+import net.osmand.plus.OsmAndFormatter;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+
+public class PedestrianRouteCard extends BaseCard {
+
+ private int approxPedestrianTime;
+
+ public PedestrianRouteCard(@NonNull MapActivity mapActivity, int approxPedestrianTime) {
+ super(mapActivity);
+ this.approxPedestrianTime = approxPedestrianTime;
+ }
+
+ @Override
+ public int getCardLayoutId() {
+ return R.layout.route_ped_info;
+ }
+
+ @Override
+ protected void updateContent() {
+ TextView titleView = (TextView) view.findViewById(R.id.title);
+ String text = app.getString(R.string.public_transport_ped_route_title);
+ String formattedDuration = OsmAndFormatter.getFormattedDuration(approxPedestrianTime, app);
+ int start = text.indexOf("%1$s");
+ int end = start + formattedDuration.length();
+ text = text.replace("%1$s", formattedDuration);
+ SpannableString spannable = new SpannableString(text);
+ spannable.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ titleView.setText(spannable);
+
+ FrameLayout button = view.findViewById(R.id.button);
+ View buttonDescr = view.findViewById(R.id.button_descr);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ CardListener listener = getListener();
+ if (listener != null) {
+ listener.onCardButtonPressed(PedestrianRouteCard.this, 0);
+ }
+ }
+ });
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
+ AndroidUtils.setBackground(app, button, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
+ AndroidUtils.setBackground(app, buttonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
+ } else {
+ AndroidUtils.setBackground(app, buttonDescr, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
+ }
+ view.findViewById(R.id.card_divider).setVisibility(View.VISIBLE);
+ view.findViewById(R.id.top_divider).setVisibility(View.GONE);
+ }
+}