Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e79555be99
4 changed files with 108 additions and 6 deletions
|
@ -39,6 +39,7 @@ public class PointDescription {
|
|||
public static final String POINT_TYPE_GPX_ITEM = "gpx_item";
|
||||
public static final String POINT_TYPE_WORLD_REGION_SHOW_ON_MAP = "world_region_show_on_map";
|
||||
public static final String POINT_TYPE_BLOCKED_ROAD = "blocked_road";
|
||||
public static final String POINT_TYPE_TRANSPORT_ROUTE = "transport_route";
|
||||
|
||||
|
||||
public static final PointDescription LOCATION_POINT = new PointDescription(POINT_TYPE_LOCATION, "");
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.graphics.drawable.Drawable;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -31,7 +30,9 @@ import net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController;
|
|||
import net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
import net.osmand.plus.osmedit.EditPOIMenuController;
|
||||
|
@ -108,6 +109,8 @@ public abstract class MenuController extends BaseMenuController {
|
|||
menuController = new GpxItemMenuController(app, mapActivity, pointDescription, (GpxDisplayItem) object);
|
||||
} else if (object instanceof MapMarker) {
|
||||
menuController = new MapMarkerMenuController(app, mapActivity, pointDescription, (MapMarker) object);
|
||||
} else if (object instanceof TransportStopRoute) {
|
||||
menuController = new TransportRouteController(app, mapActivity, pointDescription, (TransportStopRoute) object);
|
||||
} else if (object instanceof TransportStop) {
|
||||
menuController = new TransportStopController(app, mapActivity, pointDescription, (TransportStop) object);
|
||||
} else if (object instanceof LatLon) {
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
||||
|
||||
public class TransportRouteController extends MenuController {
|
||||
|
||||
private TransportStopRoute transportStop;
|
||||
|
||||
public TransportRouteController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription,
|
||||
TransportStopRoute transportStop) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
this.transportStop = transportStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setObject(Object object) {
|
||||
if (object instanceof TransportStopRoute) {
|
||||
this.transportStop = (TransportStopRoute) object;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLeftIconId() {
|
||||
return this.transportStop.type.getTopResourceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayDistanceDirection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fabVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buttonsVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return super.displayStreetNameInTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return getPointDescription().getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||
List<TransportStop> stops = transportStop.route.getForwardStops();
|
||||
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
|
||||
for (TransportStop stop : stops) {
|
||||
addPlainMenuItem(
|
||||
stop == transportStop.stop ? R.drawable.ic_action_marker_dark : transportStop.type.getResourceId(),
|
||||
useEnglishNames ? stop.getEnName(true) : stop.getName(), false, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import net.osmand.data.TransportStop;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
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;
|
||||
|
@ -15,6 +16,9 @@ import net.osmand.util.Algorithms;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
public class TransportStopController extends MenuController {
|
||||
|
||||
public enum TransportStopType {
|
||||
|
@ -111,12 +115,20 @@ public class TransportStopController extends MenuController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
for (TransportStopRoute r : routes) {
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
|
||||
for (final TransportStopRoute r : routes) {
|
||||
OnClickListener listener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
MapContextMenu mm = getMapActivity().getContextMenu();
|
||||
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, r.desc);
|
||||
mm.show(latLon, pd, r);
|
||||
}
|
||||
};
|
||||
if (r.type == null) {
|
||||
addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.desc, false, false, null);
|
||||
addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.desc, false, false, listener );
|
||||
} else {
|
||||
addPlainMenuItem(r.type.getResourceId(), r.desc, false, false, null);
|
||||
addPlainMenuItem(r.type.getResourceId(), r.desc, false, false, listener);
|
||||
}
|
||||
}
|
||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||
|
@ -142,6 +154,7 @@ public class TransportStopController extends MenuController {
|
|||
}
|
||||
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getName() : rs.getEnName(true));
|
||||
r.route = rs;
|
||||
r.stop = transportStop;
|
||||
this.routes.add(r);
|
||||
}
|
||||
}
|
||||
|
@ -149,9 +162,10 @@ public class TransportStopController extends MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
private class TransportStopRoute {
|
||||
public static class TransportStopRoute {
|
||||
public TransportStopType type;
|
||||
public String desc;
|
||||
public TransportRoute route;
|
||||
public TransportStop stop;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue