Skip to content

Commit

Permalink
* switched TimerComplicationService.kt to use DynamicValues *2
Browse files Browse the repository at this point in the history
Signed-off-by: amoledwatchfaces <[email protected]>
  • Loading branch information
amoledwatchfaces committed Oct 1, 2024
1 parent a67b004 commit c07b703
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,12 @@ class TimerComplicationService : SuspendingComplicationDataSourceService() {
}

override suspend fun onComplicationRequest(request: ComplicationRequest): ComplicationData? {
//Log.i("TimerComplicationService", "onComplicationRequest id: ${request.complicationInstanceId}")

val startMillis = preferences.first().startTime
val targetMillis = preferences.first().timePicked

val currentTime = System.currentTimeMillis()
val timeRange = (targetMillis - startMillis) / 1000
val timePassed = (currentTime - startMillis) / 1000
val timeLeft = (timeRange - timePassed)

/** Use DynamicValue in API 33+ **/

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
/*
if (currentTime < targetMillis) {
Expand Down Expand Up @@ -202,6 +196,10 @@ class TimerComplicationService : SuspendingComplicationDataSourceService() {
}
/** Use WorkManger in API 27+ **/
else {
val currentTime = System.currentTimeMillis()
val timePassed = (currentTime - startMillis) / 1000
val timeLeft = (timeRange - timePassed)

/*
Log.i("TimerComplicationService", "Time Range: $timeRange")
Log.i("TimerComplicationService", "Time Passed: $timePassed")
Expand Down Expand Up @@ -260,6 +258,6 @@ class TimerComplicationService : SuspendingComplicationDataSourceService() {
}
}
}
}
}
}

0 comments on commit c07b703

Please sign in to comment.