@interval-health/capacitor-health 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ ext {
6
6
  androidxAppCompatVersion = '1.7.0'
7
7
  androidxJunitVersion = '1.2.1'
8
8
  androidxEspressoCoreVersion = '3.6.1'
9
+
9
10
  }
10
11
 
11
12
  buildscript {
@@ -27,7 +28,7 @@ android {
27
28
  compileSdk = 36
28
29
 
29
30
  defaultConfig {
30
- minSdk 26
31
+ minSdk 24
31
32
  targetSdk 36
32
33
  versionCode 1
33
34
  versionName "1.0"
@@ -3,6 +3,7 @@ package app.capgo.plugin.health
3
3
  import androidx.health.connect.client.HealthConnectClient
4
4
  import androidx.health.connect.client.records.ActiveCaloriesBurnedRecord
5
5
  import androidx.health.connect.client.records.DistanceRecord
6
+ import androidx.health.connect.client.records.ExerciseSessionRecord
6
7
  import androidx.health.connect.client.records.HeartRateRecord
7
8
  import androidx.health.connect.client.records.Record
8
9
  import androidx.health.connect.client.records.SleepSessionRecord
@@ -141,6 +142,21 @@ class HealthManager {
141
142
  )
142
143
  samples.add(record.startTime to payload)
143
144
  }
145
+ HealthDataType.WORKOUT -> readRecords(client, ExerciseSessionRecord::class, startTime, endTime, limit) { record ->
146
+ val durationMinutes = (record.endTime.toEpochMilli() - record.startTime.toEpochMilli()) / 60000.0
147
+ val payload = createSamplePayload(
148
+ dataType,
149
+ record.startTime,
150
+ record.endTime,
151
+ durationMinutes,
152
+ record.metadata
153
+ )
154
+ samples.add(record.startTime to payload)
155
+ }
156
+ HealthDataType.MOBILITY -> {
157
+ // Mobility is a composite type not directly backed by a single record type.
158
+ // No-op: return empty samples.
159
+ }
144
160
  }
145
161
 
146
162
  val sorted = samples.sortedBy { it.first }
@@ -257,6 +273,20 @@ class HealthManager {
257
273
  )
258
274
  client.insertRecords(listOf(record))
259
275
  }
276
+ HealthDataType.WORKOUT -> {
277
+ val record = ExerciseSessionRecord(
278
+ startTime = startTime,
279
+ startZoneOffset = zoneOffset(startTime),
280
+ endTime = endTime,
281
+ endZoneOffset = zoneOffset(endTime),
282
+ exerciseType = ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
283
+ )
284
+ client.insertRecords(listOf(record))
285
+ }
286
+ HealthDataType.MOBILITY -> {
287
+ // Mobility is a composite type not directly backed by a single record type.
288
+ throw UnsupportedOperationException("Saving mobility data is not supported")
289
+ }
260
290
  }
261
291
  }
262
292
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interval-health/capacitor-health",
3
- "version": "1.4.0",
3
+ "version": "2.0.0",
4
4
  "description": "Capacitor plugin to interact with data from Apple HealthKit and Health Connect",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -19,10 +19,10 @@
19
19
  "license": "MPL-2.0",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/sandip-3008/capacitor-health"
22
+ "url": "git+https://github.com/sandip-3008/capacitor-apple-health"
23
23
  },
24
24
  "bugs": {
25
- "url": "https://github.com/sandip-3008/capacitor-health/issues"
25
+ "url": "https://github.com/sandip-3008/capacitor-apple-health/issues"
26
26
  },
27
27
  "keywords": [
28
28
  "capacitor",