update context menu
This commit is contained in:
parent
6c29a3c865
commit
30304cf11a
6 changed files with 46 additions and 7 deletions
|
@ -40,6 +40,7 @@ public class PointDescription {
|
|||
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 String POINT_TYPE_TRANSPORT_STOP = "transport_stop";
|
||||
|
||||
|
||||
public static final PointDescription LOCATION_POINT = new PointDescription(POINT_TYPE_LOCATION, "");
|
||||
|
|
|
@ -357,6 +357,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
mapActivity.getMapView().setMapPosition(mapPosition);
|
||||
mapPosition = 0;
|
||||
}
|
||||
if(getMenuController() != null) {
|
||||
getMenuController().onHide();
|
||||
}
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().dismissMenu();
|
||||
|
|
|
@ -340,4 +340,8 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
public abstract void buttonPressed();
|
||||
}
|
||||
|
||||
public void onHide() {
|
||||
|
||||
}
|
||||
}
|
|
@ -2,15 +2,19 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
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.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
||||
import net.osmand.plus.views.TransportStopsLayer;
|
||||
|
||||
public class TransportRouteController extends MenuController {
|
||||
|
||||
|
@ -72,15 +76,36 @@ public class TransportRouteController extends MenuController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
public void onHide() {
|
||||
super.onHide();
|
||||
MapContextMenu mm = getMapActivity().getContextMenu();
|
||||
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
|
||||
stopsLayer.setRoute(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
|
||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||
List<TransportStop> stops = transportStop.route.getForwardStops();
|
||||
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
|
||||
for (TransportStop stop : stops) {
|
||||
for (final TransportStop stop : stops) {
|
||||
final String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
|
||||
addPlainMenuItem(
|
||||
stop == transportStop.stop ? R.drawable.ic_action_marker_dark :
|
||||
(transportStop.type == null ? R.drawable.mx_route_bus_ref : transportStop.type.getResourceId()),
|
||||
useEnglishNames ? stop.getEnName(true) : stop.getName(), false, false, null);
|
||||
name , false, false, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
MapContextMenu mm = getMapActivity().getContextMenu();
|
||||
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
|
||||
getMapActivity().getString(R.string.transport_Stop),
|
||||
name);
|
||||
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
|
||||
stopsLayer.setRoute(null);
|
||||
mm.show(latLon, pd, stop);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
|
@ -393,9 +394,7 @@ public abstract class OsmandMapLayer {
|
|||
rc.setDensityValue((float) tileBox.getMapDensity());
|
||||
// cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
|
||||
renderer.updatePaint(req, paint, 0, false, rc);
|
||||
if(paint.getColor() == 0 && defaultColor != 0) {
|
||||
paint.setColor(defaultColor);
|
||||
}
|
||||
updateDefaultColor(paint, defaultColor);
|
||||
if (paint.getStrokeWidth() == 0 && defaultWidth != 0) {
|
||||
paint.setStrokeWidth(defaultWidth);
|
||||
}
|
||||
|
@ -429,6 +428,13 @@ public abstract class OsmandMapLayer {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void updateDefaultColor(Paint paint, int defaultColor) {
|
||||
if((paint.getColor() == 0 || paint.getColor() == Color.BLACK) && defaultColor != 0) {
|
||||
paint.setColor(defaultColor);
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateHash(Object... o) {
|
||||
return Arrays.hashCode(o);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if(o instanceof TransportStop){
|
||||
return new PointDescription(PointDescription.POINT_TYPE_POI, view.getContext().getString(R.string.transport_Stop),
|
||||
return new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP, view.getContext().getString(R.string.transport_Stop),
|
||||
((TransportStop)o).getName());
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue