Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-05-30 16:53:41 +02:00
commit 08b28c5a22
11 changed files with 31 additions and 29 deletions

View file

@ -87,7 +87,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof Recording) {
Recording objectInMotion = (Recording) contextMenuLayer.getMoveableObject();
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
drawRecording(canvas, objectInMotion, pf.x, pf.y);
}
}

View file

@ -190,12 +190,8 @@ public class MapMultiSelectionMenu extends BaseMenuController {
selectedObjects.remove(menuObject.getObject());
}
hide();
Object o = menuObject.getObject();
getMapActivity().getMapLayers().getContextMenuLayer().tryInitSelectedObjectContextMenuProvider(o);
getMapActivity().getMapViewTrackingUtilities().locationChanged(menuObject.getLatLon().getLatitude(),
menuObject.getLatLon().getLongitude(), this);
getMapActivity().getContextMenu()
.show(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());
getMapActivity().getMapLayers().getContextMenuLayer().showContextMenu(
menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());
}
private void clearSelectedObjects() {

View file

@ -59,7 +59,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof OsmPoint) {
OsmPoint objectInMotion = (OsmPoint) contextMenuLayer.getMoveableObject();
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
drawPoint(canvas, objectInMotion, pf.x, pf.y);
}
}

View file

@ -99,7 +99,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements
float locationX;
float locationY;
if (inMotion) {
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
locationX = pf.x;
locationY = pf.y;
} else {

View file

@ -182,7 +182,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
public PointF getMoveableCenterPoint(RotatedTileBox tb) {
public PointF getMovableCenterPoint(RotatedTileBox tb) {
if (applyingMarkerLatLon != null) {
float x = tb.getPixXFromLatLon(applyingMarkerLatLon.getLatitude(), applyingMarkerLatLon.getLongitude());
float y = tb.getPixYFromLatLon(applyingMarkerLatLon.getLatitude(), applyingMarkerLatLon.getLongitude());
@ -232,7 +232,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
PointF newMarkerPosition = getMoveableCenterPoint(tileBox);
PointF newMarkerPosition = getMovableCenterPoint(tileBox);
final LatLon ll = tileBox.getLatLonFromPixel(newMarkerPosition.x, newMarkerPosition.y);
applyingMarkerLatLon = ll;
@ -316,6 +316,23 @@ public class ContextMenuLayer extends OsmandMapLayer {
return showContextMenu(new PointF(x, y), activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation);
}
public boolean showContextMenu(@NonNull LatLon latLon,
@NonNull PointDescription pointDescription,
@NonNull Object object) {
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
double latitude = latLon.getLatitude();
double longitude = latLon.getLongitude();
float x = tileBox.getPixXFromLatLon(latitude, longitude);
float y = tileBox.getPixYFromLatLon(latitude, longitude);
Map<Object, IContextMenuProvider> selectedObjects =
selectObjectsForContextMenu(tileBox, new PointF(x, y), false);
selectedObjectContextMenuProvider = selectedObjects.get(object);
hideVisibleMenues();
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
menu.show(latLon, pointDescription, object);
return true;
}
private boolean showContextMenu(PointF point, RotatedTileBox tileBox, boolean showUnknownLocation) {
Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false);
if (selectedObjects.size() == 1) {
@ -520,17 +537,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
return false;
}
public void tryInitSelectedObjectContextMenuProvider(Object o) {
for (OsmandMapLayer osmandMapLayer : view.getLayers()) {
if (osmandMapLayer instanceof IMoveObjectProvider) {
if(((IMoveObjectProvider) osmandMapLayer).isObjectMovable(o)) {
selectedObjectContextMenuProvider = (IContextMenuProvider) osmandMapLayer;
break;
}
}
}
}
public interface IContextMenuProvider {
void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o);

View file

@ -95,7 +95,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
FavouritePoint objectInMotion = (FavouritePoint) contextMenuLayer.getMoveableObject();
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(),
objectInMotion.getColor(), true);
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
fid.drawBitmapInCenter(canvas, pf.x, pf.y);
}
}

View file

@ -151,7 +151,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof WptPt) {
WptPt objectInMotion = (WptPt) contextMenuLayer.getMoveableObject();
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
SelectedGpxFile gpxFile = pointFileMap.get(objectInMotion);
if (gpxFile != null) {
drawBigPoint(canvas, objectInMotion, getFileColor(gpxFile), pf.x, pf.y);

View file

@ -57,7 +57,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof RouteDataObject) {
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
float left = pf.x - roadWorkIcon.getWidth() / 2;
float top = pf.y - roadWorkIcon.getHeight();
canvas.drawBitmap(roadWorkIcon, left, top, paint);

View file

@ -308,7 +308,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
if (contextMenuLayer.getMoveableObject() instanceof MapMarker) {
MapMarker objectInMotion = (MapMarker) contextMenuLayer.getMoveableObject();
Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
int marginX = bitmap.getWidth() / 6;
int marginY = bitmap.getHeight();
float locationX = pf.x;

View file

@ -44,7 +44,7 @@ public class MoveMarkerBottomSheetHelper {
}
public void onDraw(RotatedTileBox rt) {
PointF point = mContextMenuLayer.getMoveableCenterPoint(rt);
PointF point = mContextMenuLayer.getMovableCenterPoint(rt);
double lat = rt.getLatFromPixel(point.x, point.y);
double lon = rt.getLonFromPixel(point.x, point.y);
mDescription.setText(mContext.getString(R.string.lat_lon_pattern, lat, lon));

View file

@ -150,7 +150,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements
private float getPointX(RotatedTileBox tileBox, TargetPoint point) {
if (contextMenuLayer.getMoveableObject() != null
&& point == contextMenuLayer.getMoveableObject()) {
return contextMenuLayer.getMoveableCenterPoint(tileBox).x;
return contextMenuLayer.getMovableCenterPoint(tileBox).x;
} else {
return tileBox.getPixXFromLonNoRot(point.getLongitude());
}
@ -159,7 +159,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements
private float getPointY(RotatedTileBox tileBox, TargetPoint point) {
if (contextMenuLayer.getMoveableObject() != null
&& point == contextMenuLayer.getMoveableObject()) {
return contextMenuLayer.getMoveableCenterPoint(tileBox).y;
return contextMenuLayer.getMovableCenterPoint(tileBox).y;
} else {
return tileBox.getPixYFromLatNoRot(point.getLatitude());
}