Add health connect snippets#915
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds several helper functions to the HealthConnectManager class for managing permissions and inserting various Health Connect records. The review identified several issues: an empty conditional block for permission checks, incorrect property usage in the PlannedExerciseSessionRecord constructor, unused function parameters, and typos in function names. Addressing these will improve code correctness, cleanliness, and maintainability.
yrezgui
left a comment
There was a problem hiding this comment.
You need to apply spotless
I have ran spotless command ( ./gradlew spotlessApply) |
| healthConnectClient: HealthConnectClient, | ||
| record: StepsRecord |
There was a problem hiding this comment.
how about this pending comment?
| return permissions | ||
| } | ||
|
|
||
| suspend fun createPermissionHeartRate(): Set<String> { |
There was a problem hiding this comment.
same here, what do you think of this pending comment?
| } | ||
|
|
||
| // [START android_healthconnect_check_permission_launcher] | ||
| val permissions = remember { |
There was a problem hiding this comment.
I don't think we need "remember {}" here because it's a static list, can we just have permissions = setOf(...)?
| if (granted?.containsAll(permissions) == true) { | ||
| val startTime = Instant.now().minusSeconds(3600) | ||
| val endTime = Instant.now() | ||
| manager.insertSteps(startTime, endTime) |
There was a problem hiding this comment.
does this insertSteps() call need to be on an I/O thread? because I thought coroutineScope uses the main dispatcher by default
| } | ||
| } | ||
|
|
||
| fun createSetOfPermissionSleep(): Set<String> { |
There was a problem hiding this comment.
return value can be Unit for these createPermission..() methods in this file right?
| return permissions | ||
| } | ||
|
|
||
| suspend fun createPermissionSleepSession(): Set<String> { |
There was a problem hiding this comment.
for the methods in this file, can you double check that you only add suspend onto the functions that require it? for example, I think suspend can be removed here and we can return Unit for the method
Add snippets for Health Connect site