@kobe-brants/react-native-keep-awake 1.0.11 → 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,21 +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
|
-
import com.facebook.react.bridge.NativeModule
|
|
8
8
|
import com.facebook.react.module.annotations.ReactModule
|
|
9
9
|
|
|
10
10
|
@ReactModule(name = KeepAwakeModule.NAME)
|
|
11
|
-
class KeepAwakeModule(reactContext: ReactApplicationContext) :
|
|
12
|
-
|
|
11
|
+
class KeepAwakeModule(private val reactContext: ReactApplicationContext) :
|
|
12
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
13
13
|
|
|
14
14
|
override fun getName(): String {
|
|
15
15
|
return NAME
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@ReactMethod
|
|
19
|
-
|
|
20
|
-
val activity = currentActivity
|
|
19
|
+
fun activate() {
|
|
20
|
+
val activity = reactContext.currentActivity
|
|
21
21
|
if (activity != null) {
|
|
22
22
|
activity.runOnUiThread {
|
|
23
23
|
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
@@ -26,8 +26,8 @@ class KeepAwakeModule(reactContext: ReactApplicationContext) :
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
@ReactMethod
|
|
29
|
-
|
|
30
|
-
val activity = currentActivity
|
|
29
|
+
fun deactivate() {
|
|
30
|
+
val activity = reactContext.currentActivity
|
|
31
31
|
if (activity != null) {
|
|
32
32
|
activity.runOnUiThread {
|
|
33
33
|
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
@@ -4,7 +4,6 @@ import com.facebook.react.ReactPackage
|
|
|
4
4
|
import com.facebook.react.bridge.NativeModule
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
import java.util.Collections
|
|
8
7
|
|
|
9
8
|
class KeepAwakePackage : ReactPackage {
|
|
10
9
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|