Fix pin visibility for track menu

This commit is contained in:
Vitaliy 2021-04-06 01:23:30 +03:00
parent 7775338364
commit 6991d7add7
3 changed files with 28 additions and 17 deletions

View file

@ -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();

View file

@ -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();
}

View file

@ -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<Object, IContextMenuProvider> selectedObjects = new HashMap<>();
List<Object> 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);