react-native-health-connect 2.0.1 → 2.0.3

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/README.md CHANGED
@@ -21,7 +21,8 @@ This library is a wrapper around Health Connect for react native. Health Connect
21
21
 
22
22
  - [Health Connect](https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata&hl=en&gl=US) needs to be installed on the user's device. Starting from Android 14 (Upside Down Cake), Health Connect is part of the Android Framework. Read more [here](https://developer.android.com/health-and-fitness/guides/health-connect/develop/get-started#step-1).
23
23
  - Health Connect API requires `minSdkVersion=26` (Android Oreo / 8.0).
24
- - If you are planning to release your app on Google Play, you will need to submit a [declaration form](https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true).
24
+ - If you are planning to release your app on Google Play, you will need to submit a [declaration form](https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true). Approval can take up to 7 days.
25
+ - Approval does not grant you immediate access to Health Connect. A whitelist must propagate to the Health Connect servers, which take an additional 5-7 business days. The whitelist is updated every Monday according to Google Fit AHP support.
25
26
 
26
27
  ## Installation
27
28
 
@@ -46,6 +46,7 @@ android {
46
46
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
47
47
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
48
48
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
49
+ consumerProguardFiles "proguard-rules.pro"
49
50
  }
50
51
  buildTypes {
51
52
  release {
@@ -0,0 +1 @@
1
+ -keep class dev.matinzd.healthconnect.records.** { *; }
@@ -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 = ExerciseRoute(
49
- route = it.getMap("exerciseRoute")?.getArray("route")?.toMapList()?.map { sample ->
50
- ExerciseRoute.Location(
51
- time = Instant.parse(sample.getString("time")),
52
- latitude = sample.getDouble("latitude"),
53
- longitude = sample.getDouble("longitude"),
54
- horizontalAccuracy = getLengthFromJsMap(sample.getMap("horizontalAccuracy")),
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
  }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "react-native-health-connect",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
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",