@flomentumsolutions/capacitor-health-extended 0.0.17 → 0.0.18
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.
|
@@ -270,7 +270,7 @@ class HealthPlugin : Plugin() {
|
|
|
270
270
|
private fun getMetricAndMapper(dataType: String): MetricAndMapper {
|
|
271
271
|
return when (dataType) {
|
|
272
272
|
"steps" -> metricAndMapper("steps", CapHealthPermission.READ_STEPS, StepsRecord.COUNT_TOTAL) { it?.toDouble() }
|
|
273
|
-
"active-calories" -> metricAndMapper(
|
|
273
|
+
"active-calories", "activeCalories" -> metricAndMapper(
|
|
274
274
|
"calories",
|
|
275
275
|
CapHealthPermission.READ_ACTIVE_CALORIES,
|
|
276
276
|
ActiveCaloriesBurnedRecord.ACTIVE_CALORIES_TOTAL
|
|
@@ -301,7 +301,7 @@ class HealthPlugin : Plugin() {
|
|
|
301
301
|
CoroutineScope(Dispatchers.IO).launch {
|
|
302
302
|
try {
|
|
303
303
|
val result = when (dataType) {
|
|
304
|
-
"heart-rate" -> readLatestHeartRate()
|
|
304
|
+
"heart-rate", "heartRate" -> readLatestHeartRate()
|
|
305
305
|
"weight" -> readLatestWeight()
|
|
306
306
|
"height" -> readLatestHeight()
|
|
307
307
|
"steps" -> readLatestSteps()
|
|
@@ -370,11 +370,11 @@ class HealthPlugin : Plugin() {
|
|
|
370
370
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
371
371
|
pageSize = 1
|
|
372
372
|
)
|
|
373
|
-
val
|
|
374
|
-
|
|
373
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
374
|
+
|
|
375
375
|
return JSObject().apply {
|
|
376
|
-
put("value", record
|
|
377
|
-
put("timestamp", record
|
|
376
|
+
put("value", record?.weight?.inKilograms ?: 0)
|
|
377
|
+
put("timestamp", (record?.time?.epochSecond ?: 0) * 1000)
|
|
378
378
|
put("unit", "kg")
|
|
379
379
|
}
|
|
380
380
|
}
|
|
@@ -388,11 +388,10 @@ class HealthPlugin : Plugin() {
|
|
|
388
388
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
389
389
|
pageSize = 1
|
|
390
390
|
)
|
|
391
|
-
val
|
|
392
|
-
val record = result.records.firstOrNull() ?: throw Exception("No step data found")
|
|
391
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
393
392
|
return JSObject().apply {
|
|
394
|
-
put("value", record
|
|
395
|
-
put("timestamp", record
|
|
393
|
+
put("value", record?.count ?: 0)
|
|
394
|
+
put("timestamp", (record?.endTime?.epochSecond ?: 0) * 1000)
|
|
396
395
|
put("unit", "count")
|
|
397
396
|
}
|
|
398
397
|
}
|
|
@@ -406,11 +405,11 @@ class HealthPlugin : Plugin() {
|
|
|
406
405
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
407
406
|
pageSize = 1
|
|
408
407
|
)
|
|
409
|
-
val
|
|
410
|
-
|
|
408
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
409
|
+
|
|
411
410
|
return JSObject().apply {
|
|
412
|
-
put("value", record
|
|
413
|
-
put("timestamp", record
|
|
411
|
+
put("value", record?.heartRateVariabilityMillis ?: 0)
|
|
412
|
+
put("timestamp", (record?.time?.epochSecond ?: 0) * 1000)
|
|
414
413
|
put("unit", "ms")
|
|
415
414
|
}
|
|
416
415
|
}
|
|
@@ -424,12 +423,12 @@ class HealthPlugin : Plugin() {
|
|
|
424
423
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
425
424
|
pageSize = 1
|
|
426
425
|
)
|
|
427
|
-
val
|
|
428
|
-
|
|
426
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
427
|
+
|
|
429
428
|
return JSObject().apply {
|
|
430
|
-
put("systolic", record
|
|
431
|
-
put("diastolic", record
|
|
432
|
-
put("timestamp", record
|
|
429
|
+
put("systolic", record?.systolic?.inMillimetersOfMercury ?: 0)
|
|
430
|
+
put("diastolic", record?.diastolic?.inMillimetersOfMercury ?: 0)
|
|
431
|
+
put("timestamp", (record?.time?.epochSecond ?: 0) * 1000)
|
|
433
432
|
put("unit", "mmHg")
|
|
434
433
|
}
|
|
435
434
|
}
|
|
@@ -443,11 +442,11 @@ class HealthPlugin : Plugin() {
|
|
|
443
442
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
444
443
|
pageSize = 1
|
|
445
444
|
)
|
|
446
|
-
val
|
|
447
|
-
|
|
445
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
446
|
+
|
|
448
447
|
return JSObject().apply {
|
|
449
|
-
put("value", record
|
|
450
|
-
put("timestamp", record
|
|
448
|
+
put("value", record?.height?.inMeters ?: 0)
|
|
449
|
+
put("timestamp", (record?.time?.epochSecond ?: 0) * 1000)
|
|
451
450
|
put("unit", "m")
|
|
452
451
|
}
|
|
453
452
|
}
|
|
@@ -461,11 +460,10 @@ class HealthPlugin : Plugin() {
|
|
|
461
460
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
462
461
|
pageSize = 1
|
|
463
462
|
)
|
|
464
|
-
val
|
|
465
|
-
val record = result.records.firstOrNull() ?: throw Exception("No distance data found")
|
|
463
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
466
464
|
return JSObject().apply {
|
|
467
|
-
put("value", record
|
|
468
|
-
put("timestamp", record
|
|
465
|
+
put("value", record?.distance?.inMeters ?: 0)
|
|
466
|
+
put("timestamp", (record?.endTime?.epochSecond ?: 0) * 1000)
|
|
469
467
|
put("unit", "m")
|
|
470
468
|
}
|
|
471
469
|
}
|
|
@@ -479,11 +477,10 @@ class HealthPlugin : Plugin() {
|
|
|
479
477
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
480
478
|
pageSize = 1
|
|
481
479
|
)
|
|
482
|
-
val
|
|
483
|
-
val record = result.records.firstOrNull() ?: throw Exception("No active calories data found")
|
|
480
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
484
481
|
return JSObject().apply {
|
|
485
|
-
put("value", record
|
|
486
|
-
put("timestamp", record
|
|
482
|
+
put("value", record?.energy?.inKilocalories ?: 0)
|
|
483
|
+
put("timestamp", (record?.endTime?.epochSecond ?: 0) * 1000)
|
|
487
484
|
put("unit", "kcal")
|
|
488
485
|
}
|
|
489
486
|
}
|
|
@@ -497,11 +494,10 @@ class HealthPlugin : Plugin() {
|
|
|
497
494
|
timeRangeFilter = TimeRangeFilter.after(Instant.EPOCH),
|
|
498
495
|
pageSize = 1
|
|
499
496
|
)
|
|
500
|
-
val
|
|
501
|
-
val record = result.records.firstOrNull() ?: throw Exception("No total calories data found")
|
|
497
|
+
val record = healthConnectClient.readRecords(request).records.firstOrNull()
|
|
502
498
|
return JSObject().apply {
|
|
503
|
-
put("value", record
|
|
504
|
-
put("timestamp", record
|
|
499
|
+
put("value", record?.energy?.inKilocalories ?: 0)
|
|
500
|
+
put("timestamp", (record?.endTime?.epochSecond ?: 0) * 1000)
|
|
505
501
|
put("unit", "kcal")
|
|
506
502
|
}
|
|
507
503
|
}
|
|
@@ -623,7 +619,7 @@ class HealthPlugin : Plugin() {
|
|
|
623
619
|
)
|
|
624
620
|
|
|
625
621
|
return response.map {
|
|
626
|
-
val mappedValue = metricAndMapper.getValue(it.result)
|
|
622
|
+
val mappedValue = metricAndMapper.getValue(it.result) ?: 0.0
|
|
627
623
|
AggregatedSample(it.startTime, it.endTime, mappedValue)
|
|
628
624
|
}
|
|
629
625
|
|
package/package.json
CHANGED