commit
f1756768ce
8 changed files with 31 additions and 36 deletions
|
@ -291,10 +291,12 @@ public class GpxSelectionHelper {
|
|||
return group;
|
||||
}
|
||||
|
||||
private String getGroupName(GPXFile g) {
|
||||
public String getGroupName(GPXFile g) {
|
||||
String name = g.path;
|
||||
if (g.showCurrentTrack) {
|
||||
name = getString(R.string.shared_string_currently_recording_track);
|
||||
} else if (Algorithms.isEmpty(name)) {
|
||||
name = getString(R.string.current_route);
|
||||
} else {
|
||||
int i = name.lastIndexOf('/');
|
||||
if (i >= 0) {
|
||||
|
|
|
@ -79,6 +79,7 @@ import net.osmand.plus.ContextMenuItem;
|
|||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxDbHelper;
|
||||
import net.osmand.plus.GpxDbHelper.GpxDataItemCallback;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
|
@ -2228,18 +2229,19 @@ public class GpxUiHelper {
|
|||
return dataSet;
|
||||
}
|
||||
|
||||
public static GpxDisplayItem makeGpxDisplayItem(OsmandApplication app, GPXUtilities.GPXFile gpx) {
|
||||
GpxDisplayItem gpxItem = null;
|
||||
String groupName = app.getString(R.string.current_route);
|
||||
GpxDisplayGroup group = app.getSelectedGpxHelper().buildGpxDisplayGroup(gpx, 0, groupName);
|
||||
public static GpxDisplayItem makeGpxDisplayItem(OsmandApplication app, GPXFile gpxFile) {
|
||||
GpxSelectionHelper helper = app.getSelectedGpxHelper();
|
||||
String groupName = helper.getGroupName(gpxFile);
|
||||
GpxDisplayGroup group = helper.buildGpxDisplayGroup(gpxFile, 0, groupName);
|
||||
if (group != null && group.getModifiableList().size() > 0) {
|
||||
gpxItem = group.getModifiableList().get(0);
|
||||
GpxDisplayItem gpxItem = group.getModifiableList().get(0);
|
||||
if (gpxItem != null) {
|
||||
gpxItem.route = true;
|
||||
}
|
||||
}
|
||||
return gpxItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void saveAndShareGpx(@NonNull final Context context, @NonNull final GPXFile gpxFile) {
|
||||
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
|
||||
|
|
|
@ -7,12 +7,13 @@ import android.os.AsyncTask;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -24,7 +25,6 @@ import net.osmand.plus.settings.backend.OsmandSettings;
|
|||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -93,28 +93,15 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
protected GpxSelectionHelper.GpxDisplayItem doInBackground(Void... voids) {
|
||||
GpxSelectionHelper.GpxDisplayGroup gpxDisplayGroup = null;
|
||||
GPXUtilities.GPXFile gpxFile = null;
|
||||
GPXUtilities.Track generalTrack = null;
|
||||
if (selectedGpxFile.getGpxFile().path != null) {
|
||||
gpxFile = GPXUtilities.loadGPXFile(new File(selectedGpxFile.getGpxFile().path));
|
||||
}
|
||||
if (gpxFile != null) {
|
||||
generalTrack = gpxFile.getGeneralTrack();
|
||||
}
|
||||
if (generalTrack != null) {
|
||||
gpxFile.addGeneralTrack();
|
||||
gpxDisplayGroup = app.getSelectedGpxHelper().buildGeneralGpxDisplayGroup(gpxFile, generalTrack);
|
||||
} else if (gpxFile != null && gpxFile.tracks.size() > 0) {
|
||||
gpxDisplayGroup = app.getSelectedGpxHelper().buildGeneralGpxDisplayGroup(gpxFile, gpxFile.tracks.get(0));
|
||||
}
|
||||
List<GpxSelectionHelper.GpxDisplayItem> items = null;
|
||||
if (gpxDisplayGroup != null) {
|
||||
items = gpxDisplayGroup.getModifiableList();
|
||||
}
|
||||
if (items != null && items.size() > 0) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
if (gpxFile.tracks.size() > 0) {
|
||||
GpxDisplayGroup gpxDisplayGroup = app.getSelectedGpxHelper().buildGeneralGpxDisplayGroup(gpxFile, gpxFile.tracks.get(0));
|
||||
|
||||
List<GpxDisplayItem> items = gpxDisplayGroup.getModifiableList();
|
||||
if (!Algorithms.isEmpty(items)) {
|
||||
return items.get(0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
|
|||
public static final String UPDATE_DYNAMIC_ITEMS = "update_dynamic_items";
|
||||
private static final int GPS_UPDATE_INTERVAL = 1000;
|
||||
public static final GPXTabItemType[] INIT_TAB_ITEMS =
|
||||
new GPXTabItemType[]{GPX_TAB_ITEM_GENERAL, GPX_TAB_ITEM_ALTITUDE, GPX_TAB_ITEM_SPEED};
|
||||
new GPXTabItemType[] {GPX_TAB_ITEM_GENERAL, GPX_TAB_ITEM_ALTITUDE, GPX_TAB_ITEM_SPEED};
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
|
@ -651,7 +651,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void openAnalyzeOnMap(GpxDisplayItem gpxItem) {
|
||||
public void openAnalyzeOnMap(@NonNull GpxDisplayItem gpxItem) {
|
||||
}
|
||||
|
||||
public interface DismissTargetFragment {
|
||||
|
|
|
@ -2,6 +2,8 @@ package net.osmand.plus.myplaces;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
|
||||
|
@ -19,5 +21,5 @@ public interface SegmentActionsListener {
|
|||
|
||||
void showOptionsPopupMenu(View view, TrkSegment trkSegment, boolean confirmDeletion, GpxDisplayItem gpxItem);
|
||||
|
||||
void openAnalyzeOnMap(GpxDisplayItem gpxItem);
|
||||
void openAnalyzeOnMap(@NonNull GpxDisplayItem gpxItem);
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
}
|
||||
|
||||
@Override
|
||||
public void openAnalyzeOnMap(GpxDisplayItem gpxItem) {
|
||||
public void openAnalyzeOnMap(@NonNull GpxDisplayItem gpxItem) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
settings.setMapLocationToShow(gpxItem.locationOnMap.lat, gpxItem.locationOnMap.lon,
|
||||
settings.getLastKnownMapZoom(),
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesFragment.getDefaultIconColorId;
|
||||
import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED;
|
||||
|
||||
public class GpxBlockStatisticsBuilder {
|
||||
|
||||
|
|
|
@ -1131,7 +1131,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
}
|
||||
|
||||
@Override
|
||||
public void openAnalyzeOnMap(GpxDisplayItem gpxItem) {
|
||||
public void openAnalyzeOnMap(@NonNull GpxDisplayItem gpxItem) {
|
||||
if (gpxPoint != null) {
|
||||
gpxItem.locationOnMap = gpxPoint.getSelectedPoint();
|
||||
}
|
||||
TrackDetailsMenu trackDetailsMenu = getMapActivity().getTrackDetailsMenu();
|
||||
trackDetailsMenu.setGpxItem(gpxItem);
|
||||
trackDetailsMenu.setSelectedGpxFile(selectedGpxFile);
|
||||
|
|
Loading…
Reference in a new issue