diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index 0da95fecc0..253b9ccbca 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -86,6 +86,39 @@
android:verticalSpacing="@dimen/context_menu_transport_grid_spacing"
android:visibility="gone"/>
+
+
+
+
+
+
+
+ #bfbfbf
#c5d2e6
#3db878
#3a9f73
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 05f81738fb..1a87fbe47f 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,16 +9,18 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
- DD°MM′SS″
- DD.DDDDDD°
- DD.DDDDD°
- DD°MM.MMMM′
- DD°MM.MMM′
- E
- W
- S
- N
- Optional point name
+ DD°MM′SS″
+ DD.DDDDDD°
+ DD.DDDDD°
+ DD°MM.MMMM′
+ DD°MM.MMM′
+ E
+ W
+ S
+ N
+ Optional point name
+ Routes near in
+ NEAR
Enter the file name.
Map import error
Map imported successfully
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
index 54c2d05a4e..280e293b60 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
@@ -792,6 +792,20 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return null;
}
+ public List getLocalTransportStopRoutes() {
+ if (menuController != null) {
+ return menuController.getLocalTransportStopRoutes();
+ }
+ return null;
+ }
+
+ public List getNearbyTransportStopRoutes() {
+ if (menuController != null) {
+ return menuController.getNearbyTransportStopRoutes();
+ }
+ return null;
+ }
+
public void navigateButtonPressed() {
if (navigateInPedestrianMode()) {
settings.APPLICATION_MODE.set(ApplicationMode.PEDESTRIAN);
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 5e141b90fe..0f89f14cea 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -40,6 +40,7 @@ import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.LockableScrollView;
+import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@@ -50,6 +51,7 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
+import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread;
@@ -60,6 +62,7 @@ import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms;
import java.util.List;
+import java.util.Locale;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
@@ -489,29 +492,32 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
zoomButtonsView.setVisibility(View.GONE);
}
- GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
- List transportStopRoutes = menu.getTransportStopRoutes();
- if (transportStopRoutes != null && transportStopRoutes.size() > 0) {
- final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), transportStopRoutes, nightMode);
- adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {
- @Override
- public void onClick(int position) {
- TransportStopRoute route = adapter.getItem(position);
- if (route != null) {
- PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
- route.getDescription(getMapActivity().getMyApplication(), false));
- menu.show(menu.getLatLon(), pd, route);
- TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
- stopsLayer.setRoute(route);
- int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
- getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
- }
- }
- });
- transportStopRoutesGrid.setAdapter(adapter);
- transportStopRoutesGrid.setVisibility(View.VISIBLE);
+ GridView localTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
+ GridView nearbyTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_nearby_routes_grid);
+ TextView nearbRoutesWithinTv = (TextView) view.findViewById(R.id.nearby_routes_within_text_view);
+ LinearLayout nearbyRoutesLayout = (LinearLayout) view.findViewById(R.id.nearby_routes);
+
+ List localTransportStopRoutes = menu.getLocalTransportStopRoutes();
+ List nearbyTransportStopRoutes = menu.getNearbyTransportStopRoutes();
+ if (nightMode) {
+ nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_bottom_view_secondary_text_color_dark));
} else {
- transportStopRoutesGrid.setVisibility(View.GONE);
+ nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_nearby_routes_text_color_dark));
+ }
+ if (localTransportStopRoutes != null && localTransportStopRoutes.size() > 0) {
+ localTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(localTransportStopRoutes));
+ localTransportStopRoutesGrid.setVisibility(View.VISIBLE);
+ } else {
+ localTransportStopRoutesGrid.setVisibility(View.GONE);
+ }
+ if (nearbyTransportStopRoutes != null && nearbyTransportStopRoutes.size() > 0) {
+ String nearInDistance = getMyApplication().getString(R.string.transport_nearby_routes) + " "
+ + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, getMyApplication()).toUpperCase() +":";
+ nearbRoutesWithinTv.setText(nearInDistance);
+ nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes));
+ nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE);
+ } else {
+ nearbyRoutesLayout.setVisibility(View.GONE);
}
View buttonsBottomBorder = view.findViewById(R.id.buttons_bottom_border);
@@ -634,6 +640,26 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return view;
}
+ private TransportStopRouteAdapter createTransportStopRouteAdapter(List routes) {
+ final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), routes, nightMode);
+ adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {
+ @Override
+ public void onClick(int position) {
+ TransportStopRoute route = adapter.getItem(position);
+ if (route != null) {
+ PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
+ route.getDescription(getMapActivity().getMyApplication(), false));
+ menu.show(menu.getLatLon(), pd, route);
+ TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
+ stopsLayer.setRoute(route);
+ int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
+ getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
+ }
+ }
+ });
+ return adapter;
+ }
+
private float getToolbarAlpha(int y) {
float a = 0;
if (menu != null && !menu.isLandscapeLayout()) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
index 87866febdf..8019cca758 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
@@ -31,30 +31,25 @@ import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
-import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.osm.PoiCategory;
-import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
-import net.osmand.plus.GPXUtilities.GPXFile;
-import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.IconsCache;
-import net.osmand.plus.OsmAndAppCustomization;
+import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard;
import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
+import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.transport.TransportStopRoute;
-import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.widgets.TextViewEx;
@@ -310,8 +305,15 @@ public class MenuBuilder {
buildTitleRow(view);
}
if (showTransportRoutes()) {
- buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false),
+ buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false, false),
false, 0, false, null, true);
+
+ CollapsableView collapsableView = getCollapsableTransportStopRoutesView(view.getContext(), false, true);
+ if (collapsableView != null) {
+ String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS,app);
+ buildRow(view, 0, null, routesWithingDistance, 0, true, collapsableView,
+ false, 0, false, null, true);
+ }
}
buildNearestWikiRow(view);
if (needBuildPlainMenuItems()) {
@@ -835,29 +837,44 @@ public class MenuBuilder {
}
}
- private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed) {
+ private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed, boolean isNearbyRoutes) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false);
-
- for (int i = 0; i < routes.size(); i++) {
- final TransportStopRoute r = routes.get(i);
- View.OnClickListener listener = new View.OnClickListener() {
- @Override
- public void onClick(View arg0) {
- MapContextMenu mm = getMapActivity().getContextMenu();
- PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
- r.getDescription(getMapActivity().getMyApplication(), false));
- mm.show(latLon, pd, r);
- TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
- stopsLayer.setRoute(r);
- int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
- getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
- }
- };
- boolean showDivider = i < routes.size() - 1;
- buildTransportRouteRow(view, r, listener, showDivider);
+ List localTransportStopRoutes = mapContextMenu.getLocalTransportStopRoutes();
+ List nearbyTransportStopRoutes = mapContextMenu.getNearbyTransportStopRoutes();
+ if (!isNearbyRoutes) {
+ buildTransportRouteRows(view, localTransportStopRoutes);
+ } else {
+ buildTransportRouteRows(view, nearbyTransportStopRoutes);
}
+ if (isNearbyRoutes && nearbyTransportStopRoutes.isEmpty()) {
+ return null;
+ } else {
+ return new CollapsableView(view, this, collapsed);
+ }
+ }
- return new CollapsableView(view, this, collapsed);
+ private void buildTransportRouteRows(LinearLayout view, List routes) {
+ for (int i = 0; i < routes.size(); i++) {
+ final TransportStopRoute r = routes.get(i);
+ boolean showDivider = i < routes.size() - 1;
+ buildTransportRouteRow(view, r, createTransportRoutesViewClickListener(r), showDivider);
+ }
+ }
+
+ private View.OnClickListener createTransportRoutesViewClickListener(final TransportStopRoute r) {
+ return new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ MapContextMenu mm = getMapActivity().getContextMenu();
+ PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
+ r.getDescription(getMapActivity().getMyApplication(), false));
+ mm.show(latLon, pd, r);
+ TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
+ stopsLayer.setRoute(r);
+ int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
+ getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
+ }
+ };
}
protected CollapsableView getCollapsableTextView(Context context, boolean collapsed, String text) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
index b576166b68..0c83a68727 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java
@@ -79,6 +79,7 @@ import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser.OpeningHours;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -522,6 +523,29 @@ public abstract class MenuController extends BaseMenuController implements Colla
return null;
}
+ private List getSubTransportStopRoutes(boolean nearby) {
+ List allRoutes = getTransportStopRoutes();
+ if (allRoutes != null) {
+ List res = new ArrayList<>();
+ for (TransportStopRoute route : allRoutes) {
+ boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName());
+ if ((nearby && isCurrentRouteNearby) || (!nearby && !isCurrentRouteNearby)) {
+ res.add(route);
+ }
+ }
+ return res;
+ }
+ return null;
+ }
+
+ public List getLocalTransportStopRoutes() {
+ return getSubTransportStopRoutes(false);
+ }
+
+ public List getNearbyTransportStopRoutes() {
+ return getSubTransportStopRoutes(true);
+ }
+
public void share(LatLon latLon, String title, String address) {
ShareMenu.show(latLon, title, address, getMapActivity());
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java
index 811c1344fe..2778b67a4d 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java
@@ -1,9 +1,5 @@
package net.osmand.plus.mapcontextmenu.controllers;
-import android.view.View;
-import android.view.View.OnClickListener;
-
-import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.data.TransportRoute;
@@ -11,12 +7,10 @@ import net.osmand.data.TransportStop;
import net.osmand.plus.R;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.resources.TransportIndexRepository;
import net.osmand.plus.transport.TransportStopType;
-import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@@ -28,6 +22,8 @@ import java.util.List;
public class TransportStopController extends MenuController {
+ public static final int SHOW_STOPS_RADIUS_METERS = 150;
+
private TransportStop transportStop;
private List routes = new ArrayList<>();
private TransportStopType topType;
@@ -101,7 +97,7 @@ public class TransportStopController extends MenuController {
addRoutes(routes, useEnglishNames, t, transportStop, transportStop, 0);
}
ArrayList ls = new ArrayList<>();
- QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), 150);
+ QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), SHOW_STOPS_RADIUS_METERS);
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
for(TransportStop tstop : ls) {
if(tstop.getId().longValue() != transportStop.getId().longValue() || empty) {