Fix #9408 Show "My Position" context menu fragment when long tap on location button. Don't show "Whats here" menu

This commit is contained in:
Nazar-Kutz 2020-08-18 19:43:59 +03:00
parent 51786f71f0
commit 96b3931644
2 changed files with 24 additions and 13 deletions

View file

@ -574,11 +574,21 @@ public class ContextMenuLayer extends OsmandMapLayer {
applyingMarkerLatLon = null;
}
public boolean showContextMenuForMyLocation() {
PointLocationLayer provider = view.getLayerByClass(PointLocationLayer.class);
if (provider != null) {
LatLon ll = provider.getObjectLocation(null);
if (ll != null) {
PointDescription pointDescription = provider.getObjectName(null);
return showContextMenu(ll, pointDescription, ll, provider);
}
}
return false;
}
public boolean showContextMenu(double latitude, double longitude, boolean showUnknownLocation) {
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
float x = cp.getPixXFromLatLon(latitude, longitude);
float y = cp.getPixYFromLatLon(latitude, longitude);
return showContextMenu(new PointF(x, y), activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation);
return showContextMenu(getPointFromLatLon(latitude, longitude),
activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation);
}
public boolean showContextMenu(@NonNull LatLon latLon,
@ -803,6 +813,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
return false;
}
private PointF getPointFromLatLon(double latitude, double longitude) {
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
float x = cp.getPixXFromLatLon(latitude, longitude);
float y = cp.getPixYFromLatLon(latitude, longitude);
return new PointF(x, y);
}
private List<String> getValues(@Nullable QStringStringHash set) {
List<String> res = new ArrayList<>();
if (set != null) {

View file

@ -439,15 +439,9 @@ public class MapControlsLayer extends OsmandMapLayer {
}
private void showContextMenuForMyLocation() {
OsmAndLocationProvider lp = app.getLocationProvider();
Location lastKnownLocation = lp.getLastKnownLocation();
Location lastStaleKnownLocation = lp.getLastStaleKnownLocation();
Location location = lastKnownLocation != null ? lastKnownLocation : lastStaleKnownLocation;
if (location != null) {
ContextMenuLayer cml = mapActivity.getMapView().getLayerByClass(ContextMenuLayer.class);
if (cml != null) {
cml.showContextMenu(location.getLatitude(), location.getLongitude(), true);
}
ContextMenuLayer cml = mapActivity.getMapView().getLayerByClass(ContextMenuLayer.class);
if (cml != null) {
cml.showContextMenuForMyLocation();
}
}