@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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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.
|
|
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.
|
|
7
|
-
import
|
|
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 :
|
|
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
|
|
15
|
-
return
|
|
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
|
}
|