@kobe-brants/react-native-keep-awake 1.0.9 → 1.0.11
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,40 +1,38 @@
|
|
|
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
|
|
7
|
+
import com.facebook.react.bridge.NativeModule
|
|
4
8
|
import com.facebook.react.module.annotations.ReactModule
|
|
5
9
|
|
|
6
10
|
@ReactModule(name = KeepAwakeModule.NAME)
|
|
7
11
|
class KeepAwakeModule(reactContext: ReactApplicationContext) :
|
|
8
|
-
NativeKeepAwakeSpec(reactContext) {
|
|
12
|
+
NativeKeepAwakeSpec(reactContext), NativeModule {
|
|
9
13
|
|
|
10
14
|
override fun getName(): String {
|
|
11
15
|
return NAME
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
@ReactMethod
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
public void run() {
|
|
21
|
-
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
19
|
+
override fun activate() {
|
|
20
|
+
val activity = currentActivity
|
|
21
|
+
if (activity != null) {
|
|
22
|
+
activity.runOnUiThread {
|
|
23
|
+
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
24
24
|
}
|
|
25
|
+
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
@ReactMethod
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
public void run() {
|
|
34
|
-
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
29
|
+
override fun deactivate() {
|
|
30
|
+
val activity = currentActivity
|
|
31
|
+
if (activity != null) {
|
|
32
|
+
activity.runOnUiThread {
|
|
33
|
+
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
37
34
|
}
|
|
35
|
+
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
companion object {
|