A fork of Simple Time Tracker with WearOS support. (Now integrated upstream)
0

Configure Feed

Select the types of activity you want to include in your feed.

add two duration formats for csv export

razeeman (Mar 5, 2023, 12:32 PM +0300) 4d076ac4 9197c943

+21 -7
+1 -1
buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Deps.kt
··· 53 53 const val viewModel = 54 54 "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.viewModelKtx}" 55 55 const val room = 56 - "androidx.room:room-ktx:${Versions.roomKtx}" 56 + "androidx.room:room-ktx:${Versions.room}" 57 57 const val navigationFragment = 58 58 "androidx.navigation:navigation-fragment-ktx:${Versions.navigationKtx}" 59 59 const val navigationUi =
+1 -2
buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Versions.kt
··· 13 13 const val constraintLayout = "2.1.4" 14 14 const val recyclerView = "1.1.0" 15 15 const val lifecycleExtensions = "2.2.0" 16 - const val room = "2.2.5" 16 + const val room = "2.4.3" 17 17 const val dagger = "2.42" 18 18 const val viewpager2 = "1.0.0" 19 19 const val flexBox = "2.0.1" ··· 26 26 const val liveDataCoreKtx = "2.2.0" 27 27 const val liveDataKtx = "2.2.0" 28 28 const val viewModelKtx = "2.2.0" 29 - const val roomKtx = "2.2.5" 30 29 const val navigationKtx = "2.3.5" 31 30 32 31 const val junit = "4.13"
+1 -1
core/src/main/java/com/example/util/simpletimetracker/core/di/BaseViewModelFactory.kt
··· 8 8 private val viewModel: VM 9 9 ) : ViewModelProvider.Factory { 10 10 11 - override fun <T : ViewModel?> create(modelClass: Class<T>): T { 11 + override fun <T : ViewModel> create(modelClass: Class<T>): T { 12 12 @Suppress("UNCHECKED_CAST") 13 13 return viewModel as T 14 14 }
+18 -3
data_local/src/main/java/com/example/util/simpletimetracker/data_local/resolver/CsvRepoImpl.kt
··· 96 96 ): String? { 97 97 return if (recordType != null) { 98 98 String.format( 99 - "\"%s\",%s,%s,\"%s\",\"%s\",\"%s\",%s\n", 99 + "\"%s\",%s,%s,\"%s\",\"%s\",\"%s\",%s,%s\n", 100 100 recordType.name, 101 101 formatDateTime(record.timeStarted), 102 102 formatDateTime(record.timeEnded), ··· 104 104 categories.takeUnless { it.isEmpty() }?.joinToString(separator = ", ") { it.name }.orEmpty(), 105 105 recordTags.takeUnless { it.isEmpty() }?.joinToString(separator = ", ") { it.name }.orEmpty(), 106 106 formatDuration(record.timeEnded - record.timeStarted), 107 + formatDurationMinutes(record.timeEnded - record.timeStarted), 107 108 ) 108 109 } else { 109 110 null ··· 116 117 } 117 118 } 118 119 119 - private fun formatDuration(interval: Long): String { 120 + private fun formatDurationMinutes(interval: Long): String { 120 121 val min: Long = TimeUnit.MILLISECONDS.toMinutes(interval) 121 122 return min.toString() 122 123 } 123 124 125 + private fun formatDuration(interval: Long): String { 126 + val hr: Long = TimeUnit.MILLISECONDS.toHours( 127 + interval 128 + ) 129 + val min: Long = TimeUnit.MILLISECONDS.toMinutes( 130 + interval - TimeUnit.HOURS.toMillis(hr) 131 + ) 132 + val sec: Long = TimeUnit.MILLISECONDS.toSeconds( 133 + interval - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min) 134 + ) 135 + 136 + return "$hr:$min:$sec" 137 + } 138 + 124 139 companion object { 125 - private const val CSV_HEADER = "activity name,time started,time ended,comment,categories,record tags,duration\n" 140 + private const val CSV_HEADER = "activity name,time started,time ended,comment,categories,record tags,duration,duration minutes\n" 126 141 127 142 private val dateTimeFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US) 128 143 }