forked from upstream-mirrors/OpenTracks
Removed WaypointType.
This commit is contained in:
@@ -27,7 +27,6 @@ import android.widget.EditText;
|
||||
|
||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.Waypoint;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
||||
import de.dennisguse.opentracks.services.TrackRecordingServiceConnection;
|
||||
|
||||
@@ -126,7 +125,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
if (newMarker) {
|
||||
statisticsSection.setVisibility(View.GONE);
|
||||
waypointSection.setVisibility(View.VISIBLE);
|
||||
int nextWaypointNumber = trackId == -1L ? -1 : new ContentProviderUtils(this).getNextWaypointNumber(trackId, WaypointType.WAYPOINT);
|
||||
int nextWaypointNumber = trackId == -1L ? -1 : new ContentProviderUtils(this).getNextWaypointNumber(trackId);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 0;
|
||||
}
|
||||
@@ -141,7 +140,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
boolean statistics = waypoint.getType() == WaypointType.STATISTICS;
|
||||
boolean statistics = false; //TODO REMOVE
|
||||
statisticsSection.setVisibility(statistics ? View.VISIBLE : View.GONE);
|
||||
waypointSection.setVisibility(statistics ? View.GONE : View.VISIBLE);
|
||||
if (statistics) {
|
||||
@@ -159,7 +158,6 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
*/
|
||||
private void addMarker() {
|
||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(
|
||||
WaypointType.WAYPOINT,
|
||||
false,
|
||||
waypointName.getText().toString(),
|
||||
waypointMarkerType.getText().toString(),
|
||||
@@ -173,7 +171,7 @@ public class MarkerEditActivity extends AbstractActivity {
|
||||
* Saves a marker.
|
||||
*/
|
||||
private void saveMarker() {
|
||||
boolean statistics = waypoint.getType() == WaypointType.STATISTICS;
|
||||
boolean statistics = false; //TODO REMOVE
|
||||
if (statistics) {
|
||||
waypoint.setName(statisticsName.getText().toString());
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,6 @@ import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.Track;
|
||||
import de.dennisguse.opentracks.content.TrackDataHub;
|
||||
import de.dennisguse.opentracks.content.Waypoint;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
||||
import de.dennisguse.opentracks.fragments.ChartDistanceFragment;
|
||||
import de.dennisguse.opentracks.fragments.ChartTimeFragment;
|
||||
@@ -109,7 +108,7 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
|
||||
trackController.update(isRecording(), recordingTrackPaused);
|
||||
if (hasPhoto && photoUri != null) {
|
||||
hasPhoto = false;
|
||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(WaypointType.WAYPOINT, false, null, null, null, null, photoUri.toString());
|
||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(false, null, null, null, null, photoUri.toString());
|
||||
long markerId = trackRecordingServiceConnection.addMarker(TrackDetailActivity.this, waypointCreationRequest);
|
||||
if (markerId != -1L) {
|
||||
//TODO: Make configurable.
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.NoSuchElementException;
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
import de.dennisguse.opentracks.android.ContentResolverWrapper;
|
||||
import de.dennisguse.opentracks.android.IContentResolver;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
@@ -443,9 +442,6 @@ public class ContentProviderUtils {
|
||||
if (!cursor.isNull(trackIdIndex)) {
|
||||
waypoint.setTrackId(cursor.getLong(trackIdIndex));
|
||||
}
|
||||
if (!cursor.isNull(typeIndex)) {
|
||||
waypoint.setType(WaypointType.values()[cursor.getInt(typeIndex)]);
|
||||
}
|
||||
if (!cursor.isNull(lengthIndex)) {
|
||||
waypoint.setLength(cursor.getFloat(lengthIndex));
|
||||
}
|
||||
@@ -539,25 +535,10 @@ public class ContentProviderUtils {
|
||||
* The generator is used to update the next statistics waypoint.
|
||||
*
|
||||
* @param waypointId the waypoint id
|
||||
* @param descriptionGenerator the description generator. Can be null for waypoint marker
|
||||
*/
|
||||
|
||||
public void deleteWaypoint(Context context, long waypointId, DescriptionGenerator descriptionGenerator) {
|
||||
public void deleteWaypoint(Context context, long waypointId) {
|
||||
final Waypoint waypoint = getWaypoint(waypointId);
|
||||
if (waypoint != null && waypoint.getType() == WaypointType.STATISTICS
|
||||
&& descriptionGenerator != null) {
|
||||
final Waypoint nextWaypoint = getNextStatisticsWaypointAfter(waypoint);
|
||||
if (nextWaypoint == null) {
|
||||
Log.d(TAG, "Unable to find the next statistics marker after deleting one.");
|
||||
} else {
|
||||
nextWaypoint.getTripStatistics().merge(waypoint.getTripStatistics());
|
||||
nextWaypoint.setDescription(
|
||||
descriptionGenerator.generateWaypointDescription(nextWaypoint.getTripStatistics()));
|
||||
if (!updateWaypoint(nextWaypoint)) {
|
||||
Log.e(TAG, "Unable to update the next statistics marker after deleting one.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (waypoint != null && waypoint.hasPhoto()) {
|
||||
Uri uri = waypoint.getPhotoURI();
|
||||
File file = new File(uri.getPath());
|
||||
@@ -596,14 +577,13 @@ public class ContentProviderUtils {
|
||||
* Gets the last waypoint for a type. Returns null if it doesn't exist.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param waypointType the waypoint type
|
||||
*/
|
||||
public Waypoint getLastWaypoint(long trackId, WaypointType waypointType) {
|
||||
public Waypoint getLastWaypoint(long trackId) {
|
||||
if (trackId < 0) {
|
||||
return null;
|
||||
}
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId), Integer.toString(waypointType.ordinal())};
|
||||
String selection = WaypointsColumns.TRACKID + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId)};
|
||||
try (Cursor cursor = getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID + " DESC", 1)) {
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
@@ -618,20 +598,17 @@ public class ContentProviderUtils {
|
||||
* Returns -1 if not able to get the next waypoint number.
|
||||
*
|
||||
* @param trackId the track id
|
||||
* @param waypointType the waypoint type
|
||||
*/
|
||||
public int getNextWaypointNumber(long trackId, WaypointType waypointType) {
|
||||
public int getNextWaypointNumber(long trackId) {
|
||||
if (trackId < 0) {
|
||||
return -1;
|
||||
}
|
||||
String[] projection = {WaypointsColumns._ID};
|
||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId), Integer.toString(waypointType.ordinal())};
|
||||
String selection = WaypointsColumns.TRACKID + "=?";
|
||||
String[] selectionArgs = new String[]{Long.toString(trackId)};
|
||||
try (Cursor cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, -1)) {
|
||||
if (cursor != null) {
|
||||
int count = cursor.getCount();
|
||||
// For statistics markers, the first marker is for the track statistics, so return the count as the next user visible number.
|
||||
return waypointType == WaypointType.STATISTICS ? count : count + 1;
|
||||
return cursor.getCount();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -751,7 +728,6 @@ public class ContentProviderUtils {
|
||||
values.put(WaypointsColumns.CATEGORY, waypoint.getCategory());
|
||||
values.put(WaypointsColumns.ICON, waypoint.getIcon());
|
||||
values.put(WaypointsColumns.TRACKID, waypoint.getTrackId());
|
||||
values.put(WaypointsColumns.TYPE, waypoint.getType().ordinal());
|
||||
values.put(WaypointsColumns.LENGTH, waypoint.getLength());
|
||||
values.put(WaypointsColumns.DURATION, waypoint.getDuration());
|
||||
values.put(WaypointsColumns.STARTID, waypoint.getStartId());
|
||||
@@ -796,18 +772,6 @@ public class ContentProviderUtils {
|
||||
return values;
|
||||
}
|
||||
|
||||
private Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint) {
|
||||
String selection = WaypointsColumns._ID + ">? AND " + WaypointsColumns.TRACKID + "=? AND "
|
||||
+ WaypointsColumns.TYPE + "=" + WaypointType.STATISTICS.ordinal();
|
||||
String[] selectionArgs = new String[]{Long.toString(waypoint.getId()), Long.toString(waypoint.getTrackId())};
|
||||
try (Cursor cursor = getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID, 1)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return createWaypoint(cursor);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a waypoint cursor.
|
||||
*
|
||||
|
||||
@@ -35,7 +35,6 @@ public final class Waypoint {
|
||||
private String category = "";
|
||||
private String icon = "";
|
||||
private long trackId = -1L;
|
||||
private WaypointType type = WaypointType.WAYPOINT;
|
||||
private double length = 0.0;
|
||||
private long duration = 0;
|
||||
private long startId = -1L;
|
||||
@@ -47,13 +46,12 @@ public final class Waypoint {
|
||||
public Waypoint() {
|
||||
}
|
||||
|
||||
public Waypoint(String name, String description, String category, String icon, long trackId, WaypointType type, double length, long duration, long startId, long stopId, Location location, TripStatistics tripStatistics, String photoUrl) {
|
||||
public Waypoint(String name, String description, String category, String icon, long trackId, double length, long duration, long startId, long stopId, Location location, TripStatistics tripStatistics, String photoUrl) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.icon = icon;
|
||||
this.trackId = trackId;
|
||||
this.type = type;
|
||||
this.length = length;
|
||||
this.duration = duration;
|
||||
this.startId = startId;
|
||||
@@ -111,14 +109,6 @@ public final class Waypoint {
|
||||
this.trackId = trackId;
|
||||
}
|
||||
|
||||
public WaypointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WaypointType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getLength() {
|
||||
return length;
|
||||
}
|
||||
@@ -186,9 +176,4 @@ public final class Waypoint {
|
||||
public boolean hasPhoto() {
|
||||
return photoUrl != null && !"".equals(photoUrl);
|
||||
}
|
||||
|
||||
public enum WaypointType {
|
||||
WAYPOINT,
|
||||
STATISTICS //Always the first waypoint; only one can exist.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package de.dennisguse.opentracks.content;
|
||||
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
|
||||
/**
|
||||
* A request for the service to create a waypoint at the current location.
|
||||
@@ -24,12 +23,10 @@ import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
*/
|
||||
public class WaypointCreationRequest {
|
||||
|
||||
public final static WaypointCreationRequest DEFAULT_WAYPOINT = new WaypointCreationRequest(WaypointType.WAYPOINT, false);
|
||||
public final static WaypointCreationRequest DEFAULT_WAYPOINT = new WaypointCreationRequest(false);
|
||||
|
||||
@Deprecated // TODO Do not create per
|
||||
public final static WaypointCreationRequest DEFAULT_START_TRACK = new WaypointCreationRequest(WaypointType.STATISTICS, true);
|
||||
|
||||
private WaypointType type;
|
||||
public final static WaypointCreationRequest DEFAULT_START_TRACK = new WaypointCreationRequest(true);
|
||||
|
||||
// true if this marker contains the track statistics
|
||||
private boolean isTrackStatistics;
|
||||
@@ -40,12 +37,11 @@ public class WaypointCreationRequest {
|
||||
private String iconUrl;
|
||||
private String photoUrl;
|
||||
|
||||
private WaypointCreationRequest(WaypointType type, boolean isTrackStatistics) {
|
||||
this(type, isTrackStatistics, null, null, null, null, null);
|
||||
private WaypointCreationRequest(boolean isTrackStatistics) {
|
||||
this(isTrackStatistics, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public WaypointCreationRequest(WaypointType type, boolean isTrackStatistics, String name, String category, String description, String iconUrl, String photoUrl) {
|
||||
this.type = type;
|
||||
public WaypointCreationRequest(boolean isTrackStatistics, String name, String category, String description, String iconUrl, String photoUrl) {
|
||||
this.isTrackStatistics = isTrackStatistics;
|
||||
this.name = name;
|
||||
this.category = category;
|
||||
@@ -54,10 +50,6 @@ public class WaypointCreationRequest {
|
||||
this.photoUrl = photoUrl;
|
||||
}
|
||||
|
||||
public WaypointType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isTrackStatistics() {
|
||||
return isTrackStatistics;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.DescriptionGeneratorImpl;
|
||||
import de.dennisguse.opentracks.util.DialogUtils;
|
||||
|
||||
/**
|
||||
@@ -83,8 +82,7 @@ public class DeleteMarkerDialogFragment extends DialogFragment {
|
||||
public void run() {
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(fragmentActivity);
|
||||
for (long markerId : markerIds) {
|
||||
contentProviderUtils.deleteWaypoint(fragmentActivity,
|
||||
markerId, new DescriptionGeneratorImpl(fragmentActivity));
|
||||
contentProviderUtils.deleteWaypoint(fragmentActivity, markerId);
|
||||
}
|
||||
caller.onDeleteMarkerDone();
|
||||
}
|
||||
|
||||
@@ -119,12 +119,9 @@ public class GpxTrackWriter implements TrackWriter {
|
||||
if (location.hasAltitude()) {
|
||||
printWriter.println("<ele>" + ELEVATION_FORMAT.format(location.getAltitude()) + "</ele>");
|
||||
}
|
||||
printWriter.println(
|
||||
"<time>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</time>");
|
||||
printWriter.println("<time>" + StringUtils.formatDateTimeIso8601(location.getTime()) + "</time>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(waypoint.getName()) + "</name>");
|
||||
printWriter.println("<cmt>" + StringUtils.formatCData(waypoint.getType().name()) + "</cmt>");
|
||||
printWriter.println(
|
||||
"<desc>" + StringUtils.formatCData(waypoint.getDescription()) + "</desc>");
|
||||
printWriter.println("<desc>" + StringUtils.formatCData(waypoint.getDescription()) + "</desc>");
|
||||
printWriter.println("<type>" + StringUtils.formatCData(waypoint.getCategory()) + "</type>");
|
||||
printWriter.println("</wpt>");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import de.dennisguse.opentracks.content.DescriptionGeneratorImpl;
|
||||
import de.dennisguse.opentracks.content.SensorDataSetLocation;
|
||||
import de.dennisguse.opentracks.content.Track;
|
||||
import de.dennisguse.opentracks.content.Waypoint;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.util.StringUtils;
|
||||
|
||||
@@ -44,7 +43,6 @@ import de.dennisguse.opentracks.util.StringUtils;
|
||||
public class KmlTrackWriter implements TrackWriter {
|
||||
|
||||
private static final String WAYPOINT_STYLE = "waypoint";
|
||||
private static final String STATISTICS_STYLE = "statistics";
|
||||
private static final String START_STYLE = "start";
|
||||
private static final String END_STYLE = "end";
|
||||
private static final String TRACK_STYLE = "track";
|
||||
@@ -55,7 +53,6 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
private static final String SENSOR_TYPE_POWER = "power";
|
||||
|
||||
private static final String WAYPOINT_ICON = "http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png";
|
||||
private static final String STATISTICS_ICON = "http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png";
|
||||
private static final String START_ICON = "http://maps.google.com/mapfiles/kml/paddle/grn-circle.png";
|
||||
private static final String END_ICON = "http://maps.google.com/mapfiles/kml/paddle/red-circle.png";
|
||||
private static final String TRACK_ICON = "http://earth.google.com/images/kml-icons/track-directional/track-0.png";
|
||||
@@ -125,7 +122,6 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
writeTrackStyle();
|
||||
writePlacemarkerStyle(START_STYLE, START_ICON, 32, 1);
|
||||
writePlacemarkerStyle(END_STYLE, END_ICON, 32, 1);
|
||||
writePlacemarkerStyle(STATISTICS_STYLE, STATISTICS_ICON, 20, 2);
|
||||
writePlacemarkerStyle(WAYPOINT_STYLE, WAYPOINT_ICON, 20, 2);
|
||||
printWriter.println("<Schema id=\"" + SCHEMA_ID + "\">");
|
||||
|
||||
@@ -167,13 +163,11 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
@Override
|
||||
public void writeWaypoint(Waypoint waypoint) {
|
||||
if (printWriter != null && exportTrackDetail) {
|
||||
String styleName = waypoint.getType() == WaypointType.STATISTICS ? STATISTICS_STYLE : WAYPOINT_STYLE;
|
||||
|
||||
if (waypoint.hasPhoto() && exportPhotos) {
|
||||
float heading = getHeading(waypoint.getTrackId(), waypoint.getLocation());
|
||||
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), styleName, waypoint.getLocation(), waypoint.getPhotoUrl(), heading);
|
||||
writePhotoOverlay(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), WAYPOINT_STYLE, waypoint.getLocation(), waypoint.getPhotoUrl(), heading);
|
||||
} else {
|
||||
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), styleName, waypoint.getLocation());
|
||||
writePlacemark(waypoint.getName(), waypoint.getCategory(), waypoint.getDescription(), WAYPOINT_STYLE, waypoint.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-23
@@ -44,7 +44,6 @@ import de.dennisguse.opentracks.content.LocationFactory;
|
||||
import de.dennisguse.opentracks.content.LocationIterator;
|
||||
import de.dennisguse.opentracks.content.Track;
|
||||
import de.dennisguse.opentracks.content.Waypoint;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.services.TrackRecordingService;
|
||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||
import de.dennisguse.opentracks.stats.TripStatisticsUpdater;
|
||||
@@ -201,27 +200,14 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
// Valid location
|
||||
if (location.getLatitude() == waypoint.getLocation().getLatitude() && location.getLongitude() == waypoint.getLocation().getLongitude()) {
|
||||
|
||||
// Get tripStatistics, description, and icon
|
||||
TripStatistics tripStatistics;
|
||||
String waypointDescription;
|
||||
String icon;
|
||||
if (waypoint.getType() == WaypointType.STATISTICS) {
|
||||
tripStatistics = markerTripStatisticsUpdater.getTripStatistics();
|
||||
markerTripStatisticsUpdater = new TripStatisticsUpdater(location.getTime());
|
||||
waypointDescription = new DescriptionGeneratorImpl(context).generateWaypointDescription(tripStatistics);
|
||||
icon = context.getString(R.string.marker_statistics_icon_url);
|
||||
} else {
|
||||
tripStatistics = null;
|
||||
waypointDescription = waypoint.getDescription();
|
||||
icon = context.getString(R.string.marker_waypoint_icon_url);
|
||||
}
|
||||
|
||||
// Get length and duration
|
||||
TripStatistics tripStatistics = null;
|
||||
String waypointDescription = waypoint.getDescription();
|
||||
String icon = context.getString(R.string.marker_waypoint_icon_url);
|
||||
double length = trackTripStatisticstrackUpdater.getTripStatistics().getTotalDistance();
|
||||
long duration = trackTripStatisticstrackUpdater.getTripStatistics().getTotalTime();
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint newWaypoint = new Waypoint(waypoint.getName(), waypointDescription, waypoint.getCategory(), icon, track.getId(), waypoint.getType(), length, duration, -1L, -1L, location, tripStatistics, waypoint.getPhotoUrl());
|
||||
Waypoint newWaypoint = new Waypoint(waypoint.getName(), waypointDescription, waypoint.getCategory(), icon, track.getId(), length, duration, -1L, -1L, location, tripStatistics, waypoint.getPhotoUrl());
|
||||
contentProviderUtils.insertWaypoint(newWaypoint);
|
||||
}
|
||||
|
||||
@@ -292,10 +278,8 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
|
||||
/**
|
||||
* Adds a waypoint.
|
||||
*
|
||||
* @param type the waypoint type
|
||||
*/
|
||||
protected void addWaypoint(WaypointType type) throws SAXException {
|
||||
protected void addWaypoint() throws SAXException {
|
||||
// Waypoint must have a time, else cannot match to the track points
|
||||
if (time == null) {
|
||||
return;
|
||||
@@ -318,7 +302,6 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
if (category != null) {
|
||||
waypoint.setCategory(category);
|
||||
}
|
||||
waypoint.setType(type);
|
||||
|
||||
if (photoUrl != null) {
|
||||
waypoint.setPhotoUrl(photoUrl);
|
||||
@@ -505,6 +488,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
*
|
||||
* @param track the track
|
||||
*/
|
||||
@Deprecated //TODO Store statistics for track in track rather than in waypoint.
|
||||
private void insertFirstWaypoint(Track track) {
|
||||
String waypointName = context.getString(R.string.marker_split_name_format, 0);
|
||||
String waypointCategory = "";
|
||||
@@ -517,7 +501,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
Location waypointLocation = new Location("");
|
||||
waypointLocation.setLatitude(100);
|
||||
waypointLocation.setLongitude(180);
|
||||
Waypoint waypoint = new Waypoint(waypointName, waypointDescription, waypointCategory, icon, track.getId(), WaypointType.STATISTICS, length, duration, -1L, -1L, waypointLocation, tripStatistics, "");
|
||||
Waypoint waypoint = new Waypoint(waypointName, waypointDescription, waypointCategory, icon, track.getId(), length, duration, -1L, -1L, waypointLocation, tripStatistics, "");
|
||||
contentProviderUtils.insertWaypoint(waypoint);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
|
||||
/**
|
||||
* Imports a GPX file.
|
||||
@@ -184,6 +183,6 @@ public class GpxFileTrackImporter extends AbstractFileTrackImporter {
|
||||
* On waypoint end.
|
||||
*/
|
||||
private void onWaypointEnd() throws SAXException {
|
||||
addWaypoint(WaypointType.STATISTICS.name().equals(waypointType) ? WaypointType.STATISTICS : WaypointType.WAYPOINT);
|
||||
addWaypoint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.ArrayList;
|
||||
|
||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.SensorDataSetLocation;
|
||||
import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,6 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter {
|
||||
private static final String HEART_RATE = "heart_rate";
|
||||
private static final String POWER = "power";
|
||||
|
||||
private static final String STATISTICS_STYLE = "#statistics";
|
||||
private static final String WAYPOINT_STYLE = "#waypoint";
|
||||
|
||||
private static final String TAG_COORDINATES = "coordinates";
|
||||
@@ -182,29 +180,16 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter {
|
||||
* On waypoint end.
|
||||
*/
|
||||
private void onWaypointEnd() throws SAXException {
|
||||
if (waypointType == null) {
|
||||
if (!WAYPOINT_STYLE.equals(waypointType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a waypoint if the waypointType matches
|
||||
WaypointType type;
|
||||
switch (waypointType) {
|
||||
case WAYPOINT_STYLE:
|
||||
type = WaypointType.WAYPOINT;
|
||||
break;
|
||||
case STATISTICS_STYLE:
|
||||
type = WaypointType.STATISTICS;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (photoUrl != null) {
|
||||
Uri uri = Uri.parse(photoUrl);
|
||||
photoUrl = getPhotoUrl(uri.getLastPathSegment());
|
||||
}
|
||||
|
||||
addWaypoint(type);
|
||||
addWaypoint();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -302,9 +302,9 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
String name = waypointCreationRequest.getName();
|
||||
if (name == null) {
|
||||
int nextWaypointNumber = contentProviderUtils.getNextWaypointNumber(recordingTrackId, waypointCreationRequest.getType());
|
||||
int nextWaypointNumber = contentProviderUtils.getNextWaypointNumber(recordingTrackId);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 0;
|
||||
nextWaypointNumber = 1;
|
||||
}
|
||||
name = getString(R.string.marker_name_format, nextWaypointNumber);
|
||||
}
|
||||
@@ -335,7 +335,7 @@ public class TrackRecordingService extends Service {
|
||||
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest.getPhotoUrl() : "";
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, waypointCreationRequest.getType(), length, duration, -1L, -1L, location, null, photoUrl);
|
||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, length, duration, -1L, -1L, location, null, photoUrl);
|
||||
Uri uri = contentProviderUtils.insertWaypoint(waypoint);
|
||||
return Long.parseLong(uri.getLastPathSegment());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user