@blife/rn-step-counter 1.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.
- package/LICENSE +21 -0
- package/README.kr.md +159 -0
- package/README.md +158 -0
- package/StepCounter.podspec +22 -0
- package/android/README.md +65 -0
- package/android/build.gradle +66 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +15 -0
- package/android/src/main/java/com/stepcounter/StepCounterModule.kt +190 -0
- package/android/src/main/java/com/stepcounter/StepCounterPackage.kt +53 -0
- package/android/src/main/java/com/stepcounter/services/AccelerometerService.kt +147 -0
- package/android/src/main/java/com/stepcounter/services/SensorListenService.kt +305 -0
- package/android/src/main/java/com/stepcounter/services/StepCounterService.kt +79 -0
- package/android/src/main/java/com/stepcounter/utils/AndroidVersionHelper.kt +33 -0
- package/android/src/main/java/com/stepcounter/utils/SensorFusionMath.kt +104 -0
- package/ios/SOMotionDetecter.h +44 -0
- package/ios/SOMotionDetecter.m +91 -0
- package/ios/StepCounter.h +7 -0
- package/ios/StepCounter.mm +264 -0
- package/lib/module/NativeStepCounter.js +21 -0
- package/lib/module/NativeStepCounter.js.map +1 -0
- package/lib/module/index.js +194 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/jest.setup.d.ts +2 -0
- package/lib/typescript/jest.setup.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeStepCounter.d.ts +60 -0
- package/lib/typescript/src/NativeStepCounter.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +80 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +138 -0
- package/src/NativeStepCounter.ts +62 -0
- package/src/index.tsx +263 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bonnmh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.kr.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# React-Native Step Counter Library
|
|
2
|
+
|
|
3
|
+
English-speaking developers, please return to the repository main page or click [the following link](README.md)
|
|
4
|
+
|
|
5
|
+
사용자가 일정 시간 걸은 걸음 수를 계산하기 위한 리액트 네이티브 모듈입니다. 이 패키지는 Android의 `StepCounter` 센서, Android 기기에서 하드웨어 스텝 카운터를 사용할 수 없을 때의 가속도계 기반 폴백, iOS의 `Core Motion` 프레임워크를 사용합니다.
|
|
6
|
+
|
|
7
|
+
## 설치 방법
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm install @bonnmh/rn-step-counter
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
yarn add @bonnmh/rn-step-counter
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
리액트네이티브 0.60 버전 이후 설치된 네이티브 모듈은 오토 링크됩니다. 네이티브 모듈을 수동으로 연결할 필요가 없습니다.
|
|
18
|
+
|
|
19
|
+
## 요구 사항
|
|
20
|
+
|
|
21
|
+
- React Native `>=0.71.0`
|
|
22
|
+
- React Native CLI 앱. 네이티브 코드가 포함되어 있으므로 Expo Go는 지원하지 않습니다.
|
|
23
|
+
|
|
24
|
+
### ANDROID
|
|
25
|
+
|
|
26
|
+
앱에 아래 권한과 센서 feature 선언이 없다면 추가하세요.
|
|
27
|
+
|
|
28
|
+
```xml
|
|
29
|
+
<!-- android/src/main/AndroidManifest.xml-->
|
|
30
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
31
|
+
package="com.stepcounter">
|
|
32
|
+
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
|
|
33
|
+
<uses-permission android:name="android.permission.BODY_SENSORS_BACKGROUND" />
|
|
34
|
+
|
|
35
|
+
<uses-feature
|
|
36
|
+
android:name="android.hardware.sensor.stepcounter"
|
|
37
|
+
android:required="false" />
|
|
38
|
+
<uses-feature
|
|
39
|
+
android:name="android.hardware.sensor.accelerometer"
|
|
40
|
+
android:required="true" />
|
|
41
|
+
</manifest>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### iOS
|
|
45
|
+
|
|
46
|
+
앱의 `Info.plist`에 `NSMotionUsageDescription`을 추가하세요.
|
|
47
|
+
|
|
48
|
+
```xml plist
|
|
49
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN">
|
|
50
|
+
<plist version="1.0">
|
|
51
|
+
...
|
|
52
|
+
<key>NSMotionUsageDescription</key>
|
|
53
|
+
<string>We want to access your motion data to count your steps.</string>
|
|
54
|
+
...
|
|
55
|
+
</plist>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Interface
|
|
59
|
+
|
|
60
|
+
- `isStepCountingSupported()`: `Promise<{ supported: boolean; granted: boolean }>`: 장치에 기능 관련 스텝 카운터 또는 가속도계가 있는지 확인하는 메서드입니다.
|
|
61
|
+
- 응답 객체의 키 `granted`의 Boolean 값은 앱 사용자가 이 기능 사용 권한을 부여했는지 권한 허용 여부이며, `supported`는 장치가 이 기능을 지원하는지 여부입니다.
|
|
62
|
+
- Android에서는 하드웨어 스텝 카운터를 사용할 수 없을 때 가속도계 기반 카운팅으로 폴백할 수 있습니다. 그래도 업데이트를 시작하기 전에 플랫폼의 동작/활동 권한을 요청하고 사용자의 권한 선택을 존중해야 합니다.
|
|
63
|
+
|
|
64
|
+
- `startStepCounterUpdate(start: Date, callBack: StepCountUpdateCallback)`: EmitterSubscription:
|
|
65
|
+
- 만보계 센서가 장치에서 지원되고 사용 가능한 상태인 경우 센서 매니저의 수신기 이벤트 리스너를 등록하고 스텝 카운트 이벤트 수신기를 자바스크립트에 전달합니다.
|
|
66
|
+
- 만보계 센서가 장치에서 지원되지 않거나 사용할 수 없는 경우, 가속도계 센서를 리스너에 등록하고, 걸음을 감지하는 벡터 알고리즘 필터를 통해 걸음 이벤트를 생성한 후 앱으로 전달합니다.
|
|
67
|
+
- `start`는 `Date` 객체로, 이벤트를 수신하기 시작할 날짜를 나타냅니다. (new Date())
|
|
68
|
+
|
|
69
|
+
- `stopStepCounterUpdate()`: void:
|
|
70
|
+
- `startStepCounterUpdate`로 등록된 구독을 제거하고 네이티브 센서 세션을 중지합니다.
|
|
71
|
+
|
|
72
|
+
- `createStepCountFilter(options?: StepCountFilterOptions)`: `(data: StepCountData) => StepCountData | null`:
|
|
73
|
+
- 손으로 휴대폰을 축을 중심으로 돌리는 것처럼 센서 오탐이 발생할 수 있는 라이브 업데이트를 걸러내기 위한 상태 기반 필터를 생성합니다.
|
|
74
|
+
- `minimumStepIntervalMs`보다 빠른 보행 간격을 의미하는 버스트 업데이트를 버리고, 이후 누적 값에서 무시한 걸음 수를 보정합니다.
|
|
75
|
+
- 하드웨어/OS 만보계가 이미 오탐을 걸음으로 판단한 경우 패키지는 원시 움직임 정보를 받을 수 없습니다. 앱에서 원시 센서 스트림보다 엄격한 라이브 세션 카운트가 필요할 때 이 헬퍼를 사용하세요.
|
|
76
|
+
|
|
77
|
+
- `StepCountData`:
|
|
78
|
+
- **공통 데이터**
|
|
79
|
+
- `steps`: 지정된 기간 동안 사용자가 걸은 걸음 수를 나타내는 숫자 속성입니다.
|
|
80
|
+
- `startDate`: 이것은 밀리세컨드로 측정 된 UNIX 타임 스탬프 형식의 데이터의 시작 날짜를 나타내는 숫자 속성입니다.
|
|
81
|
+
- `endDate`: 이것은 밀리세컨드로 측정 된 UNIX 타임 스탬프 형식의 데이터의 종료 날짜를 나타내는 숫자 속성입니다.
|
|
82
|
+
- `distance`: 이것은 지정된 기간 동안 사용자가 걸거나 뛴 거리를 미터로 나타내는 숫자 속성입니다. (안드로이드는 지원하지 않기 때문에 임의 설정한 상수와 걸음 수를 이용해 계산됩니다.)
|
|
83
|
+
- `counterType`: (`CounterType`) 걸음을 감지하는 데 사용되는 센서 유형을 나타내는 유니온 타입입니다. iOS에서는 `"CMPedometer"`, 안드로이드에서는 하드웨어 만보계 센서 사용 시 `"STEP_COUNTER"`, 가속도계 폴백 사용 시 `"ACCELEROMETER"` 중 하나의 값을 가집니다.
|
|
84
|
+
|
|
85
|
+
- **iOS에만 있음**
|
|
86
|
+
- `floorsAscended`: 지정된 기간 동안 사용자가 상승한 층의 수를 나타내는 숫자 속성입니다. 기기가 이 기능을 지원하지 않으면 `nil`이 될 수 있습니다.
|
|
87
|
+
- `floorsDescended`: 지정된 기간 동안 사용자가 하강한 층의 수를 나타내는 숫자 속성입니다. 기기가 이 기능을 지원하지 않으면 `nil`이 될 수 있습니다.
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
리액트 네이티브 앱에서 이 라이브러리를 실제로 사용하려면 다음 단계를 따르세요.:
|
|
92
|
+
|
|
93
|
+
라이브러리를 리액트 네이티브 앱으로 임포트합니다.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import React, { useEffect, useState } from "react";
|
|
97
|
+
import {
|
|
98
|
+
createStepCountFilter,
|
|
99
|
+
isStepCountingSupported,
|
|
100
|
+
parseStepData,
|
|
101
|
+
startStepCounterUpdate,
|
|
102
|
+
stopStepCounterUpdate,
|
|
103
|
+
} from "@bonnmh/rn-step-counter";
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`isStepCountingSupported` 메소드를 사용하여 장치에 스텝 카운터 또는 가속도계 센서가 있는지 확인합니다.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const [supported, setSupported] = useState(false);
|
|
110
|
+
const [granted, setGranted] = useState(false);
|
|
111
|
+
|
|
112
|
+
async function askPermission() {
|
|
113
|
+
isStepCountingSupported().then((result) => {
|
|
114
|
+
console.debug("🚀 - isStepCountingSupported", result);
|
|
115
|
+
setGranted(result.granted === true);
|
|
116
|
+
setSupported(result.supported === true);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
스텝 카운터를 시작하려면 `startStepCounterUpdate` 메소드를 호출합니다.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const [steps, setSteps] = useState(0);
|
|
125
|
+
|
|
126
|
+
async function startStepCounter() {
|
|
127
|
+
const filterStepCountData = createStepCountFilter();
|
|
128
|
+
|
|
129
|
+
startStepCounterUpdate(new Date(), (data) => {
|
|
130
|
+
const filteredData = filterStepCountData(data);
|
|
131
|
+
if (!filteredData) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.debug(parseStepData(filteredData));
|
|
136
|
+
setSteps(filteredData.steps);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
다음은 `NativeStepCounter`를 사용하는 리액트 네이티브 애플리케이션의 예시입니다.
|
|
142
|
+
|
|
143
|
+
예제 앱 코드 보기: [링크](https://github.com/bonnmh/rn-step-counter/blob/main/example/src/App.tsx)
|
|
144
|
+
|
|
145
|
+
## Change Log
|
|
146
|
+
|
|
147
|
+
패키지의 버전별 변경 사항을 확인하려면 [`Release Notes`](CHANGELOG.md)를 참조하십시오.
|
|
148
|
+
|
|
149
|
+
## Contributing
|
|
150
|
+
|
|
151
|
+
리포지토리 및 개발 워크 플로에 기여하는 방법을 알고 싶으시다면 [`Contributing Guide`](CONTRIBUTING.md)를 참조하십시오.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
[CallStack](https://callstack.com/)의 [create-react-native-library](https://github.com/callstack/react-native-builder-bob/tree/main/packages/create-react-native-library)를 사용해 개발했습니다.
|
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# React-Native Step Counter Library
|
|
2
|
+
|
|
3
|
+
한국어 사용자는 [Korean version.](README.kr.md)를 참조하십시오.
|
|
4
|
+
|
|
5
|
+
This library provides an interface for tracking the number of steps taken by the user in a React Native app. It uses the Android `StepCounter` sensor, an accelerometer fallback on Android devices without a step counter sensor, and Apple's `Core Motion` framework on iOS.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm install @bonnmh/rn-step-counter
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
bun add @bonnmh/rn-step-counter
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Native modules will automatically connect after React Native 0.60 version. So you don't need to link the native modules manually.
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- React Native `>=0.71.0`
|
|
22
|
+
- React Native CLI apps. Expo Go is not supported because this package includes native code.
|
|
23
|
+
|
|
24
|
+
### ANDROID
|
|
25
|
+
|
|
26
|
+
Add the motion permission and sensor feature declarations if your app does not already include them.
|
|
27
|
+
|
|
28
|
+
```xml
|
|
29
|
+
<!-- android/src/main/AndroidManifest.xml-->
|
|
30
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
31
|
+
package="com.stepcounter">
|
|
32
|
+
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
|
|
33
|
+
<uses-permission android:name="android.permission.BODY_SENSORS_BACKGROUND" />
|
|
34
|
+
|
|
35
|
+
<uses-feature
|
|
36
|
+
android:name="android.hardware.sensor.stepcounter"
|
|
37
|
+
android:required="false" />
|
|
38
|
+
<uses-feature
|
|
39
|
+
android:name="android.hardware.sensor.accelerometer"
|
|
40
|
+
android:required="true" />
|
|
41
|
+
</manifest>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### iOS
|
|
45
|
+
|
|
46
|
+
Add `NSMotionUsageDescription` to your app's `Info.plist`.
|
|
47
|
+
|
|
48
|
+
```xml plist
|
|
49
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN">
|
|
50
|
+
<plist version="1.0">
|
|
51
|
+
...
|
|
52
|
+
<key>NSMotionUsageDescription</key>
|
|
53
|
+
<string>We want to access your motion data to count your steps.</string>
|
|
54
|
+
...
|
|
55
|
+
</plist>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Interface
|
|
59
|
+
|
|
60
|
+
- `isStepCountingSupported()`: `Promise<{ supported: boolean; granted: boolean }>`: method to check if the device has a feature related step counter or accelerometer.
|
|
61
|
+
- One key for the response object is `granted`, whether the app user has granted this feature permission, and `supported` is whether the device supports this feature.
|
|
62
|
+
- Android can fall back to accelerometer-based counting when the hardware step counter is unavailable. You should still request and respect the platform motion/activity permission before starting updates.
|
|
63
|
+
|
|
64
|
+
- `startStepCounterUpdate(start: Date, callBack: StepCountUpdateCallback)`: `EventSubscription`:
|
|
65
|
+
- If the pedometer sensor is available and supported on the device, register it with the listener in the sensor manager, and return the step count event listener.
|
|
66
|
+
- If the pedometer sensor is not supported by the device or is not available, register the accelerometer sensor with the listener, generate an accel event through a vector algorithm filter and receive it to the app.
|
|
67
|
+
|
|
68
|
+
- `stopStepCounterUpdate(): void`:
|
|
69
|
+
- Removes the subscription registered by `startStepCounterUpdate` and stops the native sensor session.
|
|
70
|
+
|
|
71
|
+
- `createStepCountFilter(options?: StepCountFilterOptions)`: `(data: StepCountData) => StepCountData | null`:
|
|
72
|
+
- Creates a stateful live-update filter for sensor false positives such as hand rotation.
|
|
73
|
+
- The filter drops bursts that imply a cadence faster than `minimumStepIntervalMs` and rebases later cumulative values so ignored steps do not come back on the next accepted event.
|
|
74
|
+
- Native hardware/OS pedometers can still report false positives before the package receives the event. Use this helper when your app needs stricter live-session counts than the raw sensor stream.
|
|
75
|
+
|
|
76
|
+
- `StepCountData`:
|
|
77
|
+
- **Common Interface**
|
|
78
|
+
- `steps`: This is a number property that indicates the number of steps taken by the user during the specified time period.
|
|
79
|
+
- `startDate`: This is a number property that indicates the start date of the data in Unix timestamp format, measured in milliseconds.
|
|
80
|
+
- `endDate`: This is a number property that indicates the end date of the data in Unix timestamp format, measured in milliseconds.
|
|
81
|
+
- `distance`: This is a number property that indicates the distance in meters that the user has walked or run during the specified time period.
|
|
82
|
+
- `counterType`: (`CounterType`) The name of the sensor used to count the number of steps. One of `"CMPedometer"` (iOS), `"STEP_COUNTER"` (Android hardware sensor), or `"ACCELEROMETER"` (Android fallback).
|
|
83
|
+
|
|
84
|
+
- **iOS Only**
|
|
85
|
+
- `floorsAscended`: This is a number property that indicates the number of floors the user has ascended during the specified time period. It can be nil if the device does not support this feature.
|
|
86
|
+
- `floorsDescended`: This is a number property that indicates the number of floors the user has descended during the specified time period. It can be nil if the device does not support this feature.
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
To use the Step Counter Library in your React Native app, follow these steps:
|
|
91
|
+
|
|
92
|
+
Import the library into your React Native app.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import React, { useEffect, useState } from "react";
|
|
96
|
+
import {
|
|
97
|
+
createStepCountFilter,
|
|
98
|
+
isStepCountingSupported,
|
|
99
|
+
parseStepData,
|
|
100
|
+
startStepCounterUpdate,
|
|
101
|
+
stopStepCounterUpdate,
|
|
102
|
+
} from "@bonnmh/rn-step-counter";
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Use the `isStepCountingSupported` method to check if the device has a step counter or accelerometer sensor.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const [supported, setSupported] = useState(false);
|
|
109
|
+
const [granted, setGranted] = useState(false);
|
|
110
|
+
|
|
111
|
+
async function askPermission() {
|
|
112
|
+
isStepCountingSupported().then((result) => {
|
|
113
|
+
console.debug("🚀 - isStepCountingSupported", result);
|
|
114
|
+
setGranted(result.granted === true);
|
|
115
|
+
setSupported(result.supported === true);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Call the `startStepCounterUpdate` method to start the step counter service.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const [steps, setSteps] = useState(0);
|
|
124
|
+
|
|
125
|
+
async function startStepCounter() {
|
|
126
|
+
const filterStepCountData = createStepCountFilter();
|
|
127
|
+
|
|
128
|
+
startStepCounterUpdate(new Date(), (data) => {
|
|
129
|
+
const filteredData = filterStepCountData(data);
|
|
130
|
+
if (!filteredData) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
console.debug(parseStepData(filteredData));
|
|
135
|
+
setSteps(filteredData.steps);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Here's an example of a complete React component that uses the `NativeStepCounter`.
|
|
141
|
+
|
|
142
|
+
Link to Example Application: [here](https://github.com/bonnmh/rn-step-counter/blob/main/example/src/App.tsx)
|
|
143
|
+
|
|
144
|
+
## Change Log
|
|
145
|
+
|
|
146
|
+
See the [`Release Notes`](CHANGELOG.md) for a list of changes.
|
|
147
|
+
|
|
148
|
+
## Contributing
|
|
149
|
+
|
|
150
|
+
See the [`Contributing Guide`](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "StepCounter"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
repo_url = package.dig("repository", "url") || package["repository"]
|
|
15
|
+
repo_url = repo_url.sub(/^git\+/, "").sub(/\.git$/, "")
|
|
16
|
+
s.source = { :git => repo_url, :tag => "#{s.version}" }
|
|
17
|
+
|
|
18
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
19
|
+
s.private_header_files = "ios/**/*.h"
|
|
20
|
+
|
|
21
|
+
install_modules_dependencies(s)
|
|
22
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 안드로이드 기본센서 & 복합센서
|
|
2
|
+
|
|
3
|
+
- [안드로이드 동작 센서](https://developer.android.com/guide/topics/sensors/sensors_motion?hl=ko)
|
|
4
|
+
- [안드로이드 센서 유형](https://source.android.com/docs/core/interaction/sensors/sensor-types?hl=ko)
|
|
5
|
+
|
|
6
|
+
## TYPE_ACCELEROMETER
|
|
7
|
+
|
|
8
|
+
SensorEvent.values[0] x축의 가속력\(중력 포함). m/s2
|
|
9
|
+
SensorEvent.values[1] y축의 가속력\(중력 포함). m/s2
|
|
10
|
+
SensorEvent.values[2] z축의 가속력\(중력 포함). m/s2
|
|
11
|
+
|
|
12
|
+
## TYPE_ACCELEROMETER_UNCALIBRATED
|
|
13
|
+
|
|
14
|
+
SensorEvent.values[0] 편향 보상 없이 X축을 따라 측정한 가속. m/s2
|
|
15
|
+
SensorEvent.values[1] 편향 보상 없이 Y축을 따라 측정한 가속. m/s2
|
|
16
|
+
SensorEvent.values[2] 편향 보상 없이 Z축을 따라 측정한 가속. m/s2
|
|
17
|
+
SensorEvent.values[3] 추정된 편향 보상을 적용하여 X축을 따라 측정한 가속. m/s2
|
|
18
|
+
SensorEvent.values[4] 추정된 편향 보상을 적용하여 Y축을 따라 측정한 가속. m/s2
|
|
19
|
+
SensorEvent.values[5] 추정된 편향 보상을 적용하여 Z축을 따라 측정한 가속. m/s2
|
|
20
|
+
|
|
21
|
+
## TYPE_GRAVITY
|
|
22
|
+
|
|
23
|
+
SensorEvent.values[0] x축의 중력. m/s2
|
|
24
|
+
SensorEvent.values[1] y축의 중력. m/s2
|
|
25
|
+
SensorEvent.values[2] z축의 중력. m/s2
|
|
26
|
+
|
|
27
|
+
## TYPE_GYROSCOPE
|
|
28
|
+
|
|
29
|
+
SensorEvent.values[0] x축을 중심으로 한 회전 속도. rad/s
|
|
30
|
+
SensorEvent.values[1] y축을 중심으로 한 회전 속도. rad/s
|
|
31
|
+
SensorEvent.values[2] z축을 중심으로 한 회전 속도. rad/s
|
|
32
|
+
|
|
33
|
+
## TYPE_GYROSCOPE_UNCALIBRATED
|
|
34
|
+
|
|
35
|
+
SensorEvent.values[0] x축을 중심으로 한 회전 속도\(드리프트 보상 없음). rad/s
|
|
36
|
+
SensorEvent.values[1] y축을 중심으로 한 회전 속도\(드리프트 보상 없음). rad/s
|
|
37
|
+
SensorEvent.values[2] z축을 중심으로 한 회전 속도\(드리프트 보상 없음). rad/s
|
|
38
|
+
SensorEvent.values[3] x축을 중심으로 추정한 드리프트. rad/s
|
|
39
|
+
SensorEvent.values[4] y축을 중심으로 추정한 드리프트. rad/s
|
|
40
|
+
SensorEvent.values[5] z축을 중심으로 추정한 드리프트. rad/s
|
|
41
|
+
|
|
42
|
+
## TYPE_LINEAR_ACCELERATION
|
|
43
|
+
|
|
44
|
+
SensorEvent.values[0] x축의 가속력\(중력 제외). m/s2
|
|
45
|
+
SensorEvent.values[1] y축의 가속력\(중력 제외). m/s2
|
|
46
|
+
SensorEvent.values[2] z축의 가속력\(중력 제외). m/s2
|
|
47
|
+
|
|
48
|
+
## TYPE_ROTATION_VECTOR
|
|
49
|
+
|
|
50
|
+
SensorEvent.values[0] x축의 회전 벡터 구성요소\(x \* sin\(θ/2)). 단위 없음
|
|
51
|
+
SensorEvent.values[1] y축의 회전 벡터 구성요소\(y \* sin\(θ/2)). 단위 없음
|
|
52
|
+
SensorEvent.values[2] z축의 회전 벡터 구성요소\(z \* sin\(θ/2)). 단위 없음
|
|
53
|
+
SensorEvent.values[3] 회전 벡터의 스칼라 구성요소\(\(cos\(θ/2)). 옵셔널.단위 없음
|
|
54
|
+
|
|
55
|
+
## TYPE_STEP_COUNTER
|
|
56
|
+
|
|
57
|
+
SensorEvent.values[0] 센서가 활성화되어 있는 동안 마지막 재부팅 이후로 사용자가 걸은 걸음 수. 단위 보
|
|
58
|
+
|
|
59
|
+
### TYPE_SIGNIFICANT_MOTION
|
|
60
|
+
|
|
61
|
+
\(중요하거나 위험할 수 있는 활동 감지) 해당 없음
|
|
62
|
+
|
|
63
|
+
### TYPE_STEP_DETECTOR
|
|
64
|
+
|
|
65
|
+
해당 없음
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.StepCounter = [
|
|
3
|
+
kotlinVersion : "2.0.21",
|
|
4
|
+
minSdkVersion : 24,
|
|
5
|
+
compileSdkVersion: 36,
|
|
6
|
+
targetSdkVersion : 36
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
ext.getExtOrDefault = { prop ->
|
|
10
|
+
if (rootProject.ext.has(prop)) {
|
|
11
|
+
return rootProject.ext.get(prop)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return StepCounter[prop]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
repositories {
|
|
18
|
+
google()
|
|
19
|
+
mavenCentral()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
dependencies {
|
|
23
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
24
|
+
// noinspection DifferentKotlinGradleVersion
|
|
25
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
apply plugin: "com.android.library"
|
|
31
|
+
apply plugin: "kotlin-android"
|
|
32
|
+
|
|
33
|
+
apply plugin: "com.facebook.react"
|
|
34
|
+
|
|
35
|
+
android {
|
|
36
|
+
namespace "com.stepcounter"
|
|
37
|
+
compileSdkVersion getExtOrDefault("compileSdkVersion")
|
|
38
|
+
|
|
39
|
+
defaultConfig {
|
|
40
|
+
minSdkVersion getExtOrDefault("minSdkVersion")
|
|
41
|
+
targetSdkVersion getExtOrDefault("targetSdkVersion")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
buildFeatures {
|
|
45
|
+
buildConfig true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
buildTypes {
|
|
49
|
+
release {
|
|
50
|
+
minifyEnabled false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
lint {
|
|
55
|
+
disable "GradleCompatible"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
compileOptions {
|
|
59
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
60
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
dependencies {
|
|
65
|
+
implementation "com.facebook.react:react-android"
|
|
66
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
package="com.stepcounter">
|
|
4
|
+
|
|
5
|
+
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
|
|
6
|
+
<uses-permission android:name="android.permission.BODY_SENSORS_BACKGROUND" />
|
|
7
|
+
|
|
8
|
+
<uses-feature
|
|
9
|
+
android:name="android.hardware.sensor.stepcounter"
|
|
10
|
+
android:required="false" />
|
|
11
|
+
<uses-feature
|
|
12
|
+
android:name="android.hardware.sensor.accelerometer"
|
|
13
|
+
android:required="true" />
|
|
14
|
+
|
|
15
|
+
</manifest>
|