react-native-health-connect 2.0.0 → 2.0.2
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.
package/android/src/main/java/dev/matinzd/healthconnect/records/ReactExerciseSessionRecord.kt
CHANGED
|
@@ -18,6 +18,17 @@ import java.time.Instant
|
|
|
18
18
|
class ReactExerciseSessionRecord : ReactHealthRecordImpl<ExerciseSessionRecord> {
|
|
19
19
|
override fun parseWriteRecord(records: ReadableArray): List<ExerciseSessionRecord> {
|
|
20
20
|
return records.toMapList().map {
|
|
21
|
+
val routeList = it.getMap("exerciseRoute")?.getArray("route")?.toMapList()?.map { sample ->
|
|
22
|
+
ExerciseRoute.Location(
|
|
23
|
+
time = Instant.parse(sample.getString("time")),
|
|
24
|
+
latitude = sample.getDouble("latitude"),
|
|
25
|
+
longitude = sample.getDouble("longitude"),
|
|
26
|
+
horizontalAccuracy = getLengthFromJsMap(sample.getMap("horizontalAccuracy")),
|
|
27
|
+
verticalAccuracy = getLengthFromJsMap(sample.getMap("verticalAccuracy")),
|
|
28
|
+
altitude = getLengthFromJsMap(sample.getMap("altitude")),
|
|
29
|
+
)
|
|
30
|
+
} ?: emptyList()
|
|
31
|
+
|
|
21
32
|
ExerciseSessionRecord(
|
|
22
33
|
startTime = Instant.parse(it.getString("startTime")),
|
|
23
34
|
endTime = Instant.parse(it.getString("endTime")),
|
|
@@ -45,18 +56,13 @@ class ReactExerciseSessionRecord : ReactHealthRecordImpl<ExerciseSessionRecord>
|
|
|
45
56
|
repetitions = sample.getSafeInt("repetitions", 0),
|
|
46
57
|
)
|
|
47
58
|
} ?: emptyList(),
|
|
48
|
-
exerciseRoute =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
verticalAccuracy = getLengthFromJsMap(sample.getMap("verticalAccuracy")),
|
|
56
|
-
altitude = getLengthFromJsMap(sample.getMap("altitude")),
|
|
57
|
-
)
|
|
58
|
-
} ?: emptyList(),
|
|
59
|
-
)
|
|
59
|
+
exerciseRoute = if (routeList.isNotEmpty()) {
|
|
60
|
+
ExerciseRoute(
|
|
61
|
+
route = routeList,
|
|
62
|
+
)
|
|
63
|
+
} else {
|
|
64
|
+
null
|
|
65
|
+
},
|
|
60
66
|
)
|
|
61
67
|
}
|
|
62
68
|
}
|
|
@@ -89,7 +95,7 @@ class ReactExerciseSessionRecord : ReactHealthRecordImpl<ExerciseSessionRecord>
|
|
|
89
95
|
})
|
|
90
96
|
|
|
91
97
|
|
|
92
|
-
when(record.exerciseRouteResult) {
|
|
98
|
+
when (record.exerciseRouteResult) {
|
|
93
99
|
is ExerciseRouteResult.Data -> {
|
|
94
100
|
val exerciseRouteMap = WritableNativeMap()
|
|
95
101
|
exerciseRouteMap.putArray("route", WritableNativeArray().apply {
|
|
@@ -106,12 +112,15 @@ class ReactExerciseSessionRecord : ReactHealthRecordImpl<ExerciseSessionRecord>
|
|
|
106
112
|
})
|
|
107
113
|
putMap("exerciseRoute", exerciseRouteMap)
|
|
108
114
|
}
|
|
115
|
+
|
|
109
116
|
is ExerciseRouteResult.NoData -> {
|
|
110
117
|
putMap("exerciseRoute", WritableNativeMap())
|
|
111
118
|
}
|
|
119
|
+
|
|
112
120
|
is ExerciseRouteResult.ConsentRequired -> {
|
|
113
121
|
throw Exception("Consent required")
|
|
114
122
|
}
|
|
123
|
+
|
|
115
124
|
else -> {
|
|
116
125
|
putMap("exerciseRoute", WritableNativeMap())
|
|
117
126
|
}
|
|
@@ -287,8 +287,8 @@ fun getEnergyFromJsMap(energyMap: ReadableMap?): Energy {
|
|
|
287
287
|
|
|
288
288
|
val value = energyMap.getDouble("value")
|
|
289
289
|
return when (energyMap.getString("unit")) {
|
|
290
|
-
"kilojoules" -> Energy.
|
|
291
|
-
"kilocalories" -> Energy.
|
|
290
|
+
"kilojoules" -> Energy.kilojoules(value)
|
|
291
|
+
"kilocalories" -> Energy.kilocalories(value)
|
|
292
292
|
"joules" -> Energy.joules(value)
|
|
293
293
|
"calories" -> Energy.calories(value)
|
|
294
294
|
else -> Energy.calories(value)
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-health-connect",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "React native library for health connect (Android only)",
|
|
5
|
+
"funding": "https://github.com/matinzd/react-native-health-connect?sponsor=1",
|
|
5
6
|
"main": "lib/commonjs/index",
|
|
6
7
|
"module": "lib/module/index",
|
|
7
8
|
"types": "lib/typescript/index.d.ts",
|