fixes calculation auf pauses & displays start time in addition to start date
This commit is contained in:
		
							parent
							
								
									8796aa9331
								
							
						
					
					
						commit
						f686cac359
					
				
					 11 changed files with 23 additions and 17 deletions
				
			
		|  | @ -72,10 +72,10 @@ dependencies { | |||
|     implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||||
|     implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' | ||||
|     implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' | ||||
|     implementation "androidx.preference:preference-ktx:1.1.0" | ||||
|     implementation "androidx.preference:preference-ktx:1.1.1" | ||||
| 
 | ||||
|     implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' | ||||
|     implementation 'androidx.navigation:navigation-ui-ktx:2.2.1' | ||||
|     implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2' | ||||
|     implementation 'androidx.navigation:navigation-ui-ktx:2.2.2' | ||||
| 
 | ||||
| 
 | ||||
|     implementation "com.google.android.material:material:1.1.0-beta01" | ||||
|  |  | |||
|  | @ -215,7 +215,7 @@ class TrackerService(): Service(), CoroutineScope, SensorEventListener { | |||
|         // set resumed flag | ||||
|         resumed = true | ||||
|         // calculate length of recording break | ||||
|         track.recordingPaused = TrackHelper.calculateRecordingPaused(track.recordingStop) | ||||
|         track.recordingPaused = track.recordingPaused + TrackHelper.calculateDurationOfPause(track.recordingStop) | ||||
|         // start tracking | ||||
|         startTracking(newTrack = false) | ||||
|     } | ||||
|  |  | |||
|  | @ -20,7 +20,6 @@ package org.y20k.trackbook.dialogs | |||
| import android.content.Context | ||||
| import android.text.InputType | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.widget.EditText | ||||
| import android.widget.TextView | ||||
| import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||||
|  | @ -51,7 +50,7 @@ class RenameTrackDialog (private var renameTrackListener: RenameTrackListener) { | |||
|         // get input field | ||||
|         val inflater = LayoutInflater.from(context) | ||||
|         val view = inflater.inflate(R.layout.dialog_rename_track, null) | ||||
|         val inputField = view.findViewById<View>(R.id.dialog_rename_track_input_edit_text) as EditText | ||||
|         val inputField = view.findViewById<EditText>(R.id.dialog_rename_track_input_edit_text) | ||||
| 
 | ||||
|         // pre-fill with current track name | ||||
|         inputField.setText(trackName, TextView.BufferType.EDITABLE) | ||||
|  |  | |||
|  | @ -56,19 +56,25 @@ object DateTimeHelper { | |||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* Create sortable string from date - used for filenames  */ | ||||
|     /* Create sortable string for date - used for filenames  */ | ||||
|     fun convertToSortableDateString(date: Date): String { | ||||
|         val dateFormat: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US) | ||||
|         return dateFormat.format(date) | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* Creates a readable string from date - used in the UI */ | ||||
|     /* Creates a readable string for date - used in the UI */ | ||||
|     fun convertToReadableDate(date: Date, dateStyle: Int = DateFormat.LONG): String { | ||||
|         return DateFormat.getDateInstance(dateStyle, Locale.getDefault()).format(date) | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* Creates a readable string date and time - used in the UI */ | ||||
|     fun convertToReadableDateAndTime(date: Date, dateStyle: Int = DateFormat.SHORT, timeStyle: Int = DateFormat.SHORT): String { | ||||
|         return "${DateFormat.getDateInstance(dateStyle, Locale.getDefault()).format(date)} ${DateFormat.getTimeInstance(timeStyle, Locale.getDefault()).format(date)}" | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* Calculates time difference between two locations */ | ||||
|     fun calculateTimeDistance(previousLocation: Location?, location: Location): Long  { | ||||
|         var timeDifference: Long = 0L | ||||
|  |  | |||
|  | @ -75,7 +75,7 @@ object LocationHelper { | |||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* Determines whether one Location reading is better than the current Location fix */ | ||||
|     /* Determines whether one location reading is better than the current location fix */ | ||||
|     fun isBetterLocation(location: Location, currentBestLocation: Location?): Boolean { | ||||
|         // Credit: https://developer.android.com/guide/topics/location/strategies.html#BestEstimate | ||||
| 
 | ||||
|  |  | |||
|  | @ -145,7 +145,7 @@ object TrackHelper { | |||
| 
 | ||||
| 
 | ||||
|     /* Calculates time passed since last stop of recording */ | ||||
|     fun calculateRecordingPaused(recordingStop: Date): Long = | ||||
|     fun calculateDurationOfPause(recordingStop: Date): Long = | ||||
|         GregorianCalendar.getInstance().time.time - recordingStop.time | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -111,10 +111,10 @@ class TracklistAdapter(private val fragment: Fragment) : RecyclerView.Adapter<Re | |||
|         val backgroundJob = Job() | ||||
|         val uiScope = CoroutineScope(Dispatchers.Main + backgroundJob) | ||||
|         uiScope.launch { | ||||
|             notifyItemRemoved(position) | ||||
|             val deferred: Deferred<Tracklist> = async { FileHelper.deleteTrackSuspended(context, position, tracklist) } | ||||
|             // wait for result and store in tracklist | ||||
|             tracklist = deferred.await() | ||||
|             notifyItemRemoved(position) | ||||
|             backgroundJob.cancel() | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -185,8 +185,8 @@ data class TrackFragmentLayoutHolder(var context: Context, var inflater: LayoutI | |||
|         stepsView.text = steps | ||||
|         waypointsView.text = track.wayPoints.size.toString() | ||||
|         durationView.text = DateTimeHelper.convertToReadableTime(context, track.duration) | ||||
|         recordingStartView.text = DateTimeHelper.convertToReadableDate(track.recordingStart) | ||||
|         recordingStopView.text = DateTimeHelper.convertToReadableDate(track.recordingStart) | ||||
|         recordingStartView.text = DateTimeHelper.convertToReadableDateAndTime(track.recordingStart) | ||||
|         recordingStopView.text = DateTimeHelper.convertToReadableDateAndTime(track.recordingStart) | ||||
|         maxAltitudeView.text = LengthUnitHelper.convertDistanceToString(track.maxAltitude, useImperialUnits) | ||||
|         minAltitudeView.text = LengthUnitHelper.convertDistanceToString(track.minAltitude, useImperialUnits) | ||||
|         positiveElevationView.text = LengthUnitHelper.convertDistanceToString(track.positiveElevation, useImperialUnits) | ||||
|  |  | |||
|  | @ -16,6 +16,7 @@ | |||
|         android:layout_marginBottom="24dp" | ||||
|         android:hint="@string/dialog_rename_track_input_hint" | ||||
|         android:maxLines="1" | ||||
|         app:endIconMode="clear_text" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|  |  | |||
|  | @ -1,16 +1,16 @@ | |||
| // Top-level build file where you can add configuration options common to all sub-projects/modules. | ||||
| 
 | ||||
| buildscript { | ||||
|     ext.kotlin_version = '1.3.71' | ||||
|     ext.kotlin_version = '1.3.72' | ||||
|     repositories { | ||||
|         google() | ||||
|         jcenter() | ||||
|          | ||||
|     } | ||||
|     dependencies { | ||||
|         classpath 'com.android.tools.build:gradle:3.6.1' | ||||
|         classpath 'com.android.tools.build:gradle:3.6.3' | ||||
|         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||||
|         classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1" | ||||
|         classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.2" | ||||
|         // NOTE: Do not place your application dependencies here; they belong | ||||
|         // in the individual module build.gradle files | ||||
|     } | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| # v2.0.3 - Echoes | ||||
| 
 | ||||
| **2020-03-13** | ||||
| - updated translation | ||||
| - updated translations | ||||
| - minor bug fixes (e.g. plausibility check for the first location) | ||||
		Loading…
	
		Reference in a new issue
	
	 y20k
						y20k