Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-05-31 14:14:09 +02:00
commit 778ef01249
3 changed files with 20 additions and 22 deletions

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
@ -215,11 +216,16 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public MapContextMenu() {
}
public boolean init(LatLon latLon, PointDescription pointDescription, @Nullable Object object) {
public boolean init(@NonNull LatLon latLon,
@Nullable PointDescription pointDescription,
@Nullable Object object) {
return init(latLon, pointDescription, object, false);
}
public boolean init(LatLon latLon, PointDescription pointDescription, Object object, boolean update) {
public boolean init(@NonNull LatLon latLon,
@Nullable PointDescription pointDescription,
@Nullable Object object,
boolean update) {
if (myLocation == null) {
myLocation = getMapActivity().getMyApplication().getSettings().getLastKnownMapLocation();
@ -296,7 +302,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void show(LatLon latLon, PointDescription pointDescription, @Nullable Object object) {
public void show(@NonNull LatLon latLon,
@Nullable PointDescription pointDescription,
@Nullable Object object) {
if (init(latLon, pointDescription, object)) {
if (!MapContextMenuFragment.showInstance(this, mapActivity, centerMarker)) {
active = false;

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu.other;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import net.osmand.data.LatLon;
@ -185,13 +186,11 @@ public class MapMultiSelectionMenu extends BaseMenuController {
clearSelectedObjects();
}
public void openContextMenu(MenuObject menuObject) {
if (selectedObjects.containsKey(menuObject.getObject())) {
selectedObjects.remove(menuObject.getObject());
}
public void openContextMenu(@NonNull MenuObject menuObject) {
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
hide();
getMapActivity().getMapLayers().getContextMenuLayer().showContextMenu(
menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());
menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
}
private void clearSelectedObjects() {

View file

@ -317,16 +317,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
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);
@Nullable PointDescription pointDescription,
@Nullable Object object,
@Nullable IContextMenuProvider provider) {
selectedObjectContextMenuProvider = provider;
hideVisibleMenues();
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
menu.show(latLon, pointDescription, object);
@ -337,7 +331,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false);
if (selectedObjects.size() == 1) {
Object selectedObj = selectedObjects.keySet().iterator().next();
selectedObjectContextMenuProvider = selectedObjects.get(selectedObj);
LatLon latLon = null;
PointDescription pointDescription = null;
if (selectedObjectContextMenuProvider != null) {
@ -347,9 +340,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (latLon == null) {
latLon = getLatLon(point, tileBox);
}
hideVisibleMenues();
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
menu.show(latLon, pointDescription, selectedObj);
showContextMenu(latLon, pointDescription, selectedObj, selectedObjects.get(selectedObj));
return true;
} else if (selectedObjects.size() > 1) {