Health: Google Health Connect and Apple Health sync support#132
Health: Google Health Connect and Apple Health sync support#132sjp4 merged 7 commits intocoredevices:masterfrom
Conversation
| private val firestoreLocker: FirestoreLocker, | ||
| private val libPebble: LibPebble, | ||
| ) : CoreBackgroundSync { | ||
| ) : CoreBackgroundSync, KoinComponent { |
There was a problem hiding this comment.
Shouldn't use KoinComponent / by inject() here - just add to the constructor parameters to inject (like libPebble etc)
| firestoreLocker.init() | ||
| oneTimeSetLockerOrderMode() | ||
| // Health: request data from watch, sync to platform, and auto-sync on new data | ||
| libPebble.requestHealthData() |
There was a problem hiding this comment.
This won't do anything - there won't be any watches connected when the app starts
| platformHealthSync.sync() | ||
| } | ||
| platformHealthSync.startAutoSync(GlobalScope) |
There was a problem hiding this comment.
This should be merged in into one call
| scope.launch { | ||
| appResumed.appResumed.collect { | ||
| libPebble.requestHealthData() | ||
| sync() |
There was a problem hiding this comment.
This won't work (the sync will fire before health data has been collected - the suspending requestHealthData call only waits until the request has been ACKed). The sync call above from healthDataUpdated should handle this.
| android:permission="android.permission.BIND_JOB_SERVICE" | ||
| android:exported="false"> | ||
| </service> | ||
| <activity-alias |
| } | ||
| } | ||
| healthSyncTracker.enabled = enabled | ||
| healthPlatformSyncEnabled = enabled |
There was a problem hiding this comment.
Does this end up wrong if the user rejects the permission request?
| return@launch | ||
| } | ||
| } | ||
| healthSyncTracker.enabled = enabled |
There was a problem hiding this comment.
Probably should manage this inside PlatformHealthSync (settings screen shouldn't know to have to track this)
| topLevelType = TopLevelType.Phone, | ||
| section = Section.Health, | ||
| checked = healthPlatformSyncEnabled, | ||
| description = "Write steps, heart rate, sleep, and workouts to your phone's health platform", |
There was a problem hiding this comment.
add enabled = healthSettings.trackingEnabled (only show if health is enabled)
| description = if (isSyncing) "Syncing..." else "Sync Pebble health data to phone", | ||
| topLevelType = TopLevelType.Phone, | ||
| section = Section.Health, | ||
| show = { healthPlatformSyncEnabled }, |
| expect fun makeTokenClipEntry(token: String): ClipEntry | ||
|
|
||
| object SettingsKeys { | ||
| const val KEY_HEALTH_PLATFORM_SYNC = "health_platform_sync_enabled" |
background syncing. apple health and google health connect integration complete. added open workouts to health sync. fix sleep data sync. # Conflicts: # composeApp/src/commonMain/kotlin/coredevices/coreapp/CommonAppDelegate.kt # composeApp/src/commonMain/kotlin/coredevices/coreapp/di/utilModule.kt # gradle/libs.versions.toml # pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchSettingsScreen.kt # Conflicts: # composeApp/src/commonMain/kotlin/coredevices/coreapp/ui/screens/OnboardingScreen.kt
It never returned success because WRITE_EXERCISE_ROUTE is implicitly requested and wasn't in the manifest
|
|

Implemented with the help of Claude and HealthKMP!