@kobe-brants/react-native-keep-awake 1.0.8 → 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 {
@@ -8,12 +8,8 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
8
8
  import java.util.HashMap
9
9
 
10
10
  class KeepAwakePackage : BaseReactPackage() {
11
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
- return if (name == KeepAwakeModule.NAME) {
13
- KeepAwakeModule(reactContext)
14
- } else {
15
- null
16
- }
11
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
12
+ return listOf(KeepAwakeModule(reactContext))
17
13
  }
18
14
 
19
15
  override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kobe-brants/react-native-keep-awake",
3
- "version": "1.0.8",
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",