Merge pull request #11370 from osmandapp/track_menu

Track menu fixes
This commit is contained in:
vshcherb 2021-04-09 16:02:11 +02:00 committed by GitHub
commit 621a06b2c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 154 additions and 98 deletions

View file

@ -155,7 +155,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -18,8 +18,8 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.PluginsFragment;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.itinerary.ItineraryGroup;
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapsource.EditMapSourceDialogFragment;
import net.osmand.plus.openplacereviews.OPRConstants;
import net.osmand.plus.openplacereviews.OprAuthHelper.OprAuthorizationListener;
@ -259,7 +259,7 @@ public class IntentHelper {
String path = intent.getStringExtra(TRACK_FILE_NAME);
String name = intent.getStringExtra(RETURN_SCREEN_NAME);
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null, name, null);
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, name, null);
mapActivity.setIntent(null);
}
}

View file

@ -153,9 +153,11 @@ public class SelectedGpxMenuBuilder extends MenuBuilder {
OsmAndFormatter.getFormattedSpeed((float) selectedPoint.speed, app), 0, null,
false, null, false, 0, false, false, false, null, false);
}
buildRow(view, getThemedIcon(R.drawable.ic_action_relative_bearing), null, app.getString(R.string.shared_string_bearing),
OsmAndFormatter.getFormattedAzimuth(selectedGpxPoint.getBearing(), app), 0, null,
false, null, false, 0, false, false, false, null, false);
if (!Float.isNaN(selectedGpxPoint.getBearing())) {
buildRow(view, getThemedIcon(R.drawable.ic_action_relative_bearing), null, app.getString(R.string.shared_string_bearing),
OsmAndFormatter.getFormattedAzimuth(selectedGpxPoint.getBearing(), app), 0, null,
false, null, false, 0, false, false, false, null, false);
}
}
private void buildCategoryView(View view, String name) {

View file

@ -43,11 +43,8 @@ public class SelectedGpxMenuController extends MenuController {
@Override
public void buttonPressed() {
mapContextMenu.close();
WptPt wptPt = selectedGpxPoint.selectedPoint;
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
String path = selectedGpxFile.getGpxFile().path;
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon, null, null);
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, selectedGpxPoint, null, null, false);
}
};
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
@ -215,11 +212,15 @@ public class SelectedGpxMenuController extends MenuController {
public static class SelectedGpxPoint {
private final WptPt prevPoint;
private final WptPt nextPoint;
private final WptPt selectedPoint;
private final SelectedGpxFile selectedGpxFile;
private final float bearing;
public SelectedGpxPoint(SelectedGpxFile selectedGpxFile, WptPt selectedPoint, float bearing) {
public SelectedGpxPoint(SelectedGpxFile selectedGpxFile, WptPt selectedPoint, WptPt prevPoint, WptPt nextPoint, float bearing) {
this.prevPoint = prevPoint;
this.nextPoint = nextPoint;
this.selectedPoint = selectedPoint;
this.selectedGpxFile = selectedGpxFile;
this.bearing = bearing;
@ -236,5 +237,13 @@ public class SelectedGpxMenuController extends MenuController {
public float getBearing() {
return bearing;
}
public WptPt getPrevPoint() {
return prevPoint;
}
public WptPt getNextPoint() {
return nextPoint;
}
}
}

View file

@ -17,6 +17,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.track.TrackMenuFragment;
@ -49,8 +50,8 @@ public class WptPtMenuController extends MenuController {
GpxSelectionHelper selectionHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
if (selectedGpxFile != null) {
String path = selectedGpxFile.getGpxFile().path;
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat), null, null);
SelectedGpxPoint gpxPoint = new SelectedGpxPoint(selectedGpxFile, wpt, null, null, Float.NaN);
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, gpxPoint, null, null, false);
}
}
}

View file

@ -23,7 +23,6 @@ import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.GPXUtilities.TrkSegment;
@ -43,6 +42,7 @@ import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
import net.osmand.plus.myplaces.GPXItemPagerAdapter;
import net.osmand.plus.views.layers.GPXLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
@ -299,18 +299,7 @@ public class TrackDetailsMenu {
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
GpxDisplayItem gpxItem = getGpxItem();
if (ds != null && ds.size() > 0 && gpxItem != null) {
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
for (TrkSegment s : t.segments) {
if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) {
segment = s;
break;
}
}
if (segment != null) {
break;
}
}
this.segment = segment;
this.segment = GPXItemPagerAdapter.getSegmentForAnalysis(gpxItem, gpxItem.analysis);
}
}
return segment;
@ -755,21 +744,21 @@ public class TrackDetailsMenu {
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
boolean hasSlopeChart = false;
if (analysis.hasElevationData) {
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE});
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE});
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SLOPE});
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.SLOPE});
}
}
if (analysis.hasSpeedData) {
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SPEED});
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.SPEED});
}
if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE});
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE});
}
if (analysis.hasElevationData && analysis.hasSpeedData) {
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED});
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED});
}
for (GPXDataSetType t : gpxItem.chartTypes) {

View file

@ -316,7 +316,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -502,7 +502,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return isInMeasurementMode();
}

