forked from upstream-mirrors/OpenTracks
First waypoint of a track does not store the statistics of the track.
This commit is contained in:
+1
-1
@@ -466,7 +466,7 @@ public class CustomContentProviderUtilsTest {
|
|||||||
long waypoint1Id = ContentUris.parseId(contentProviderUtils.insertWaypoint(waypoint1));
|
long waypoint1Id = ContentUris.parseId(contentProviderUtils.insertWaypoint(waypoint1));
|
||||||
|
|
||||||
Waypoint waypoint2 = new Waypoint();
|
Waypoint waypoint2 = new Waypoint();
|
||||||
waypoint2.setDescription(Long.toString(trackId));
|
waypoint2.setDescription(MOCK_DESC);
|
||||||
waypoint2.setTrackId(trackId);
|
waypoint2.setTrackId(trackId);
|
||||||
waypoint2.setTripStatistics(statistics);
|
waypoint2.setTripStatistics(statistics);
|
||||||
long waypoint2Id = ContentUris.parseId(contentProviderUtils.insertWaypoint(waypoint2));
|
long waypoint2Id = ContentUris.parseId(contentProviderUtils.insertWaypoint(waypoint2));
|
||||||
|
|||||||
@@ -158,7 +158,6 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
*/
|
*/
|
||||||
private void addMarker() {
|
private void addMarker() {
|
||||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(
|
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(
|
||||||
false,
|
|
||||||
waypointName.getText().toString(),
|
waypointName.getText().toString(),
|
||||||
waypointMarkerType.getText().toString(),
|
waypointMarkerType.getText().toString(),
|
||||||
waypointDescription.getText().toString(),
|
waypointDescription.getText().toString(),
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
|
|||||||
trackController.update(isRecording(), recordingTrackPaused);
|
trackController.update(isRecording(), recordingTrackPaused);
|
||||||
if (hasPhoto && photoUri != null) {
|
if (hasPhoto && photoUri != null) {
|
||||||
hasPhoto = false;
|
hasPhoto = false;
|
||||||
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(false, null, null, null, null, photoUri.toString());
|
WaypointCreationRequest waypointCreationRequest = new WaypointCreationRequest(null, null, null, null, photoUri.toString());
|
||||||
long markerId = trackRecordingServiceConnection.addMarker(TrackDetailActivity.this, waypointCreationRequest);
|
long markerId = trackRecordingServiceConnection.addMarker(TrackDetailActivity.this, waypointCreationRequest);
|
||||||
if (markerId != -1L) {
|
if (markerId != -1L) {
|
||||||
//TODO: Make configurable.
|
//TODO: Make configurable.
|
||||||
|
|||||||
@@ -23,26 +23,13 @@ package de.dennisguse.opentracks.content;
|
|||||||
*/
|
*/
|
||||||
public class WaypointCreationRequest {
|
public class WaypointCreationRequest {
|
||||||
|
|
||||||
public final static WaypointCreationRequest DEFAULT_WAYPOINT = new WaypointCreationRequest(false);
|
|
||||||
|
|
||||||
@Deprecated // TODO Do not create per
|
|
||||||
public final static WaypointCreationRequest DEFAULT_START_TRACK = new WaypointCreationRequest(true);
|
|
||||||
|
|
||||||
// true if this marker contains the track statistics
|
|
||||||
private boolean isTrackStatistics;
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String category;
|
private String category;
|
||||||
private String description;
|
private String description;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String photoUrl;
|
private String photoUrl;
|
||||||
|
|
||||||
private WaypointCreationRequest(boolean isTrackStatistics) {
|
public WaypointCreationRequest(String name, String category, String description, String iconUrl, String photoUrl) {
|
||||||
this(isTrackStatistics, null, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaypointCreationRequest(boolean isTrackStatistics, String name, String category, String description, String iconUrl, String photoUrl) {
|
|
||||||
this.isTrackStatistics = isTrackStatistics;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@@ -50,10 +37,6 @@ public class WaypointCreationRequest {
|
|||||||
this.photoUrl = photoUrl;
|
this.photoUrl = photoUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTrackStatistics() {
|
|
||||||
return isTrackStatistics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
-24
@@ -39,7 +39,6 @@ import javax.xml.parsers.SAXParserFactory;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
import de.dennisguse.opentracks.content.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.content.DescriptionGeneratorImpl;
|
|
||||||
import de.dennisguse.opentracks.content.LocationFactory;
|
import de.dennisguse.opentracks.content.LocationFactory;
|
||||||
import de.dennisguse.opentracks.content.LocationIterator;
|
import de.dennisguse.opentracks.content.LocationIterator;
|
||||||
import de.dennisguse.opentracks.content.Track;
|
import de.dennisguse.opentracks.content.Track;
|
||||||
@@ -260,7 +259,6 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
trackData.track.setTripStatistics(trackData.tripStatisticsUpdater.getTripStatistics());
|
trackData.track.setTripStatistics(trackData.tripStatisticsUpdater.getTripStatistics());
|
||||||
trackData.track.setNumberOfPoints(trackData.numberOfLocations);
|
trackData.track.setNumberOfPoints(trackData.numberOfLocations);
|
||||||
contentProviderUtils.updateTrack(trackData.track);
|
contentProviderUtils.updateTrack(trackData.track);
|
||||||
insertFirstWaypoint(trackData.track);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -483,28 +481,6 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
data.track.setStopId(contentProviderUtils.getLastTrackPointId(data.track.getId()));
|
data.track.setStopId(contentProviderUtils.getLastTrackPointId(data.track.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserts the first waypoint, the track statistics waypoint.
|
|
||||||
*
|
|
||||||
* @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 = "";
|
|
||||||
TripStatisticsUpdater updater = new TripStatisticsUpdater(track.getTripStatistics().getStartTime());
|
|
||||||
TripStatistics tripStatistics = updater.getTripStatistics();
|
|
||||||
String waypointDescription = new DescriptionGeneratorImpl(context).generateWaypointDescription(tripStatistics);
|
|
||||||
String icon = context.getString(R.string.marker_statistics_icon_url);
|
|
||||||
double length = 0.0;
|
|
||||||
long duration = 0L;
|
|
||||||
Location waypointLocation = new Location("");
|
|
||||||
waypointLocation.setLatitude(100);
|
|
||||||
waypointLocation.setLongitude(180);
|
|
||||||
Waypoint waypoint = new Waypoint(waypointName, waypointDescription, waypointCategory, icon, track.getId(), length, duration, -1L, -1L, waypointLocation, tripStatistics, "");
|
|
||||||
contentProviderUtils.insertWaypoint(waypoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans up import.
|
* Cleans up import.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -306,31 +306,22 @@ public class TrackRecordingService extends Service {
|
|||||||
if (nextWaypointNumber == -1) {
|
if (nextWaypointNumber == -1) {
|
||||||
nextWaypointNumber = 1;
|
nextWaypointNumber = 1;
|
||||||
}
|
}
|
||||||
name = getString(R.string.marker_name_format, nextWaypointNumber);
|
name = getString(R.string.marker_name_format, nextWaypointNumber + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = getLastValidTrackPointInCurrentSegment(recordingTrackId);
|
||||||
|
if (location == null) {
|
||||||
|
Log.i(TAG, "Could not create a waypoint as location is unknown.");
|
||||||
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest.getCategory() : "";
|
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest.getCategory() : "";
|
||||||
String description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest.getDescription() : "";
|
String description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest.getDescription() : "";
|
||||||
String icon = getString(R.string.marker_waypoint_icon_url);
|
String icon = getString(R.string.marker_waypoint_icon_url);
|
||||||
|
|
||||||
double length;
|
TripStatistics stats = trackTripStatisticsUpdater.getTripStatistics();
|
||||||
long duration;
|
double length = stats.getTotalDistance();
|
||||||
Location location = getLastValidTrackPointInCurrentSegment(recordingTrackId);
|
long duration = stats.getTotalTime();
|
||||||
if (location != null && trackTripStatisticsUpdater != null) {
|
|
||||||
TripStatistics stats = trackTripStatisticsUpdater.getTripStatistics();
|
|
||||||
length = stats.getTotalDistance();
|
|
||||||
duration = stats.getTotalTime();
|
|
||||||
} else {
|
|
||||||
if (!waypointCreationRequest.isTrackStatistics()) {
|
|
||||||
return -1L;
|
|
||||||
}
|
|
||||||
// For track statistics, make it an impossible location
|
|
||||||
location = new Location("");
|
|
||||||
location.setLatitude(100);
|
|
||||||
location.setLongitude(180);
|
|
||||||
length = 0.0;
|
|
||||||
duration = 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest.getPhotoUrl() : "";
|
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest.getPhotoUrl() : "";
|
||||||
|
|
||||||
@@ -371,9 +362,6 @@ public class TrackRecordingService extends Service {
|
|||||||
track.setTripStatistics(trackTripStatisticsUpdater.getTripStatistics());
|
track.setTripStatistics(trackTripStatisticsUpdater.getTripStatistics());
|
||||||
contentProviderUtils.updateTrack(track);
|
contentProviderUtils.updateTrack(track);
|
||||||
|
|
||||||
//TODO Do not use insertWaypoint
|
|
||||||
insertWaypoint(WaypointCreationRequest.DEFAULT_START_TRACK);
|
|
||||||
|
|
||||||
startRecording(true);
|
startRecording(true);
|
||||||
return trackId;
|
return trackId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user