store timespan that trackbook was paused, if resume feature is used

This commit is contained in:
y20k 2020-02-18 17:09:54 +01:00
parent d3024387be
commit 382d4e73c1
No known key found for this signature in database
GPG key ID: 824D4259F41FAFF6
4 changed files with 18 additions and 11 deletions

View file

@ -49,11 +49,11 @@ android {
debug { debug {
// Comment out the below lines if you do not need to test resource shrinking // Comment out the below lines if you do not need to test resource shrinking
//minifyEnabled true minifyEnabled true
//shrinkResources true shrinkResources true
//proguardFiles getDefaultProguardFile( proguardFiles getDefaultProguardFile(
// 'proguard-android-optimize.txt'), 'proguard-android-optimize.txt'),
// 'proguard-rules.pro' 'proguard-rules.pro'
} }
} }

View file

@ -213,6 +213,9 @@ class TrackerService(): Service(), CoroutineScope, SensorEventListener {
val lastWayPointIndex = track.wayPoints.size - 1 val lastWayPointIndex = track.wayPoints.size - 1
track.wayPoints.get(lastWayPointIndex).isStopOver = true track.wayPoints.get(lastWayPointIndex).isStopOver = true
} }
// calculate length of recording break
track.recordingPaused = TrackHelper.calculateRecordingPaused(track.recordingStop)
LogHelper.e(TAG, "We took a break for ${DateTimeHelper.convertToReadableTime(this, track.recordingPaused)}") // todo remove
// start tracking // start tracking
startTracking(newTrack = false) startTracking(newTrack = false)
} }

View file

@ -36,6 +36,7 @@ data class Track (@Expose var trackFormatVersion: Int = Keys.CURRENT_TRACK_FORMA
@Expose val wayPoints: MutableList<WayPoint> = mutableListOf<WayPoint>(), @Expose val wayPoints: MutableList<WayPoint> = mutableListOf<WayPoint>(),
@Expose var length: Float = 0f, @Expose var length: Float = 0f,
@Expose var duration: Long = 0L, @Expose var duration: Long = 0L,
@Expose var recordingPaused: Long = 0L,
@Expose var stepCount: Float = 0f, @Expose var stepCount: Float = 0f,
@Expose var recordingStart: Date = GregorianCalendar.getInstance().time, @Expose var recordingStart: Date = GregorianCalendar.getInstance().time,
@Expose var recordingStop: Date = recordingStart, @Expose var recordingStop: Date = recordingStart,

View file

@ -35,15 +35,13 @@ object TrackHelper {
/* Returns unique ID for Track - currently the start date */ /* Returns unique ID for Track - currently the start date */
fun getTrackId(track: Track): Long { fun getTrackId(track: Track): Long =
return track.recordingStart.time track.recordingStart.time
}
/* Returns unique ID for TracklistElement - currently the start date */ /* Returns unique ID for TracklistElement - currently the start date */
fun getTrackId(tracklistElement: TracklistElement): Long { fun getTrackId(tracklistElement: TracklistElement): Long =
return tracklistElement.date.time tracklistElement.date.time
}
/* Adds given locatiom as waypoint to track */ /* Adds given locatiom as waypoint to track */
@ -120,6 +118,11 @@ object TrackHelper {
} }
/* Calculates time passed since last stop of recording */
fun calculateRecordingPaused(recordingStop: Date): Long =
GregorianCalendar.getInstance().time.time - recordingStop.time
/* Creates GPX string for given track */ /* Creates GPX string for given track */
fun createGpxString(track: Track): String { fun createGpxString(track: Track): String {
var gpxString: String var gpxString: String