From 6991d7add77b9001f76bedf02134dcc0cf589ae7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 6 Apr 2021 01:23:30 +0300 Subject: [PATCH] Fix pin visibility for track menu --- .../SelectedGpxMenuController.java | 2 +- .../osmand/plus/track/TrackMenuFragment.java | 10 ++++-- .../plus/views/layers/ContextMenuLayer.java | 33 +++++++++++-------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 5fc74c9db9..80dd39f959 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -42,7 +42,7 @@ public class SelectedGpxMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - mapContextMenu.hide(false); + mapContextMenu.close(); WptPt wptPt = selectedGpxPoint.selectedPoint; LatLon latLon = new LatLon(wptPt.lat, wptPt.lon); SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 248d376791..e1a620269d 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -7,7 +7,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.ColorStateList; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; @@ -270,8 +269,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { MapContextMenu contextMenu = mapActivity.getContextMenu(); - if (contextMenu.isActive() && contextMenu.getPointDescription() != null - && contextMenu.getPointDescription().isGpxPoint()) { + PointDescription pointDescription = contextMenu.getPointDescription(); + if (pointDescription != null && pointDescription.isGpxPoint()) { + contextMenu.init(contextMenu.getLatLon(), pointDescription, contextMenu.getObject()); contextMenu.show(); } else if (Algorithms.objectEquals(callingFragmentTag, QuickSearchDialogFragment.TAG)) { mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false); @@ -296,6 +296,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card : app.getResources().getString(R.string.shared_string_currently_recording_track); } + public LatLon getLatLon() { + return latLon; + } + public GPXFile getGpx() { return displayHelper.getGpx(); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java index 0fa8db69fb..5acf8999ba 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java @@ -268,12 +268,19 @@ public class ContextMenuLayer extends OsmandMapLayer { canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight()); contextMarker.draw(canvas); mAddGpxPointBottomSheetHelper.onDraw(box); - } else if (menu.isActive() && !markerCustomized) { - LatLon latLon = menu.getLatLon(); - int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); - int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); - canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight()); - contextMarker.draw(canvas); + } else if (!markerCustomized) { + LatLon latLon = null; + if (menu.isActive()) { + latLon = menu.getLatLon(); + } else if (activity.getTrackMenuFragment() != null) { + latLon = activity.getTrackMenuFragment().getLatLon(); + } + if (latLon != null) { + int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); + int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); + canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight()); + contextMarker.draw(canvas); + } } } @@ -283,7 +290,7 @@ public class ContextMenuLayer extends OsmandMapLayer { public void updateContextMenu() { for (OsmandMapLayer layer : view.getLayers()) { - if (layer instanceof ContextMenuLayer.IMoveObjectProvider && ((ContextMenuLayer.IMoveObjectProvider) layer).isObjectMovable(selectedObject)) { + if (layer instanceof IMoveObjectProvider && ((IMoveObjectProvider) layer).isObjectMovable(selectedObject)) { selectedObjectContextMenuProvider = (IContextMenuProvider) layer; break; } @@ -361,8 +368,8 @@ public class ContextMenuLayer extends OsmandMapLayer { public boolean isObjectMoveable(Object o) { if (o != null && selectedObjectContextMenuProvider != null - && selectedObjectContextMenuProvider instanceof ContextMenuLayer.IMoveObjectProvider) { - final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) selectedObjectContextMenuProvider; + && selectedObjectContextMenuProvider instanceof IMoveObjectProvider) { + final IMoveObjectProvider l = (IMoveObjectProvider) selectedObjectContextMenuProvider; if (l.isObjectMovable(o)) { return true; } @@ -860,7 +867,7 @@ public class ContextMenuLayer extends OsmandMapLayer { } boolean res = false; for (OsmandMapLayer lt : view.getLayers()) { - if (lt instanceof ContextMenuLayer.IContextMenuProvider) { + if (lt instanceof IContextMenuProvider) { if (((IContextMenuProvider) lt).disableSingleTap()) { res = true; break; @@ -878,7 +885,7 @@ public class ContextMenuLayer extends OsmandMapLayer { } boolean res = false; for (OsmandMapLayer lt : view.getLayers()) { - if (lt instanceof ContextMenuLayer.IContextMenuProvider) { + if (lt instanceof IContextMenuProvider) { if (((IContextMenuProvider) lt).disableLongPressOnMap()) { res = true; break; @@ -924,9 +931,9 @@ public class ContextMenuLayer extends OsmandMapLayer { Map selectedObjects = new HashMap<>(); List s = new ArrayList<>(); for (OsmandMapLayer lt : view.getLayers()) { - if (lt instanceof ContextMenuLayer.IContextMenuProvider) { + if (lt instanceof IContextMenuProvider) { s.clear(); - final IContextMenuProvider l = (ContextMenuLayer.IContextMenuProvider) lt; + final IContextMenuProvider l = (IContextMenuProvider) lt; l.collectObjectsFromPoint(point, tileBox, s, unknownLocation); for (Object o : s) { selectedObjects.put(o, l);