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_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_BLOCKED_ROAD = "blocked_road";
|
||||||
public static final String POINT_TYPE_TRANSPORT_ROUTE = "transport_route";
|
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, "");
|
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);
|
mapActivity.getMapView().setMapPosition(mapPosition);
|
||||||
mapPosition = 0;
|
mapPosition = 0;
|
||||||
}
|
}
|
||||||
|
if(getMenuController() != null) {
|
||||||
|
getMenuController().onHide();
|
||||||
|
}
|
||||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||||
if (fragmentRef != null) {
|
if (fragmentRef != null) {
|
||||||
fragmentRef.get().dismissMenu();
|
fragmentRef.get().dismissMenu();
|
||||||
|
|
|
@ -340,4 +340,8 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
|
|
||||||
public abstract void buttonPressed();
|
public abstract void buttonPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onHide() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,15 +2,19 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
||||||
|
import net.osmand.plus.views.TransportStopsLayer;
|
||||||
|
|
||||||
public class TransportRouteController extends MenuController {
|
public class TransportRouteController extends MenuController {
|
||||||
|
|
||||||
|
@ -70,17 +74,38 @@ public class TransportRouteController extends MenuController {
|
||||||
public String getTypeStr() {
|
public String getTypeStr() {
|
||||||
return getPointDescription().getTypeName();
|
return getPointDescription().getTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHide() {
|
||||||
|
super.onHide();
|
||||||
|
MapContextMenu mm = getMapActivity().getContextMenu();
|
||||||
|
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
|
||||||
|
stopsLayer.setRoute(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
|
||||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||||
List<TransportStop> stops = transportStop.route.getForwardStops();
|
List<TransportStop> stops = transportStop.route.getForwardStops();
|
||||||
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
|
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(
|
addPlainMenuItem(
|
||||||
stop == transportStop.stop ? R.drawable.ic_action_marker_dark :
|
stop == transportStop.stop ? R.drawable.ic_action_marker_dark :
|
||||||
(transportStop.type == null ? R.drawable.mx_route_bus_ref : transportStop.type.getResourceId()),
|
(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;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
|
@ -393,9 +394,7 @@ public abstract class OsmandMapLayer {
|
||||||
rc.setDensityValue((float) tileBox.getMapDensity());
|
rc.setDensityValue((float) tileBox.getMapDensity());
|
||||||
// cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
|
// cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
|
||||||
renderer.updatePaint(req, paint, 0, false, rc);
|
renderer.updatePaint(req, paint, 0, false, rc);
|
||||||
if(paint.getColor() == 0 && defaultColor != 0) {
|
updateDefaultColor(paint, defaultColor);
|
||||||
paint.setColor(defaultColor);
|
|
||||||
}
|
|
||||||
if (paint.getStrokeWidth() == 0 && defaultWidth != 0) {
|
if (paint.getStrokeWidth() == 0 && defaultWidth != 0) {
|
||||||
paint.setStrokeWidth(defaultWidth);
|
paint.setStrokeWidth(defaultWidth);
|
||||||
}
|
}
|
||||||
|
@ -428,6 +427,13 @@ public abstract class OsmandMapLayer {
|
||||||
}
|
}
|
||||||
return false;
|
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) {
|
private int calculateHash(Object... o) {
|
||||||
return Arrays.hashCode(o);
|
return Arrays.hashCode(o);
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
@Override
|
@Override
|
||||||
public PointDescription getObjectName(Object o) {
|
public PointDescription getObjectName(Object o) {
|
||||||
if(o instanceof TransportStop){
|
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());
|
((TransportStop)o).getName());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue