expo-keep-awake 12.4.0 → 12.5.0
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.
- package/CHANGELOG.md +14 -0
- package/android/build.gradle +11 -8
- package/android/src/main/java/expo/modules/keepawake/KeepAwakeExceptions.kt +12 -0
- package/android/src/main/java/expo/modules/keepawake/KeepAwakeModule.kt +27 -44
- package/android/src/main/java/expo/modules/keepawake/KeepAwakePackage.kt +0 -5
- package/expo-module.config.json +4 -1
- package/package.json +2 -2
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.5.0 — 2023-09-04
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Added support for React Native 0.73. ([#24018](https://github.com/expo/expo/pull/24018) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
21
|
+
- On Android, migrate to Expo Modules Api. ([#24012](https://github.com/expo/expo/pull/24012) by [@alanjhughes](https://github.com/alanjhughes))
|
|
22
|
+
|
|
23
|
+
## 12.4.1 — 2023-08-02
|
|
24
|
+
|
|
25
|
+
_This version does not introduce any user-facing changes._
|
|
26
|
+
|
|
13
27
|
## 12.4.0 — 2023-07-28
|
|
14
28
|
|
|
15
29
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '12.
|
|
6
|
+
version = '12.5.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -53,13 +53,16 @@ afterEvaluate {
|
|
|
53
53
|
android {
|
|
54
54
|
compileSdkVersion safeExtGet("compileSdkVersion", 33)
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
57
|
+
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
|
58
|
+
compileOptions {
|
|
59
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
60
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
61
|
+
}
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
kotlinOptions {
|
|
64
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
namespace "expo.modules.keepawake"
|
|
@@ -67,7 +70,7 @@ android {
|
|
|
67
70
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
68
71
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
69
72
|
versionCode 16
|
|
70
|
-
versionName "12.
|
|
73
|
+
versionName "12.5.0"
|
|
71
74
|
}
|
|
72
75
|
lintOptions {
|
|
73
76
|
abortOnError false
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package expo.modules.keepawake
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.exception.CodedException
|
|
4
|
+
|
|
5
|
+
internal class ActivateKeepAwakeException :
|
|
6
|
+
CodedException("Unable to activate keep awake")
|
|
7
|
+
|
|
8
|
+
internal class DeactivateKeepAwakeException :
|
|
9
|
+
CodedException("Unable to deactivate keep awake. However, it probably is deactivated already")
|
|
10
|
+
|
|
11
|
+
internal class MissingModuleException(moduleName: String) :
|
|
12
|
+
CodedException("Module '$moduleName' not found. Are you sure all modules are linked correctly?")
|
|
@@ -1,54 +1,37 @@
|
|
|
1
1
|
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
2
|
package expo.modules.keepawake
|
|
3
3
|
|
|
4
|
-
import android.content.Context
|
|
5
|
-
|
|
6
|
-
import expo.modules.core.ExportedModule
|
|
7
|
-
import expo.modules.core.ModuleRegistry
|
|
8
|
-
import expo.modules.core.interfaces.services.KeepAwakeManager
|
|
9
|
-
import expo.modules.core.ModuleRegistryDelegate
|
|
10
|
-
import expo.modules.core.Promise
|
|
11
|
-
import expo.modules.core.interfaces.ExpoMethod
|
|
12
4
|
import expo.modules.core.errors.CurrentActivityNotFoundException
|
|
5
|
+
import expo.modules.core.interfaces.services.KeepAwakeManager
|
|
6
|
+
import expo.modules.kotlin.Promise
|
|
7
|
+
import expo.modules.kotlin.modules.Module
|
|
8
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
9
|
+
|
|
10
|
+
class KeepAwakeModule : Module() {
|
|
11
|
+
private val keepAwakeManager: KeepAwakeManager
|
|
12
|
+
get() = appContext.legacyModule() ?: throw MissingModuleException("KeepAwakeManager")
|
|
13
|
+
|
|
14
|
+
override fun definition() = ModuleDefinition {
|
|
15
|
+
Name("ExpoKeepAwake")
|
|
16
|
+
|
|
17
|
+
AsyncFunction("activate") { tag: String, promise: Promise ->
|
|
18
|
+
try {
|
|
19
|
+
keepAwakeManager.activate(tag) { promise.resolve(true) }
|
|
20
|
+
} catch (ex: CurrentActivityNotFoundException) {
|
|
21
|
+
promise.reject(ActivateKeepAwakeException())
|
|
22
|
+
}
|
|
23
|
+
}
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
) : ExportedModule(context) {
|
|
21
|
-
|
|
22
|
-
private val keepAwakeManager: KeepAwakeManager by moduleRegistry()
|
|
23
|
-
|
|
24
|
-
private inline fun <reified T> moduleRegistry() = moduleRegistryDelegate.getFromModuleRegistry<T>()
|
|
25
|
-
|
|
26
|
-
override fun onCreate(moduleRegistry: ModuleRegistry) {
|
|
27
|
-
moduleRegistryDelegate.onCreate(moduleRegistry)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override fun getName(): String {
|
|
31
|
-
return NAME
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@ExpoMethod
|
|
35
|
-
fun activate(tag: String, promise: Promise) {
|
|
36
|
-
try {
|
|
37
|
-
keepAwakeManager.activate(tag) { promise.resolve(true) }
|
|
38
|
-
} catch (ex: CurrentActivityNotFoundException) {
|
|
39
|
-
promise.reject(NO_ACTIVITY_ERROR_CODE, "Unable to activate keep awake")
|
|
25
|
+
AsyncFunction("deactivate") { tag: String, promise: Promise ->
|
|
26
|
+
try {
|
|
27
|
+
keepAwakeManager.deactivate(tag) { promise.resolve(true) }
|
|
28
|
+
} catch (ex: CurrentActivityNotFoundException) {
|
|
29
|
+
promise.reject(DeactivateKeepAwakeException())
|
|
30
|
+
}
|
|
40
31
|
}
|
|
41
|
-
}
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
keepAwakeManager.deactivate(tag) { promise.resolve(true) }
|
|
47
|
-
} catch (ex: CurrentActivityNotFoundException) {
|
|
48
|
-
promise.reject(NO_ACTIVITY_ERROR_CODE, "Unable to deactivate keep awake. However, it probably is deactivated already.")
|
|
33
|
+
AsyncFunction("isActivated") {
|
|
34
|
+
return@AsyncFunction keepAwakeManager.isActivated
|
|
49
35
|
}
|
|
50
36
|
}
|
|
51
|
-
|
|
52
|
-
val isActivated: Boolean
|
|
53
|
-
get() = keepAwakeManager.isActivated
|
|
54
37
|
}
|
|
@@ -2,15 +2,10 @@ package expo.modules.keepawake
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
|
|
5
|
-
import expo.modules.core.ExportedModule
|
|
6
5
|
import expo.modules.core.interfaces.InternalModule
|
|
7
6
|
import expo.modules.core.interfaces.Package
|
|
8
7
|
|
|
9
8
|
class KeepAwakePackage : Package {
|
|
10
|
-
override fun createExportedModules(context: Context): List<ExportedModule> {
|
|
11
|
-
return listOf(KeepAwakeModule(context))
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
override fun createInternalModules(context: Context): List<InternalModule> {
|
|
15
10
|
return listOf(ExpoKeepAwakeManager())
|
|
16
11
|
}
|
package/expo-module.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-keep-awake",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.0",
|
|
4
4
|
"description": "Provides a React component that prevents the screen sleeping when rendered. It also exposes static methods to control the behavior imperatively.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"jest": {
|
|
43
43
|
"preset": "expo-module-scripts"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "79607a7325f47aa17c36d266100d09a4ff2cc544"
|
|
46
46
|
}
|
package/tsconfig.json
CHANGED