View file

@ -26,7 +26,6 @@ import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.GPXUtilities.Track;
@ -34,7 +33,6 @@ import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -52,7 +50,6 @@ import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionI
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -181,17 +178,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
LineData lineData = chart.getLineData();
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
if (ds != null && ds.size() > 0) {
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
for (TrkSegment s : t.segments) {
if (s.points.size() > 0 && s.points.get(0).equals(analysis.locationStart)) {
segment = s;
break;
}
}
if (segment != null) {
break;
}
}
segment = getSegmentForAnalysis(gpxItem, analysis);
}
}
return segment;
@ -741,6 +728,14 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
}
if (gpxItem.chartHighlightPos != -1) {
chart.highlightValue(gpxItem.chartHighlightPos, 0);
} else if (gpxItem.locationOnMap != null) {
LineData lineData = chart.getLineData();
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
if (ds != null && ds.size() > 0) {
OrderedLineDataSet dataSet = (OrderedLineDataSet) ds.get(0);
gpxItem.chartHighlightPos = (float) (gpxItem.locationOnMap.distance / dataSet.getDivX());
chart.highlightValue(gpxItem.chartHighlightPos, 0);
}
}
} else {
chart.highlightValue(null);
@ -818,18 +813,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
gpxItem.chartTypes[i] = orderedDataSet.getDataSetType();
}
if (gpxItem.chartHighlightPos != -1) {
TrkSegment segment = null;
for (Track t : gpxItem.group.getGpx().tracks) {
for (TrkSegment s : t.segments) {
if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) {
segment = s;
break;
}
}
if (segment != null) {
break;
}
}
TrkSegment segment = getSegmentForAnalysis(gpxItem, gpxItem.analysis);
if (segment != null) {
OrderedLineDataSet dataSet = (OrderedLineDataSet) dataSets.get(0);
float distance = gpxItem.chartHighlightPos * dataSet.getDivX();
@ -849,7 +833,16 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
}
}
private void openSplitIntervalScreen() {
actionsListener.openSplitInterval(gpxItem, getTrkSegment());
public static TrkSegment getSegmentForAnalysis(GpxDisplayItem gpxItem, GPXTrackAnalysis analysis) {
for (Track track : gpxItem.group.getGpx().tracks) {
for (TrkSegment segment : track.segments) {
int size = segment.points.size();
if (size > 0 && segment.points.get(0).equals(analysis.locationStart)
&& segment.points.get(size - 1).equals(analysis.locationEnd)) {
return segment;
}
}
}
return null;
}
}

View file

@ -453,7 +453,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -180,7 +180,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -306,7 +306,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo);
File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxInfo.getFileName());
String path = file.getAbsolutePath();
TrackMenuFragment.showInstance(mapActivity, path, false, null, null, QuickSearchDialogFragment.TAG);
TrackMenuFragment.showInstance(mapActivity, path, false, null, QuickSearchDialogFragment.TAG);
dialogFragment.dismiss();
}

View file

