Display pin of point on track menu graphs
This commit is contained in:
parent
733d152956
commit
b1d3ebbaf1
10 changed files with 96 additions and 73 deletions
|
@ -18,8 +18,8 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.PluginsFragment;
|
import net.osmand.plus.activities.PluginsFragment;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
|
||||||
import net.osmand.plus.itinerary.ItineraryGroup;
|
import net.osmand.plus.itinerary.ItineraryGroup;
|
||||||
|
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||||
import net.osmand.plus.mapsource.EditMapSourceDialogFragment;
|
import net.osmand.plus.mapsource.EditMapSourceDialogFragment;
|
||||||
import net.osmand.plus.openplacereviews.OPRConstants;
|
import net.osmand.plus.openplacereviews.OPRConstants;
|
||||||
import net.osmand.plus.openplacereviews.OprAuthHelper.OprAuthorizationListener;
|
import net.osmand.plus.openplacereviews.OprAuthHelper.OprAuthorizationListener;
|
||||||
|
@ -259,7 +259,7 @@ public class IntentHelper {
|
||||||
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
||||||
String name = intent.getStringExtra(RETURN_SCREEN_NAME);
|
String name = intent.getStringExtra(RETURN_SCREEN_NAME);
|
||||||
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
|
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);
|
mapActivity.setIntent(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,9 +153,11 @@ public class SelectedGpxMenuBuilder extends MenuBuilder {
|
||||||
OsmAndFormatter.getFormattedSpeed((float) selectedPoint.speed, app), 0, null,
|
OsmAndFormatter.getFormattedSpeed((float) selectedPoint.speed, app), 0, null,
|
||||||
false, null, false, 0, false, false, false, null, false);
|
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),
|
if (!Float.isNaN(selectedGpxPoint.getBearing())) {
|
||||||
OsmAndFormatter.getFormattedAzimuth(selectedGpxPoint.getBearing(), app), 0, null,
|
buildRow(view, getThemedIcon(R.drawable.ic_action_relative_bearing), null, app.getString(R.string.shared_string_bearing),
|
||||||
false, null, false, 0, false, false, false, null, false);
|
OsmAndFormatter.getFormattedAzimuth(selectedGpxPoint.getBearing(), app), 0, null,
|
||||||
|
false, null, false, 0, false, false, false, null, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildCategoryView(View view, String name) {
|
private void buildCategoryView(View view, String name) {
|
||||||
|
|
|
@ -43,11 +43,8 @@ public class SelectedGpxMenuController extends MenuController {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
mapContextMenu.close();
|
mapContextMenu.close();
|
||||||
WptPt wptPt = selectedGpxPoint.selectedPoint;
|
|
||||||
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
|
|
||||||
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
||||||
String path = selectedGpxFile.getGpxFile().path;
|
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, selectedGpxPoint, null, null, false);
|
||||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon, null, null);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
||||||
|
@ -215,11 +212,15 @@ public class SelectedGpxMenuController extends MenuController {
|
||||||
|
|
||||||
public static class SelectedGpxPoint {
|
public static class SelectedGpxPoint {
|
||||||
|
|
||||||
|
private final WptPt prevPoint;
|
||||||
|
private final WptPt nextPoint;
|
||||||
private final WptPt selectedPoint;
|
private final WptPt selectedPoint;
|
||||||
private final SelectedGpxFile selectedGpxFile;
|
private final SelectedGpxFile selectedGpxFile;
|
||||||
private final float bearing;
|
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.selectedPoint = selectedPoint;
|
||||||
this.selectedGpxFile = selectedGpxFile;
|
this.selectedGpxFile = selectedGpxFile;
|
||||||
this.bearing = bearing;
|
this.bearing = bearing;
|
||||||
|
@ -236,5 +237,13 @@ public class SelectedGpxMenuController extends MenuController {
|
||||||
public float getBearing() {
|
public float getBearing() {
|
||||||
return bearing;
|
return bearing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WptPt getPrevPoint() {
|
||||||
|
return prevPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WptPt getNextPoint() {
|
||||||
|
return nextPoint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
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.MapMarker;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersHelper;
|
import net.osmand.plus.mapmarkers.MapMarkersHelper;
|
||||||
import net.osmand.plus.track.TrackMenuFragment;
|
import net.osmand.plus.track.TrackMenuFragment;
|
||||||
|
@ -49,8 +50,8 @@ public class WptPtMenuController extends MenuController {
|
||||||
GpxSelectionHelper selectionHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
|
GpxSelectionHelper selectionHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
|
||||||
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
|
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
String path = selectedGpxFile.getGpxFile().path;
|
SelectedGpxPoint gpxPoint = new SelectedGpxPoint(selectedGpxFile, wpt, null, null, Float.NaN);
|
||||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat), null, null);
|
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, gpxPoint, null, null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.github.mikephil.charting.listener.OnChartGestureListener;
|
||||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
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.GPXDataSetAxisType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
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.layers.GPXLayer;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||||
|
@ -299,18 +299,7 @@ public class TrackDetailsMenu {
|
||||||
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
|
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
|
||||||
GpxDisplayItem gpxItem = getGpxItem();
|
GpxDisplayItem gpxItem = getGpxItem();
|
||||||
if (ds != null && ds.size() > 0 && gpxItem != null) {
|
if (ds != null && ds.size() > 0 && gpxItem != null) {
|
||||||
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
|
this.segment = GPXItemPagerAdapter.getSegmentForAnalysis(gpxItem, gpxItem.analysis);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return segment;
|
return segment;
|
||||||
|
@ -755,21 +744,21 @@ public class TrackDetailsMenu {
|
||||||
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
|
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
|
||||||
boolean hasSlopeChart = false;
|
boolean hasSlopeChart = false;
|
||||||
if (analysis.hasElevationData) {
|
if (analysis.hasElevationData) {
|
||||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE});
|
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE});
|
||||||
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME
|
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME
|
||||||
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
||||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SLOPE});
|
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.SLOPE});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (analysis.hasSpeedData) {
|
if (analysis.hasSpeedData) {
|
||||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SPEED});
|
availableTypes.add(new GPXDataSetType[] {GPXDataSetType.SPEED});
|
||||||
}
|
}
|
||||||
if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME
|
if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME
|
||||||
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
&& 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) {
|
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) {
|
for (GPXDataSetType t : gpxItem.chartTypes) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import com.github.mikephil.charting.listener.OnChartGestureListener;
|
||||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.GPXUtilities.Track;
|
import net.osmand.GPXUtilities.Track;
|
||||||
|
@ -34,7 +33,6 @@ import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
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.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -181,17 +178,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
LineData lineData = chart.getLineData();
|
LineData lineData = chart.getLineData();
|
||||||
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
|
List<ILineDataSet> ds = lineData != null ? lineData.getDataSets() : null;
|
||||||
if (ds != null && ds.size() > 0) {
|
if (ds != null && ds.size() > 0) {
|
||||||
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
|
segment = getSegmentForAnalysis(gpxItem, analysis);
|
||||||
for (TrkSegment s : t.segments) {
|
|
||||||
if (s.points.size() > 0 && s.points.get(0).equals(analysis.locationStart)) {
|
|
||||||
segment = s;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (segment != null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return segment;
|
return segment;
|
||||||
|
@ -741,6 +728,14 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
}
|
}
|
||||||
if (gpxItem.chartHighlightPos != -1) {
|
if (gpxItem.chartHighlightPos != -1) {
|
||||||
chart.highlightValue(gpxItem.chartHighlightPos, 0);
|
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 {
|
} else {
|
||||||
chart.highlightValue(null);
|
chart.highlightValue(null);
|
||||||
|
@ -818,18 +813,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
gpxItem.chartTypes[i] = orderedDataSet.getDataSetType();
|
gpxItem.chartTypes[i] = orderedDataSet.getDataSetType();
|
||||||
}
|
}
|
||||||
if (gpxItem.chartHighlightPos != -1) {
|
if (gpxItem.chartHighlightPos != -1) {
|
||||||
TrkSegment segment = null;
|
TrkSegment segment = getSegmentForAnalysis(gpxItem, gpxItem.analysis);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (segment != null) {
|
if (segment != null) {
|
||||||
OrderedLineDataSet dataSet = (OrderedLineDataSet) dataSets.get(0);
|
OrderedLineDataSet dataSet = (OrderedLineDataSet) dataSets.get(0);
|
||||||
float distance = gpxItem.chartHighlightPos * dataSet.getDivX();
|
float distance = gpxItem.chartHighlightPos * dataSet.getDivX();
|
||||||
|
@ -849,7 +833,16 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSplitIntervalScreen() {
|
public static TrkSegment getSegmentForAnalysis(GpxDisplayItem gpxItem, GPXTrackAnalysis analysis) {
|
||||||
actionsListener.openSplitInterval(gpxItem, getTrkSegment());
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo);
|
SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo);
|
||||||
File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxInfo.getFileName());
|
File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxInfo.getFileName());
|
||||||
String path = file.getAbsolutePath();
|
String path = file.getAbsolutePath();
|
||||||
TrackMenuFragment.showInstance(mapActivity, path, false, null, null, QuickSearchDialogFragment.TAG);
|
TrackMenuFragment.showInstance(mapActivity, path, false, null, QuickSearchDialogFragment.TAG);
|
||||||
dialogFragment.dismiss();
|
dialogFragment.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,14 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
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.GPXItemPagerAdapter;
|
||||||
import net.osmand.plus.myplaces.SegmentActionsListener;
|
import net.osmand.plus.myplaces.SegmentActionsListener;
|
||||||
import net.osmand.plus.myplaces.SegmentGPXAdapter;
|
import net.osmand.plus.myplaces.SegmentGPXAdapter;
|
||||||
|
@ -23,12 +26,14 @@ public class SegmentsCard extends BaseCard {
|
||||||
private TrackDisplayHelper displayHelper;
|
private TrackDisplayHelper displayHelper;
|
||||||
private GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT};
|
private GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT};
|
||||||
private SegmentActionsListener listener;
|
private SegmentActionsListener listener;
|
||||||
|
private SelectedGpxPoint gpxPoint;
|
||||||
|
|
||||||
public SegmentsCard(@NonNull MapActivity mapActivity, @NonNull TrackDisplayHelper displayHelper,
|
public SegmentsCard(@NonNull MapActivity mapActivity, @NonNull TrackDisplayHelper displayHelper,
|
||||||
@NonNull SegmentActionsListener listener) {
|
@Nullable SelectedGpxPoint gpxPoint, @NonNull SegmentActionsListener listener) {
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
this.displayHelper = displayHelper;
|
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
this.displayHelper = displayHelper;
|
||||||
|
this.gpxPoint = gpxPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,6 +47,8 @@ public class SegmentsCard extends BaseCard {
|
||||||
container.removeAllViews();
|
container.removeAllViews();
|
||||||
List<GpxDisplayItem> items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes));
|
List<GpxDisplayItem> items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes));
|
||||||
for (GpxDisplayItem displayItem : items) {
|
for (GpxDisplayItem displayItem : items) {
|
||||||
|
updateLocationOnMap(displayItem);
|
||||||
|
|
||||||
View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode);
|
View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode);
|
||||||
|
|
||||||
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
||||||
|
@ -53,4 +60,16 @@ public class SegmentsCard extends BaseCard {
|
||||||
container.addView(segmentView);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -39,6 +39,7 @@ import net.osmand.FileUtils;
|
||||||
import net.osmand.FileUtils.RenameCallback;
|
import net.osmand.FileUtils.RenameCallback;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.LatLon;
|
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.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.OpenGpxDetailsTask;
|
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.TrackChartPoints;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||||
import net.osmand.plus.measurementtool.GpxData;
|
import net.osmand.plus.measurementtool.GpxData;
|
||||||
|
@ -154,6 +156,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
private String gpxTitle;
|
private String gpxTitle;
|
||||||
private String returnScreenName;
|
private String returnScreenName;
|
||||||
private String callingFragmentTag;
|
private String callingFragmentTag;
|
||||||
|
private SelectedGpxPoint gpxPoint;
|
||||||
private TrackChartPoints trackChartPoints;
|
private TrackChartPoints trackChartPoints;
|
||||||
|
|
||||||
private Float heading;
|
private Float heading;
|
||||||
|
@ -320,6 +323,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
this.callingFragmentTag = callingFragmentTag;
|
this.callingFragmentTag = callingFragmentTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGpxPoint(SelectedGpxPoint point) {
|
||||||
|
this.gpxPoint = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdjustMapPosition(boolean adjustMapPosition) {
|
||||||
|
this.adjustMapPosition = adjustMapPosition;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
@ -506,7 +517,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
cardsContainer.addView(segmentsCard.getView());
|
cardsContainer.addView(segmentsCard.getView());
|
||||||
} else {
|
} else {
|
||||||
segmentsCard = new SegmentsCard(mapActivity, displayHelper, this);
|
segmentsCard = new SegmentsCard(mapActivity, displayHelper, gpxPoint, this);
|
||||||
segmentsCard.setListener(this);
|
segmentsCard.setListener(this);
|
||||||
cardsContainer.addView(segmentsCard.build(mapActivity));
|
cardsContainer.addView(segmentsCard.build(mapActivity));
|
||||||
}
|
}
|
||||||
|
@ -1258,7 +1269,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
boolean currentRecording = file == null;
|
boolean currentRecording = file == null;
|
||||||
String path = file != null ? file.getAbsolutePath() : null;
|
String path = file != null ? file.getAbsolutePath() : null;
|
||||||
if (context instanceof MapActivity) {
|
if (context instanceof MapActivity) {
|
||||||
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null, null);
|
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null);
|
||||||
} else {
|
} else {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(TRACK_FILE_NAME, path);
|
bundle.putString(TRACK_FILE_NAME, path);
|
||||||
|
@ -1309,7 +1320,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
public static void showInstance(@NonNull MapActivity mapActivity,
|
public static void showInstance(@NonNull MapActivity mapActivity,
|
||||||
@Nullable String path,
|
@Nullable String path,
|
||||||
boolean showCurrentTrack,
|
boolean showCurrentTrack,
|
||||||
@Nullable final LatLon latLon,
|
|
||||||
@Nullable final String returnScreenName,
|
@Nullable final String returnScreenName,
|
||||||
@Nullable final String callingFragmentTag) {
|
@Nullable final String callingFragmentTag) {
|
||||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
|
@ -1318,7 +1328,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
public boolean processResult(SelectedGpxFile selectedGpxFile) {
|
public boolean processResult(SelectedGpxFile selectedGpxFile) {
|
||||||
MapActivity mapActivity = mapActivityRef.get();
|
MapActivity mapActivity = mapActivityRef.get();
|
||||||
if (mapActivity != null && selectedGpxFile != null) {
|
if (mapActivity != null && selectedGpxFile != null) {
|
||||||
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName, callingFragmentTag, true);
|
showInstance(mapActivity, selectedGpxFile, null, returnScreenName, callingFragmentTag, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1337,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
|
|
||||||
public static boolean showInstance(@NonNull MapActivity mapActivity,
|
public static boolean showInstance(@NonNull MapActivity mapActivity,
|
||||||
@NonNull SelectedGpxFile selectedGpxFile,
|
@NonNull SelectedGpxFile selectedGpxFile,
|
||||||
@Nullable LatLon latLon,
|
@Nullable SelectedGpxPoint gpxPoint,
|
||||||
@Nullable String returnScreenName,
|
@Nullable String returnScreenName,
|
||||||
@Nullable String callingFragmentTag,
|
@Nullable String callingFragmentTag,
|
||||||
boolean adjustMapPosition) {
|
boolean adjustMapPosition) {
|
||||||
|
@ -1341,10 +1351,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||||
fragment.setReturnScreenName(returnScreenName);
|
fragment.setReturnScreenName(returnScreenName);
|
||||||
fragment.setCallingFragmentTag(callingFragmentTag);
|
fragment.setCallingFragmentTag(callingFragmentTag);
|
||||||
fragment.adjustMapPosition = adjustMapPosition;
|
fragment.setAdjustMapPosition(adjustMapPosition);
|
||||||
|
|
||||||
if (latLon != null) {
|
if (gpxPoint != null) {
|
||||||
fragment.setLatLon(latLon);
|
WptPt wptPt = gpxPoint.getSelectedPoint();
|
||||||
|
fragment.setLatLon(new LatLon(wptPt.lat, wptPt.lon));
|
||||||
|
fragment.setGpxPoint(gpxPoint);
|
||||||
} else {
|
} else {
|
||||||
QuadRect rect = selectedGpxFile.getGpxFile().getRect();
|
QuadRect rect = selectedGpxFile.getGpxFile().getRect();
|
||||||
LatLon latLonRect = new LatLon(rect.centerY(), rect.centerX());
|
LatLon latLonRect = new LatLon(rect.centerY(), rect.centerX());
|
||||||
|
|
|
@ -1025,7 +1025,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
float bearing = prevPointLocation.bearingTo(nextPointLocation);
|
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) {
|
public static WptPt createProjectionPoint(WptPt prevPoint, WptPt nextPoint, LatLon latLon) {
|
||||||
|
@ -1113,9 +1113,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
MapActivity mapActivity = (MapActivity) view.getContext();
|
MapActivity mapActivity = (MapActivity) view.getContext();
|
||||||
SelectedGpxPoint point = (SelectedGpxPoint) object;
|
SelectedGpxPoint point = (SelectedGpxPoint) object;
|
||||||
WptPt wptPt = point.getSelectedPoint();
|
TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false);
|
||||||
TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(),
|
|
||||||
new LatLon(wptPt.lat, wptPt.lon), null, null, false);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue