react-native-step-tracker-pro 1.0.0 → 1.1.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.
- package/README.md +1 -1
- package/android/build.gradle +27 -12
- package/android/src/main/java/com/steptrackerpro/StepTrackerProModule.kt +5 -5
- package/android/src/main/java/com/steptrackerpro/health/HealthConnectManager.kt +5 -1
- package/docs/INSTALLATION.md +21 -6
- package/docs/TROUBLESHOOTING.md +3 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ cd android && ./gradlew clean
|
|
|
37
37
|
npx react-native run-android
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Requires `minSdk 26`, `compileSdk 35`, RN ≥ 0.
|
|
40
|
+
Requires `minSdk 26`, `compileSdk 35`, RN ≥ 0.77. Full steps, including the
|
|
41
41
|
Gradle overrides for Kotlin 2.x and the manifest entries your app has to add:
|
|
42
42
|
[docs/INSTALLATION.md](docs/INSTALLATION.md).
|
|
43
43
|
|
package/android/build.gradle
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
// Consumers can override
|
|
3
|
-
// ext { kotlinVersion = "2.
|
|
2
|
+
// Consumers can override in the app's root build.gradle:
|
|
3
|
+
// ext { kotlinVersion = "2.2.0"; roomVersion = "2.7.1" }
|
|
4
|
+
//
|
|
5
|
+
// Room's annotation processing runs through kapt rather than KSP on
|
|
6
|
+
// purpose. A KSP plugin version has to match the Kotlin plugin version
|
|
7
|
+
// exactly, and a library cannot know which Kotlin the host app will bring:
|
|
8
|
+
// pinning one here breaks every app on a different Kotlin, and there is no
|
|
9
|
+
// way to derive the KSP suffix from the Kotlin version. kapt ships inside
|
|
10
|
+
// the Kotlin Gradle plugin, so it matches the host automatically, and this
|
|
11
|
+
// module's processing surface is two entities and two DAOs.
|
|
12
|
+
// Only used when this module is built on its own; inside an app the host's
|
|
13
|
+
// Kotlin plugin is already on the classpath and wins. React Native sets
|
|
14
|
+
// rootProject.ext.kotlinVersion, so consumers are picked up automatically.
|
|
4
15
|
ext.stp_kotlinVersion = rootProject.ext.has("kotlinVersion")
|
|
5
|
-
? rootProject.ext.get("kotlinVersion") : "
|
|
6
|
-
ext.stp_kspVersion = rootProject.ext.has("kspVersion")
|
|
7
|
-
? rootProject.ext.get("kspVersion") : "1.9.24-1.0.20"
|
|
16
|
+
? rootProject.ext.get("kotlinVersion") : "2.0.21"
|
|
8
17
|
|
|
9
18
|
repositories {
|
|
10
19
|
google()
|
|
@@ -17,7 +26,6 @@ buildscript {
|
|
|
17
26
|
// `ext` resolves to the buildscript's own extra properties, not the
|
|
18
27
|
// project's, so the ext-qualified form fails to resolve at all.
|
|
19
28
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$stp_kotlinVersion"
|
|
20
|
-
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$stp_kspVersion"
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
|
|
@@ -27,7 +35,7 @@ def isNewArchitectureEnabled() {
|
|
|
27
35
|
|
|
28
36
|
apply plugin: "com.android.library"
|
|
29
37
|
apply plugin: "org.jetbrains.kotlin.android"
|
|
30
|
-
apply plugin: "
|
|
38
|
+
apply plugin: "org.jetbrains.kotlin.kapt"
|
|
31
39
|
if (isNewArchitectureEnabled()) {
|
|
32
40
|
apply plugin: "com.facebook.react"
|
|
33
41
|
}
|
|
@@ -36,7 +44,12 @@ def safeExtGet(prop, fallback) {
|
|
|
36
44
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
// Room 2.7+ is required to read Kotlin 2.x metadata: 2.6.1's bundled
|
|
48
|
+
// kotlinx-metadata rejects anything above Kotlin 2.0 with "Provided Metadata
|
|
49
|
+
// instance has version 2.2.0, while maximum supported version is 2.0.0". It in
|
|
50
|
+
// turn needs Kotlin 2.0+, which is what sets this package's React Native floor.
|
|
51
|
+
// On react-native 0.74-0.76 (Kotlin 1.9.24), pin roomVersion = "2.6.1".
|
|
52
|
+
def roomVersion = safeExtGet("roomVersion", "2.7.2")
|
|
40
53
|
// 1.1.0 stable requires compileSdk 36 and AGP 8.9.1+, which React Native did
|
|
41
54
|
// not ship until long after 0.76 - depending on it would silently break every
|
|
42
55
|
// consumer inside the react-native range peerDependencies claims to support.
|
|
@@ -88,9 +101,11 @@ android {
|
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
104
|
+
kapt {
|
|
105
|
+
arguments {
|
|
106
|
+
arg("room.schemaLocation", "$projectDir/schemas")
|
|
107
|
+
arg("room.incremental", "true")
|
|
108
|
+
}
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
repositories {
|
|
@@ -108,7 +123,7 @@ dependencies {
|
|
|
108
123
|
|
|
109
124
|
implementation "androidx.room:room-runtime:$roomVersion"
|
|
110
125
|
implementation "androidx.room:room-ktx:$roomVersion"
|
|
111
|
-
|
|
126
|
+
kapt "androidx.room:room-compiler:$roomVersion"
|
|
112
127
|
|
|
113
128
|
implementation "androidx.work:work-runtime-ktx:$workVersion"
|
|
114
129
|
implementation "androidx.health.connect:connect-client:$healthConnectVersion"
|
|
@@ -306,7 +306,7 @@ class StepTrackerProModule(private val reactContext: ReactApplicationContext) :
|
|
|
306
306
|
|
|
307
307
|
@ReactMethod
|
|
308
308
|
override fun requestPermissions(promise: Promise) {
|
|
309
|
-
val activity =
|
|
309
|
+
val activity = getCurrentActivity()
|
|
310
310
|
if (activity !is PermissionAwareActivity) {
|
|
311
311
|
promise.reject("E_NO_ACTIVITY", "No foreground activity to attach the dialog to")
|
|
312
312
|
return
|
|
@@ -350,7 +350,7 @@ class StepTrackerProModule(private val reactContext: ReactApplicationContext) :
|
|
|
350
350
|
@ReactMethod
|
|
351
351
|
override fun requestDisableBatteryOptimization(promise: Promise) {
|
|
352
352
|
runSafely(promise) {
|
|
353
|
-
val host =
|
|
353
|
+
val host = getCurrentActivity() ?: reactContext
|
|
354
354
|
promise.resolve(BatteryOptimizationHelper.requestExemption(host))
|
|
355
355
|
}
|
|
356
356
|
}
|
|
@@ -358,7 +358,7 @@ class StepTrackerProModule(private val reactContext: ReactApplicationContext) :
|
|
|
358
358
|
@ReactMethod
|
|
359
359
|
override fun openBatteryOptimizationSettings(promise: Promise) {
|
|
360
360
|
runSafely(promise) {
|
|
361
|
-
promise.resolve(BatteryOptimizationHelper.openSettings(
|
|
361
|
+
promise.resolve(BatteryOptimizationHelper.openSettings(getCurrentActivity() ?: reactContext))
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
|
|
@@ -366,7 +366,7 @@ class StepTrackerProModule(private val reactContext: ReactApplicationContext) :
|
|
|
366
366
|
override fun openManufacturerAutoStartSettings(promise: Promise) {
|
|
367
367
|
runSafely(promise) {
|
|
368
368
|
promise.resolve(
|
|
369
|
-
BatteryOptimizationHelper.openAutoStartSettings(
|
|
369
|
+
BatteryOptimizationHelper.openAutoStartSettings(getCurrentActivity() ?: reactContext)
|
|
370
370
|
)
|
|
371
371
|
}
|
|
372
372
|
}
|
|
@@ -388,7 +388,7 @@ class StepTrackerProModule(private val reactContext: ReactApplicationContext) :
|
|
|
388
388
|
)
|
|
389
389
|
return
|
|
390
390
|
}
|
|
391
|
-
val activity: Activity? =
|
|
391
|
+
val activity: Activity? = getCurrentActivity()
|
|
392
392
|
if (activity == null) {
|
|
393
393
|
promise.reject("E_NO_ACTIVITY", "No foreground activity to launch the request from")
|
|
394
394
|
return
|
|
@@ -7,6 +7,7 @@ import androidx.health.connect.client.PermissionController
|
|
|
7
7
|
import androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod
|
|
8
8
|
import androidx.health.connect.client.permission.HealthPermission
|
|
9
9
|
import androidx.health.connect.client.records.DistanceRecord
|
|
10
|
+
import androidx.health.connect.client.records.Record
|
|
10
11
|
import androidx.health.connect.client.records.StepsRecord
|
|
11
12
|
import androidx.health.connect.client.records.TotalCaloriesBurnedRecord
|
|
12
13
|
import androidx.health.connect.client.records.metadata.Device
|
|
@@ -136,7 +137,10 @@ class HealthConnectManager(
|
|
|
136
137
|
val version = state.nextHealthRecordVersion()
|
|
137
138
|
val device = Device(type = Device.TYPE_PHONE)
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
// Explicitly typed: the three record classes share only the
|
|
141
|
+
// library-internal IntervalRecord supertype, which Kotlin 2.x refuses
|
|
142
|
+
// to infer as a type argument.
|
|
143
|
+
val records = listOf<Record>(
|
|
140
144
|
StepsRecord(
|
|
141
145
|
count = totals.steps.toLong(),
|
|
142
146
|
startTime = start,
|
package/docs/INSTALLATION.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| | |
|
|
6
6
|
|---|---|
|
|
7
|
-
| React Native | ≥ 0.
|
|
7
|
+
| React Native | ≥ 0.77 (old and new architecture both supported) |
|
|
8
8
|
| `minSdkVersion` | 26 — `java.time` and the Health Connect client both need it |
|
|
9
9
|
| `compileSdkVersion` / `targetSdkVersion` | 35 |
|
|
10
10
|
| Java | 17 |
|
|
@@ -44,8 +44,7 @@ so, or the build fails with a KSP/Kotlin mismatch.
|
|
|
44
44
|
buildscript {
|
|
45
45
|
ext {
|
|
46
46
|
kotlinVersion = "2.0.21"
|
|
47
|
-
|
|
48
|
-
roomVersion = "2.7.1"
|
|
47
|
+
roomVersion = "2.7.2"
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
```
|
|
@@ -56,7 +55,7 @@ Other overridable properties: `healthConnectVersion` (default `1.1.0-beta01`),
|
|
|
56
55
|
`healthConnectVersion` is held at `1.1.0-beta01` on purpose: `1.1.0` stable
|
|
57
56
|
requires `compileSdk 36` and Android Gradle Plugin 8.9.1+, which React Native
|
|
58
57
|
did not ship until well after 0.76, so depending on it would fail
|
|
59
|
-
`checkDebugAarMetadata` in every app inside the `react-native >= 0.
|
|
58
|
+
`checkDebugAarMetadata` in every app inside the `react-native >= 0.77` range
|
|
60
59
|
this package claims to support. `1.1.0-beta01` is the newest release that still
|
|
61
60
|
builds against `compileSdk 35` and exposes the same `Metadata` API. If your app
|
|
62
61
|
is already on `compileSdk 36` and AGP 8.9.1+, opt up with:
|
|
@@ -68,8 +67,24 @@ ext {
|
|
|
68
67
|
```
|
|
69
68
|
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
Room's annotation processing runs through **kapt**, not KSP. A KSP plugin
|
|
71
|
+
version has to match the Kotlin plugin version exactly, and a library cannot
|
|
72
|
+
know which Kotlin its host app will bring — pinning one breaks every app on a
|
|
73
|
+
different Kotlin, and the KSP suffix cannot be derived from the Kotlin version.
|
|
74
|
+
kapt ships inside the Kotlin Gradle plugin, so it always matches. There is no
|
|
75
|
+
`kspVersion` to set.
|
|
76
|
+
|
|
77
|
+
The React Native floor is ≥ 0.77 because Room 2.7 is the first release whose
|
|
78
|
+
bundled `kotlinx-metadata` can read Kotlin 2.x metadata, and Room 2.7 itself
|
|
79
|
+
needs Kotlin 2.0+. On react-native 0.74–0.76 (Kotlin 1.9.24) the package still
|
|
80
|
+
works if you pin the older pair:
|
|
81
|
+
|
|
82
|
+
```groovy
|
|
83
|
+
ext {
|
|
84
|
+
kotlinVersion = "1.9.24"
|
|
85
|
+
roomVersion = "2.6.1"
|
|
86
|
+
}
|
|
87
|
+
```
|
|
73
88
|
|
|
74
89
|
## 4. Manifest entries your app must add
|
|
75
90
|
|
package/docs/TROUBLESHOOTING.md
CHANGED
|
@@ -45,8 +45,9 @@ history to survive reinstalls, sync to Health Connect or set `remoteSyncUrl`.
|
|
|
45
45
|
|
|
46
46
|
## Build fails: KSP version mismatch
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
React Native sets `rootProject.ext.kotlinVersion` and the library follows it, so
|
|
49
|
+
this should not happen on a stock app. If it does, set `kotlinVersion` in the
|
|
50
|
+
app's root `build.gradle` — see
|
|
50
51
|
[INSTALLATION.md](INSTALLATION.md#3-kotlin-2x-only-if-your-app-is-already-on-it).
|
|
51
52
|
|
|
52
53
|
## Build fails: `minSdkVersion 24 cannot be smaller than 26`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-step-tracker-pro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Production-grade Android step tracking for React Native: hardware step counter, foreground service, Room storage, Health Connect sync, boot recovery and goals.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"author": "Helper <sachinkumarq87@gmail.com>",
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=18.0.0",
|
|
48
|
-
"react-native": ">=0.
|
|
48
|
+
"react-native": ">=0.77.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/react": "^18.2.0",
|