@ -4,11 +4,14 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.plus.myplaces.GPXItemPagerAdapter;
import net.osmand.plus.myplaces.SegmentActionsListener;
import net.osmand.plus.myplaces.SegmentGPXAdapter;
@ -23,12 +26,14 @@ public class SegmentsCard extends BaseCard {
private TrackDisplayHelper displayHelper;
private GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT};
private SegmentActionsListener listener;
private SelectedGpxPoint gpxPoint;
public SegmentsCard(@NonNull MapActivity mapActivity, @NonNull TrackDisplayHelper displayHelper,
@NonNull SegmentActionsListener listener) {
@Nullable SelectedGpxPoint gpxPoint, @NonNull SegmentActionsListener listener) {
super(mapActivity);
this.displayHelper = displayHelper;
this.listener = listener;
this.displayHelper = displayHelper;
this.gpxPoint = gpxPoint;
}
@Override
@ -42,6 +47,8 @@ public class SegmentsCard extends BaseCard {
container.removeAllViews();
List<GpxDisplayItem> items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes));
for (GpxDisplayItem displayItem : items) {
updateLocationOnMap(displayItem);
View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode);
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
@ -53,4 +60,16 @@ public class SegmentsCard extends BaseCard {
container.addView(segmentView);
}
}
private void updateLocationOnMap(GpxDisplayItem item) {
if (gpxPoint != null) {
TrkSegment segment = GPXItemPagerAdapter.getSegmentForAnalysis(item, item.analysis);
if (segment != null && (segment.points.contains(gpxPoint.getSelectedPoint())
|| segment.points.contains(gpxPoint.getPrevPoint())
&& segment.points.contains(gpxPoint.getNextPoint()))) {
item.locationOnMap = gpxPoint.getSelectedPoint();
listener.onPointSelected(segment, item.locationOnMap.lat, item.locationOnMap.lon);
}
}
}
}

View file

