Merge branch 'master' of ssh://github.com/osmandapp/Osmand into new_coordinate_input
# Conflicts: # OsmAnd/res/values/strings.xml
This commit is contained in:
commit
9c2ac18147
8 changed files with 180 additions and 67 deletions
|
@ -86,6 +86,39 @@
|
|||
android:verticalSpacing="@dimen/context_menu_transport_grid_spacing"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/nearby_routes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/context_menu_direction_margin"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/context_menu_padding_margin_default"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_default"
|
||||
android:paddingTop="3dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/nearby_routes_within_text_view"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<GridView
|
||||
android:id="@+id/transport_stop_nearby_routes_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:columnWidth="@dimen/context_menu_transport_grid_item_width"
|
||||
android:horizontalSpacing="@dimen/context_menu_transport_grid_spacing"
|
||||
android:numColumns="auto_fit"
|
||||
android:verticalSpacing="@dimen/context_menu_transport_grid_spacing"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height= "wrap_content"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="ctx_menu_nearby_routes_text_color_dark">#bfbfbf</color>
|
||||
<color name="map_toolbar_switch_track_color">#c5d2e6</color>
|
||||
<color name="mapillary_color">#3db878</color>
|
||||
<color name="mapillary_color_pressed">#3a9f73</color>
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<string name="south_abbreviation">S</string>
|
||||
<string name="north_abbreviation">N</string>
|
||||
<string name="optional_point_name">Optional point name</string>
|
||||
<string name="transport_nearby_routes_within">Routes near in</string>
|
||||
<string name="transport_nearby_routes">NEAR</string>
|
||||
<string name="enter_the_file_name">Enter the file name.</string>
|
||||
<string name="map_import_error">Map import error</string>
|
||||
<string name="map_imported_successfully">Map imported successfully</string>
|
||||
|
|
|
@ -792,6 +792,20 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<TransportStopRoute> getLocalTransportStopRoutes() {
|
||||
if (menuController != null) {
|
||||
return menuController.getLocalTransportStopRoutes();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<TransportStopRoute> getNearbyTransportStopRoutes() {
|
||||
if (menuController != null) {
|
||||
return menuController.getNearbyTransportStopRoutes();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void navigateButtonPressed() {
|
||||
if (navigateInPedestrianMode()) {
|
||||
settings.APPLICATION_MODE.set(ApplicationMode.PEDESTRIAN);
|
||||
|
|
|
@ -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<TransportStopRoute> 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<TransportStopRoute> localTransportStopRoutes = menu.getLocalTransportStopRoutes();
|
||||
List<TransportStopRoute> 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<TransportStopRoute> 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()) {
|
||||
|
|
|
@ -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,12 +837,32 @@ 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);
|
||||
List<TransportStopRoute> localTransportStopRoutes = mapContextMenu.getLocalTransportStopRoutes();
|
||||
List<TransportStopRoute> 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);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildTransportRouteRows(LinearLayout view, List<TransportStopRoute> routes) {
|
||||
for (int i = 0; i < routes.size(); i++) {
|
||||
final TransportStopRoute r = routes.get(i);
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
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();
|
||||
|
@ -853,11 +875,6 @@ public class MenuBuilder {
|
|||
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
|
||||
}
|
||||
};
|
||||
boolean showDivider = i < routes.size() - 1;
|
||||
buildTransportRouteRow(view, r, listener, showDivider);
|
||||
}
|
||||
|
||||
return new CollapsableView(view, this, collapsed);
|
||||
}
|
||||
|
||||
protected CollapsableView getCollapsableTextView(Context context, boolean collapsed, String text) {
|
||||
|
|
|
@ -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<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
||||
if (allRoutes != null) {
|
||||
List<TransportStopRoute> 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<TransportStopRoute> getLocalTransportStopRoutes() {
|
||||
return getSubTransportStopRoutes(false);
|
||||
}
|
||||
|
||||
public List<TransportStopRoute> getNearbyTransportStopRoutes() {
|
||||
return getSubTransportStopRoutes(true);
|
||||
}
|
||||
|
||||
public void share(LatLon latLon, String title, String address) {
|
||||
ShareMenu.show(latLon, title, address, getMapActivity());
|
||||
}
|
||||
|
|
|
@ -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<TransportStopRoute> routes = new ArrayList<>();
|
||||
private TransportStopType topType;
|
||||
|
@ -101,7 +97,7 @@ public class TransportStopController extends MenuController {
|
|||
addRoutes(routes, useEnglishNames, t, transportStop, transportStop, 0);
|
||||
}
|
||||
ArrayList<TransportStop> 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) {
|
||||
|
|
Loading…
Reference in a new issue