Skip to content

1.1.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 01 Dec 10:10
· 4 commits to main since this release

What's Changed

  • KHealth now supports basic Exercise/Workout records (#14)
  • The library uses Kotlin version 2.1.0 now (#13)

To check for Exercise/Workout permissions:

val response = kHealth
    .checkPermissions(KHPermission.Exercise(read = true, write = true))
    .filterIsInstance<KHPermission.Exercise>()
    .firstOrNull()
        
if (response != null) {
    println("Is read granted? ${response.read} -- Is write granted? ${response.write}")
}

Use the same syntax for requesting Exercise permissions:

val response = kHealth
    .requestPermissions(KHPermission.Exercise(read = true, write = true))
    .filterIsInstance<KHPermission.Exercise>()
    .firstOrNull()
        
if (response != null) {
    println("Is read granted? ${response.read} -- Is write granted? ${response.write}")
}

To save an Exercise record:

val response = kHealth.writeRecords(
    KHRecord.Exercise(
        type = KHExerciseType.Golf,
        startTime = Clock.System.now().minus(36.minutes),
        endTime = Clock.System.now()
    )
)
println(
    if (response == KHWriteResponse.Success) "Writing exercise succeeded ✅"
    else "Writing exercise failed ❌"
)

To read an Exercise record:

val records = kHealth.readRecords(
    KHReadRequest.Exercise(
        startTime = Clock.System.now().minus(1.days),
        endTime = Clock.System.now()
    )
)
println("Exercise records: $records")

Full Changelog: 1.0.0...1.1.0