forked from upstream-mirrors/OpenTracks
+2
-2
@@ -296,7 +296,7 @@ public class TrackRecordingServiceTest {
|
||||
assertFalse(service.isRecording());
|
||||
|
||||
// when
|
||||
Marker.Id waypointId = service.insertWaypoint(null, null, null, null);
|
||||
Marker.Id waypointId = service.insertMarker(null, null, null, null);
|
||||
|
||||
// then
|
||||
assertNull(waypointId);
|
||||
@@ -313,7 +313,7 @@ public class TrackRecordingServiceTest {
|
||||
Track.Id trackId = service.getRecordingTrackId();
|
||||
|
||||
// when
|
||||
Marker.Id waypointId = service.insertWaypoint(null, null, null, null);
|
||||
Marker.Id waypointId = service.insertMarker(null, null, null, null);
|
||||
|
||||
// then
|
||||
assertNotEquals(-1L, waypointId);
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ public class TrackRecordingServiceTestLooper {
|
||||
service.newTrackPoint(trackPoint, prefAccuracy);
|
||||
|
||||
if (i % 7 == 0) {
|
||||
service.insertWaypoint(null, null, null, null);
|
||||
service.insertMarker(null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
return trackStatisticsUpdater.getTrackStatistics();
|
||||
}
|
||||
|
||||
//TODO Throw exception, when not recording.
|
||||
public long getTotalTime() {
|
||||
if (trackStatisticsUpdater == null) {
|
||||
return 0;
|
||||
@@ -225,27 +226,22 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
return trackStatisticsUpdater.getTrackStatistics().getTotalTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a waypoint.
|
||||
*
|
||||
* @return the waypoint id
|
||||
*/
|
||||
public Marker.Id insertWaypoint(String name, String category, String description, String photoUrl) {
|
||||
public Marker.Id insertMarker(String name, String category, String description, String photoUrl) {
|
||||
if (!isRecording() || isPaused()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
int nextWaypointNumber = contentProviderUtils.getNextMarkerNumber(recordingTrackId);
|
||||
if (nextWaypointNumber == -1) {
|
||||
nextWaypointNumber = 1;
|
||||
int nextMarkerNumber = contentProviderUtils.getNextMarkerNumber(recordingTrackId);
|
||||
if (nextMarkerNumber == -1) {
|
||||
nextMarkerNumber = 1;
|
||||
}
|
||||
name = getString(R.string.marker_name_format, nextWaypointNumber + 1);
|
||||
name = getString(R.string.marker_name_format, nextMarkerNumber + 1);
|
||||
}
|
||||
|
||||
TrackPoint trackPoint = getLastValidTrackPointInCurrentSegment(recordingTrackId);
|
||||
if (trackPoint == null) {
|
||||
Log.i(TAG, "Could not create a waypoint as trackPoint is unknown.");
|
||||
Log.i(TAG, "Could not create a marker as trackPoint is unknown.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -258,9 +254,9 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
double length = stats.getTotalDistance();
|
||||
long duration = stats.getTotalTime();
|
||||
|
||||
// Insert waypoint
|
||||
Marker waypoint = new Marker(name, description, category, icon, recordingTrackId, length, duration, trackPoint.getLocation(), photoUrl);
|
||||
Uri uri = contentProviderUtils.insertMarker(waypoint);
|
||||
// Insert marker
|
||||
Marker marker = new Marker(name, description, category, icon, recordingTrackId, length, duration, trackPoint.getLocation(), photoUrl);
|
||||
Uri uri = contentProviderUtils.insertMarker(marker);
|
||||
return new Marker.Id(ContentUris.parseId(uri));
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ class TrackRecordingServiceBinder extends android.os.Binder implements TrackReco
|
||||
}
|
||||
|
||||
@Override
|
||||
public Marker.Id insertWaypoint(String name, String category, String description, String photoUrl) {
|
||||
return trackRecordingService.insertWaypoint(name, category, description, photoUrl);
|
||||
public Marker.Id insertMarker(String name, String category, String description, String photoUrl) {
|
||||
return trackRecordingService.insertMarker(name, category, description, photoUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-9
@@ -187,10 +187,10 @@ public class TrackRecordingServiceConnection implements ServiceConnection, Death
|
||||
Log.d(TAG, "Unable to add marker, no track recording service");
|
||||
} else {
|
||||
try {
|
||||
Marker.Id waypoint = trackRecordingService.insertWaypoint(name, category, description, photoUrl);
|
||||
if (waypoint != null) {
|
||||
Marker.Id marker = trackRecordingService.insertMarker(name, category, description, photoUrl);
|
||||
if (marker != null) {
|
||||
Toast.makeText(context, R.string.marker_add_success, Toast.LENGTH_SHORT).show();
|
||||
return waypoint;
|
||||
return marker;
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
Log.e(TAG, "Unable to add marker.", e);
|
||||
@@ -201,12 +201,6 @@ public class TrackRecordingServiceConnection implements ServiceConnection, Death
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the recording.
|
||||
*
|
||||
* @param context the context
|
||||
* @param showEditor true to show the editor
|
||||
*/
|
||||
public void stopRecording(@NonNull Context context, boolean showEditor) {
|
||||
TrackRecordingServiceInterface trackRecordingService = getServiceIfBound();
|
||||
if (trackRecordingService == null) {
|
||||
|
||||
+3
-34
@@ -30,46 +30,20 @@ import de.dennisguse.opentracks.services.sensors.BluetoothRemoteSensorManager;
|
||||
*/
|
||||
public interface TrackRecordingServiceInterface {
|
||||
|
||||
/**
|
||||
* Starts gps.
|
||||
*/
|
||||
void startGps();
|
||||
|
||||
/**
|
||||
* Stops gps.
|
||||
*/
|
||||
void stopGps();
|
||||
|
||||
/**
|
||||
* Starts recording a new track.
|
||||
*
|
||||
* @return the track ID of the new track.
|
||||
*/
|
||||
Track.Id startNewTrack();
|
||||
|
||||
/**
|
||||
* Resumes the track identified by trackId.
|
||||
*/
|
||||
void resumeTrack(Track.Id trackId);
|
||||
|
||||
/**
|
||||
* Pauses the current recording track.
|
||||
*/
|
||||
void pauseCurrentTrack();
|
||||
|
||||
/**
|
||||
* Resumes the current recording track.
|
||||
*/
|
||||
void resumeCurrentTrack();
|
||||
|
||||
/**
|
||||
* Ends the current recording track.
|
||||
*/
|
||||
void resumeTrack(Track.Id trackId);
|
||||
|
||||
void endCurrentTrack();
|
||||
|
||||
/**
|
||||
* Returns true if currently recording a track.
|
||||
*/
|
||||
boolean isRecording();
|
||||
|
||||
/**
|
||||
@@ -88,12 +62,7 @@ public interface TrackRecordingServiceInterface {
|
||||
//TODO milliseconds?
|
||||
long getTotalTime();
|
||||
|
||||
/**
|
||||
* Inserts a waypoint in the current recording track.
|
||||
*
|
||||
* @return the ID of the inserted waypoint
|
||||
*/
|
||||
Marker.Id insertWaypoint(String name, String category, String description, String photoUrl);
|
||||
Marker.Id insertMarker(String name, String category, String description, String photoUrl);
|
||||
|
||||
/**
|
||||
* Gets the current sensor data. Returns null if there is no data.
|
||||
|
||||
Reference in New Issue
Block a user