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

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.
@@ -1,6 +1,9 @@
1
1
  package com.keepawake
2
2
 
3
+ import android.app.Activity
4
+ import android.view.WindowManager
3
5
  import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.bridge.ReactMethod
4
7
  import com.facebook.react.module.annotations.ReactModule
5
8
 
6
9
  @ReactModule(name = KeepAwakeModule.NAME)
@@ -12,29 +15,23 @@ class KeepAwakeModule(reactContext: ReactApplicationContext) :
12
15
  }
13
16
 
14
17
  @ReactMethod
15
- public void activate() {
16
- final Activity activity = getCurrentActivity();
17
- if (activity != null) {
18
- activity.runOnUiThread(new Runnable() {
19
- @Override
20
- public void run() {
21
- activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
22
- }
23
- });
18
+ override fun activate() {
19
+ val activity = currentActivity
20
+ if (activity != null) {
21
+ activity.runOnUiThread {
22
+ activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
24
23
  }
24
+ }
25
25
  }
26
26
 
27
27
  @ReactMethod
28
- public void deactivate() {
29
- final Activity activity = getCurrentActivity();
30
- if (activity != null) {
31
- activity.runOnUiThread(new Runnable() {
32
- @Override
33
- public void run() {
34
- activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
35
- }
36
- });
28
+ override fun deactivate() {
29
+ val activity = currentActivity
30
+ if (activity != null) {
31
+ activity.runOnUiThread {
32
+ activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
37
33
  }
34
+ }
38
35
  }
39
36
 
40
37
  companion object {
@@ -1,17 +1,29 @@
1
1
  package com.keepawake
2
2
 
3
- import com.facebook.react.ReactPackage
3
+ import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ViewManager
7
- import java.util.Collections
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import java.util.HashMap
8
9
 
9
- class KeepAwakePackage : ReactPackage {
10
+ class KeepAwakePackage : BaseReactPackage() {
10
11
  override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
12
  return listOf(KeepAwakeModule(reactContext))
12
13
  }
13
14
 
14
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
- return emptyList()
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
+ }
16
28
  }
17
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kobe-brants/react-native-keep-awake",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Keep device screen awake for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",