@ -39,6 +39,7 @@ import net.osmand.FileUtils;
import net.osmand.FileUtils.RenameCallback;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
@ -66,6 +67,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.OpenGpxDetailsTask;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.measurementtool.GpxData;
@ -154,6 +156,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
private String gpxTitle;
private String returnScreenName;
private String callingFragmentTag;
private SelectedGpxPoint gpxPoint;
private TrackChartPoints trackChartPoints;
private Float heading;
@ -165,7 +168,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
private int menuTitleHeight;
private int menuHeaderHeight;
private int toolbarHeightPx;
private boolean mapPositionAdjusted;
private boolean adjustMapPosition = true;
public enum TrackMenuType {
@ -320,6 +323,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
this.callingFragmentTag = callingFragmentTag;
}
public void setGpxPoint(SelectedGpxPoint point) {
this.gpxPoint = point;
}
public void setAdjustMapPosition(boolean adjustMapPosition) {
this.adjustMapPosition = adjustMapPosition;
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
@ -506,7 +517,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
}
cardsContainer.addView(segmentsCard.getView());
} else {
segmentsCard = new SegmentsCard(mapActivity, displayHelper, this);
segmentsCard = new SegmentsCard(mapActivity, displayHelper, gpxPoint, this);
segmentsCard.setListener(this);
cardsContainer.addView(segmentsCard.build(mapActivity));
}
@ -596,7 +607,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
boolean backButtonVisible = !Algorithms.isEmpty(returnScreenName) && currentMenuState == MenuState.HALF_SCREEN;
AndroidUiHelper.updateVisibility(backButtonContainer, backButtonVisible);
}
if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) {
if (currentMenuState != MenuState.FULL_SCREEN && (changed || adjustMapPosition)) {
adjustMapPosition(getMenuStatePosY(currentMenuState));
}
}
@ -750,7 +761,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
@Override
public int getStatusBarColorId() {
if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
if (getView() != null && getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
return isNightMode() ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
return -1;
@ -971,7 +982,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (r.left != 0 && r.right != 0) {
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
}
mapPositionAdjusted = true;
adjustMapPosition = false;
}
}
@ -1258,7 +1269,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
boolean currentRecording = file == null;
String path = file != null ? file.getAbsolutePath() : null;
if (context instanceof MapActivity) {
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null, null);
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null);
} else {
Bundle bundle = new Bundle();
bundle.putString(TRACK_FILE_NAME, path);
@ -1309,7 +1320,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
public static void showInstance(@NonNull MapActivity mapActivity,
@Nullable String path,
boolean showCurrentTrack,
@Nullable final LatLon latLon,
@Nullable final String returnScreenName,
@Nullable final String callingFragmentTag) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
@ -1318,7 +1328,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
public boolean processResult(SelectedGpxFile selectedGpxFile) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && selectedGpxFile != null) {
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName, callingFragmentTag);
showInstance(mapActivity, selectedGpxFile, null, returnScreenName, callingFragmentTag, true);
}
return true;
}
@ -1327,9 +1337,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
public static boolean showInstance(@NonNull MapActivity mapActivity,
@NonNull SelectedGpxFile selectedGpxFile,
@Nullable LatLon latLon,
@Nullable SelectedGpxPoint gpxPoint,
@Nullable String returnScreenName,
@Nullable String callingFragmentTag) {
@Nullable String callingFragmentTag,
boolean adjustMapPosition) {
try {
Bundle args = new Bundle();
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
@ -1340,9 +1351,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
fragment.setSelectedGpxFile(selectedGpxFile);
fragment.setReturnScreenName(returnScreenName);
fragment.setCallingFragmentTag(callingFragmentTag);
fragment.setAdjustMapPosition(adjustMapPosition);
if (latLon != null) {
fragment.setLatLon(latLon);
if (gpxPoint != null) {
WptPt wptPt = gpxPoint.getSelectedPoint();
fragment.setLatLon(new LatLon(wptPt.lat, wptPt.lon));
fragment.setGpxPoint(gpxPoint);
} else {
QuadRect rect = selectedGpxFile.getGpxFile().getRect();
LatLon latLonRect = new LatLon(rect.centerY(), rect.centerX());

View file

@ -267,7 +267,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -320,7 +320,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override
@RequiresPermission(Manifest.permission.VIBRATE)
public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) {
if (disableLongPressOnMap()) {
if (disableLongPressOnMap(point, tileBox)) {
return false;
}
if (pressedContextMarker(tileBox, point.x, point.y)) {
@ -877,7 +877,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
return res;
}
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode ||
activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.waypointsVisible
|| MapRouteInfoMenu.followTrackVisible) {
@ -886,7 +886,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
boolean res = false;
for (OsmandMapLayer lt : view.getLayers()) {
if (lt instanceof IContextMenuProvider) {
if (((IContextMenuProvider) lt).disableLongPressOnMap()) {
if (((IContextMenuProvider) lt).disableLongPressOnMap(point, tileBox)) {
res = true;
break;
}
@ -1101,7 +1101,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
boolean disableSingleTap();
boolean disableLongPressOnMap();
boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox);
boolean isObjectClickable(Object o);

View file

@ -566,7 +566,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -213,7 +213,7 @@ public class FavouritesLayer extends OsmandMapLayer implements IContextMenuProvi
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -44,10 +44,10 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.itinerary.ItineraryGroup;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.itinerary.ItineraryGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper;
import net.osmand.plus.render.OsmandRenderer;
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
@ -56,6 +56,7 @@ import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.track.GradientScaleType;
import net.osmand.plus.track.SaveGpxAsyncTask;
import net.osmand.plus.track.TrackDrawInfo;
import net.osmand.plus.track.TrackMenuFragment;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.Renderable;
@ -1024,7 +1025,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
float bearing = prevPointLocation.bearingTo(nextPointLocation);
return new SelectedGpxPoint(selectedGpxFile, projectionPoint, bearing);
return new SelectedGpxPoint(selectedGpxFile, projectionPoint, prevPoint, nextPoint, bearing);
}
public static WptPt createProjectionPoint(WptPt prevPoint, WptPt nextPoint, LatLon latLon) {
@ -1088,8 +1089,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
}
@Override
public boolean disableLongPressOnMap() {
return isInTrackAppearanceMode();
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
if (isInTrackAppearanceMode()) {
return true;
}
if (tileBox.getZoom() >= START_ZOOM) {
List<Object> res = new ArrayList<>();
getTracksFromPoint(tileBox, point, res);
return !Algorithms.isEmpty(res);
}
return false;
}
@Override
@ -1098,8 +1107,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
}
@Override
public boolean runExclusiveAction(Object o, boolean unknownLocation) {
return false;
public boolean runExclusiveAction(Object object, boolean unknownLocation) {
if (unknownLocation || !(object instanceof SelectedGpxPoint)) {
return false;
}
MapActivity mapActivity = (MapActivity) view.getContext();
SelectedGpxPoint point = (SelectedGpxPoint) object;
TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false);
return true;
}
@Override
@ -1134,6 +1149,20 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
@Override
public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) {
if (tileBox.getZoom() >= START_ZOOM) {
List<Object> trackPoints = new ArrayList<>();
getTracksFromPoint(tileBox, point, trackPoints);
if (!Algorithms.isEmpty(trackPoints)) {
MapActivity mapActivity = (MapActivity) view.getContext();
SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) trackPoints.get(0);
WptPt wptPt = selectedGpxPoint.getSelectedPoint();
PointDescription description = getObjectName(selectedGpxPoint);
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
contextMenuLayer.showContextMenu(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint, this);
return true;
}
}
return false;
}

View file

@ -128,7 +128,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -497,7 +497,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return inPlanRouteMode;
}

View file

@ -379,7 +379,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -226,7 +226,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -172,7 +172,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -802,7 +802,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return isInRouteLineAppearanceMode();
}

View file

@ -294,7 +294,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}