Skip to content

Commit

Permalink
Merge pull request #36 from morricedev/fix/step-counter-module-backwa…
Browse files Browse the repository at this point in the history
…rd-compatibility

fix : step counter module backward compatibility
  • Loading branch information
AndrewDongminYoo authored Oct 14, 2023
2 parents 73b9694 + e6cf49d commit 1030b12
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 277 deletions.
5 changes: 5 additions & 0 deletions android/src/main/java/com/stepcounter/StepCounterModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class StepCounterModule internal constructor(context: ReactApplicationContext) :
* @see VERSION_CODES.KITKAT
* @see WritableMap
*/
@ReactMethod
override fun isStepCountingSupported(promise: Promise) {
Log.d(TAG_NAME, "hardware_step_counter? $supported")
Log.d(TAG_NAME, "step_counter granted? $stepsOK")
Expand All @@ -98,6 +99,7 @@ class StepCounterModule internal constructor(context: ReactApplicationContext) :
* Start the step counter sensor.
* @param from the number of steps to start from
*/
@ReactMethod
override fun startStepCounterUpdate(from: Double) {
stepCounterListener = stepCounterListener ?: if (stepsOK) {
StepCounterService(this, sensorManager)
Expand All @@ -112,6 +114,7 @@ class StepCounterModule internal constructor(context: ReactApplicationContext) :
* Stop the step counter sensor.
* @return Nothing.
*/
@ReactMethod
override fun stopStepCounterUpdate() {
Log.d(TAG_NAME, "stopStepCounterUpdate")
stepCounterListener!!.stopService()
Expand All @@ -121,13 +124,15 @@ class StepCounterModule internal constructor(context: ReactApplicationContext) :
* Keep: Required for RN built in Event Emitter Support.
* @param eventName the name of the event. usually "stepCounterUpdate".
*/
@ReactMethod
override fun addListener(eventName: String) {}

/**
* Keep: Required for RN built in Event Emitter Support.
* @param count the number of listeners to remove.
* not implemented.
*/
@ReactMethod
override fun removeListeners(count: Double) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@react-native-community/eslint-config": "^3.2.0",
"@react-native-community/eslint-plugin": "^1.3.0",
"@react-native/metro-config": "^0.72.0",
"@release-it/conventional-changelog": "^7.0.0",
"@release-it/conventional-changelog": "^7.0.2",
"@rnx-kit/align-deps": "^2.2.4",
"@types/jest": "^29.5.3",
"@types/react": "18.2.20",
Expand Down
Loading

0 comments on commit 1030b12

Please sign in to comment.