@kobe-brants/react-native-keep-awake 1.0.10 → 1.0.12

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.
@@ -3,20 +3,21 @@ package com.keepawake
3
3
  import android.app.Activity
4
4
  import android.view.WindowManager
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
7
  import com.facebook.react.bridge.ReactMethod
7
8
  import com.facebook.react.module.annotations.ReactModule
8
9
 
9
10
  @ReactModule(name = KeepAwakeModule.NAME)
10
- class KeepAwakeModule(reactContext: ReactApplicationContext) :
11
- NativeKeepAwakeSpec(reactContext) {
11
+ class KeepAwakeModule(private val reactContext: ReactApplicationContext) :
12
+ ReactContextBaseJavaModule(reactContext) {
12
13
 
13
14
  override fun getName(): String {
14
15
  return NAME
15
16
  }
16
17
 
17
18
  @ReactMethod
18
- override fun activate() {
19
- val activity = currentActivity
19
+ fun activate() {
20
+ val activity = reactContext.currentActivity
20
21
  if (activity != null) {
21
22
  activity.runOnUiThread {
22
23
  activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@@ -25,8 +26,8 @@ class KeepAwakeModule(reactContext: ReactApplicationContext) :
25
26
  }
26
27
 
27
28
  @ReactMethod
28
- override fun deactivate() {
29
- val activity = currentActivity
29
+ fun deactivate() {
30
+ val activity = reactContext.currentActivity
30
31
  if (activity != null) {
31
32
  activity.runOnUiThread {
32
33
  activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@@ -1,29 +1,16 @@
1
1
  package com.keepawake
2
2
 
3
- import com.facebook.react.BaseReactPackage
3
+ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.module.model.ReactModuleInfo
7
- import com.facebook.react.module.model.ReactModuleInfoProvider
8
- import java.util.HashMap
6
+ import com.facebook.react.uimanager.ViewManager
9
7
 
10
- class KeepAwakePackage : BaseReactPackage() {
8
+ class KeepAwakePackage : ReactPackage {
11
9
  override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
12
10
  return listOf(KeepAwakeModule(reactContext))
13
11
  }
14
12
 
15
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
16
- return ReactModuleInfoProvider {
17
- val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
18
- moduleInfos[KeepAwakeModule.NAME] = ReactModuleInfo(
19
- KeepAwakeModule.NAME,
20
- KeepAwakeModule.NAME,
21
- false, // canOverrideExistingModule
22
- false, // needsEagerInit
23
- false, // isCxxModule
24
- true // isTurboModule
25
- )
26
- moduleInfos
27
- }
13
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
14
+ return emptyList()
28
15
  }
29
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kobe-brants/react-native-keep-awake",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Keep device screen awake for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",