expo-keep-awake 9.2.0 → 10.0.2

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 CHANGED
@@ -10,6 +10,32 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 10.0.2 — 2022-02-01
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
18
+
19
+ ## 10.0.1 — 2021-11-17
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
23
+ ## 10.0.0 — 2021-09-28
24
+
25
+ ### 🛠 Breaking changes
26
+
27
+ - Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
28
+
29
+ ### 🐛 Bug fixes
30
+
31
+ - Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
32
+
33
+ ## 9.3.0 — 2021-09-08
34
+
35
+ ### 💡 Others
36
+
37
+ - Rewrite android code to Kotlin. ([#13996](https://github.com/expo/expo/pull/13996) by [@kkafar](https://github.com/kkafar))
38
+
13
39
  ## 9.2.0 — 2021-06-16
14
40
 
15
41
  ### 🐛 Bug fixes
package/README.md CHANGED
@@ -13,7 +13,7 @@ For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
16
- For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
16
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
17
17
 
18
18
  ### Add the package to your npm dependencies
19
19
 
@@ -1,9 +1,9 @@
1
1
  apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-android'
3
- apply plugin: 'maven'
3
+ apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '9.2.0'
6
+ version = '10.0.2'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -20,27 +20,25 @@ buildscript {
20
20
  }
21
21
  }
22
22
 
23
- // Upload android library to maven with javadoc and android sources
24
- configurations {
25
- deployerJars
26
- }
27
-
28
23
  // Creating sources with comments
29
24
  task androidSourcesJar(type: Jar) {
30
25
  classifier = 'sources'
31
26
  from android.sourceSets.main.java.srcDirs
32
27
  }
33
28
 
34
- // Put the androidSources and javadoc to the artifacts
35
- artifacts {
36
- archives androidSourcesJar
37
- }
38
-
39
- uploadArchives {
40
- repositories {
41
- mavenDeployer {
42
- configuration = configurations.deployerJars
43
- repository(url: mavenLocal().url)
29
+ afterEvaluate {
30
+ publishing {
31
+ publications {
32
+ release(MavenPublication) {
33
+ from components.release
34
+ // Add additional sourcesJar to artifacts
35
+ artifact(androidSourcesJar)
36
+ }
37
+ }
38
+ repositories {
39
+ maven {
40
+ url = mavenLocal().url
41
+ }
44
42
  }
45
43
  }
46
44
  }
@@ -53,27 +51,23 @@ android {
53
51
  targetCompatibility JavaVersion.VERSION_1_8
54
52
  }
55
53
 
54
+ kotlinOptions {
55
+ jvmTarget = "1.8"
56
+ }
57
+
56
58
  defaultConfig {
57
59
  minSdkVersion safeExtGet("minSdkVersion", 21)
58
60
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
61
  versionCode 16
60
- versionName "9.2.0"
62
+ versionName "10.0.2"
61
63
  }
62
64
  lintOptions {
63
65
  abortOnError false
64
66
  }
65
67
  }
66
68
 
67
- if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
68
- apply from: project(":unimodules-core").file("../unimodules-core.gradle")
69
- } else {
70
- throw new GradleException(
71
- "'unimodules-core.gradle' was not found in the usual React Native dependency location. " +
72
- "This package can only be used in such projects. Are you sure you've installed the dependencies properly?")
73
- }
74
-
75
69
  dependencies {
76
- unimodule "unimodules-core"
70
+ implementation project(':expo-modules-core')
77
71
 
78
72
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
79
73
  }
@@ -0,0 +1,62 @@
1
+ package expo.modules.keepawake
2
+
3
+ import android.app.Activity
4
+ import android.view.WindowManager
5
+
6
+ import expo.modules.core.interfaces.services.KeepAwakeManager
7
+ import expo.modules.core.interfaces.InternalModule
8
+ import expo.modules.core.ModuleRegistry
9
+ import expo.modules.core.ModuleRegistryDelegate
10
+ import expo.modules.core.errors.CurrentActivityNotFoundException
11
+ import expo.modules.core.interfaces.ActivityProvider
12
+
13
+ import java.util.HashSet
14
+
15
+ class ExpoKeepAwakeManager(private val moduleRegistryDelegate: ModuleRegistryDelegate = ModuleRegistryDelegate()) : KeepAwakeManager, InternalModule {
16
+ private val tags: MutableSet<String> = HashSet()
17
+
18
+ private inline fun <reified T> moduleRegistry() = moduleRegistryDelegate.getFromModuleRegistry<T>()
19
+
20
+ override fun onCreate(moduleRegistry: ModuleRegistry) {
21
+ moduleRegistryDelegate.onCreate(moduleRegistry)
22
+ }
23
+
24
+ @get:Throws(CurrentActivityNotFoundException::class)
25
+ private val currentActivity: Activity
26
+ get() {
27
+ val activityProvider: ActivityProvider by moduleRegistry()
28
+ return if (activityProvider.currentActivity != null) {
29
+ activityProvider.currentActivity
30
+ } else {
31
+ throw CurrentActivityNotFoundException()
32
+ }
33
+ }
34
+
35
+ @Throws(CurrentActivityNotFoundException::class)
36
+ override fun activate(tag: String, done: Runnable) {
37
+ val activity = currentActivity
38
+ if (!isActivated) {
39
+ activity.runOnUiThread { activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }
40
+ }
41
+ tags.add(tag)
42
+ done.run()
43
+ }
44
+
45
+ @Throws(CurrentActivityNotFoundException::class)
46
+ override fun deactivate(tag: String, done: Runnable) {
47
+ val activity = currentActivity
48
+ if (tags.size == 1 && tags.contains(tag)) {
49
+ activity.runOnUiThread { activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }
50
+ }
51
+ tags.remove(tag)
52
+ done.run()
53
+ }
54
+
55
+ override fun isActivated(): Boolean {
56
+ return tags.isNotEmpty()
57
+ }
58
+
59
+ override fun getExportedInterfaces(): List<Class<*>?> {
60
+ return listOf(KeepAwakeManager::class.java)
61
+ }
62
+ }
@@ -0,0 +1,54 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+ package expo.modules.keepawake
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
+ import expo.modules.core.errors.CurrentActivityNotFoundException
13
+
14
+ private const val NAME = "ExpoKeepAwake"
15
+ private const val NO_ACTIVITY_ERROR_CODE = "NO_CURRENT_ACTIVITY"
16
+
17
+ class KeepAwakeModule(
18
+ context: Context,
19
+ private val moduleRegistryDelegate: ModuleRegistryDelegate = ModuleRegistryDelegate()
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")
40
+ }
41
+ }
42
+
43
+ @ExpoMethod
44
+ fun deactivate(tag: String, promise: Promise) {
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.")
49
+ }
50
+ }
51
+
52
+ val isActivated: Boolean
53
+ get() = keepAwakeManager.isActivated
54
+ }
@@ -0,0 +1,17 @@
1
+ package expo.modules.keepawake
2
+
3
+ import android.content.Context
4
+
5
+ import expo.modules.core.ExportedModule
6
+ import expo.modules.core.interfaces.InternalModule
7
+ import expo.modules.core.interfaces.Package
8
+
9
+ class KeepAwakePackage : Package {
10
+ override fun createExportedModules(context: Context): List<ExportedModule> {
11
+ return listOf(KeepAwakeModule(context))
12
+ }
13
+
14
+ override fun createInternalModules(context: Context): List<InternalModule> {
15
+ return listOf(ExpoKeepAwakeManager())
16
+ }
17
+ }
@@ -1,2 +1,2 @@
1
- declare const _default: import("@unimodules/core").ProxyNativeModule;
1
+ declare const _default: import("expo-modules-core").ProxyNativeModule;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { NativeModulesProxy } from '@unimodules/core';
1
+ import { NativeModulesProxy } from 'expo-modules-core';
2
2
  export default NativeModulesProxy.ExpoKeepAwake;
3
3
  //# sourceMappingURL=ExpoKeepAwake.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoKeepAwake.js","sourceRoot":"","sources":["../src/ExpoKeepAwake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,eAAe,kBAAkB,CAAC,aAAa,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\nexport default NativeModulesProxy.ExpoKeepAwake;\n"]}
1
+ {"version":3,"file":"ExpoKeepAwake.js","sourceRoot":"","sources":["../src/ExpoKeepAwake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,eAAe,kBAAkB,CAAC,aAAa,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\nexport default NativeModulesProxy.ExpoKeepAwake;\n"]}
@@ -1,7 +1,7 @@
1
1
  // Copyright 2018-present 650 Industries. All rights reserved.
2
2
 
3
- #import <UMCore/UMExportedModule.h>
4
- #import <UMCore/UMModuleRegistryConsumer.h>
3
+ #import <ExpoModulesCore/EXExportedModule.h>
4
+ #import <ExpoModulesCore/EXModuleRegistryConsumer.h>
5
5
 
6
- @interface EXKeepAwake : UMExportedModule <UMModuleRegistryConsumer>
6
+ @interface EXKeepAwake : EXExportedModule <EXModuleRegistryConsumer>
7
7
  @end
@@ -1,14 +1,14 @@
1
1
  // Copyright 2018-present 650 Industries. All rights reserved.
2
2
 
3
- #import <UMCore/UMModuleRegistry.h>
3
+ #import <ExpoModulesCore/EXModuleRegistry.h>
4
4
  #import <EXKeepAwake/EXKeepAwake.h>
5
- #import <UMCore/UMAppLifecycleService.h>
6
- #import <UMCore/UMUtilities.h>
5
+ #import <ExpoModulesCore/EXAppLifecycleService.h>
6
+ #import <ExpoModulesCore/EXUtilities.h>
7
7
 
8
- @interface EXKeepAwake () <UMAppLifecycleListener>
8
+ @interface EXKeepAwake () <EXAppLifecycleListener>
9
9
 
10
- @property (nonatomic, weak) id<UMAppLifecycleService> lifecycleManager;
11
- @property (nonatomic, weak) UMModuleRegistry *moduleRegistry;
10
+ @property (nonatomic, weak) id<EXAppLifecycleService> lifecycleManager;
11
+ @property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
12
12
 
13
13
  @end
14
14
 
@@ -22,11 +22,11 @@
22
22
  return self;
23
23
  }
24
24
 
25
- UM_EXPORT_MODULE(ExpoKeepAwake);
25
+ EX_EXPORT_MODULE(ExpoKeepAwake);
26
26
 
27
- # pragma mark - UMModuleRegistryConsumer
27
+ # pragma mark - EXModuleRegistryConsumer
28
28
 
29
- - (void)setModuleRegistry:(UMModuleRegistry *)moduleRegistry
29
+ - (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
30
30
  {
31
31
  if (_moduleRegistry) {
32
32
  [_lifecycleManager unregisterAppLifecycleListener:self];
@@ -35,7 +35,7 @@ UM_EXPORT_MODULE(ExpoKeepAwake);
35
35
  _lifecycleManager = nil;
36
36
 
37
37
  if (moduleRegistry) {
38
- _lifecycleManager = [moduleRegistry getModuleImplementingProtocol:@protocol(UMAppLifecycleService)];
38
+ _lifecycleManager = [moduleRegistry getModuleImplementingProtocol:@protocol(EXAppLifecycleService)];
39
39
  }
40
40
 
41
41
  if (_lifecycleManager) {
@@ -43,12 +43,12 @@ UM_EXPORT_MODULE(ExpoKeepAwake);
43
43
  }
44
44
  }
45
45
 
46
- UM_EXPORT_METHOD_AS(activate, activate:(NSString *)tag
47
- resolve:(UMPromiseResolveBlock)resolve
48
- reject:(UMPromiseRejectBlock)reject)
46
+ EX_EXPORT_METHOD_AS(activate, activate:(NSString *)tag
47
+ resolve:(EXPromiseResolveBlock)resolve
48
+ reject:(EXPromiseRejectBlock)reject)
49
49
  {
50
50
  if(![self shouldBeActive]) {
51
- [UMUtilities performSynchronouslyOnMainThread:^{
51
+ [EXUtilities performSynchronouslyOnMainThread:^{
52
52
  [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
53
53
  }];
54
54
  }
@@ -56,30 +56,30 @@ UM_EXPORT_METHOD_AS(activate, activate:(NSString *)tag
56
56
  resolve(@YES);
57
57
  }
58
58
 
59
- UM_EXPORT_METHOD_AS(deactivate, deactivate:(NSString *)tag
60
- resolve:(UMPromiseResolveBlock)resolve
61
- reject:(UMPromiseRejectBlock)reject)
59
+ EX_EXPORT_METHOD_AS(deactivate, deactivate:(NSString *)tag
60
+ resolve:(EXPromiseResolveBlock)resolve
61
+ reject:(EXPromiseRejectBlock)reject)
62
62
  {
63
63
  [_activeTags removeObject:tag];
64
64
  if (![self shouldBeActive]) {
65
- [UMUtilities performSynchronouslyOnMainThread:^{
65
+ [EXUtilities performSynchronouslyOnMainThread:^{
66
66
  [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
67
67
  }];
68
68
  }
69
69
  resolve(@YES);
70
70
  }
71
71
 
72
- # pragma mark - UMAppLifecycleListener
72
+ # pragma mark - EXAppLifecycleListener
73
73
 
74
74
  - (void)onAppBackgrounded {
75
- [UMUtilities performSynchronouslyOnMainThread:^{
75
+ [EXUtilities performSynchronouslyOnMainThread:^{
76
76
  [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
77
77
  }];
78
78
  }
79
79
 
80
80
  - (void)onAppForegrounded {
81
81
  if ([self shouldBeActive]) {
82
- [UMUtilities performSynchronouslyOnMainThread:^{
82
+ [EXUtilities performSynchronouslyOnMainThread:^{
83
83
  [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
84
84
  }];
85
85
  }
@@ -10,10 +10,11 @@ Pod::Spec.new do |s|
10
10
  s.license = package['license']
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
- s.platform = :ios, '11.0'
13
+ s.platform = :ios, '12.0'
14
14
  s.source = { git: 'https://github.com/expo/expo.git' }
15
+ s.static_framework = true
15
16
 
16
- s.dependency 'UMCore'
17
+ s.dependency 'ExpoModulesCore'
17
18
 
18
19
  if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
19
20
  s.source_files = "#{s.name}/**/*.h"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-keep-awake",
3
- "version": "9.2.0",
3
+ "version": "10.0.2",
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",
@@ -30,9 +30,13 @@
30
30
  },
31
31
  "author": "650 Industries, Inc.",
32
32
  "license": "MIT",
33
- "homepage": "https://docs.expo.io/versions/latest/sdk/keep-awake/",
33
+ "homepage": "https://docs.expo.dev/versions/latest/sdk/keep-awake/",
34
+ "dependencies": {},
34
35
  "devDependencies": {
35
36
  "expo-module-scripts": "^2.0.0"
36
37
  },
37
- "gitHead": "b33f5e224578564c3e4b1b467f258cc119b3b786"
38
+ "peerDependencies": {
39
+ "expo": "*"
40
+ },
41
+ "gitHead": "ba24eba18bf4f4d4b0d54828992d81a2bb18246a"
38
42
  }
@@ -1,2 +1,2 @@
1
- import { NativeModulesProxy } from '@unimodules/core';
1
+ import { NativeModulesProxy } from 'expo-modules-core';
2
2
  export default NativeModulesProxy.ExpoKeepAwake;
@@ -1,69 +0,0 @@
1
- package expo.modules.keepawake;
2
-
3
- import android.app.Activity;
4
- import android.view.WindowManager;
5
-
6
- import org.unimodules.core.ModuleRegistry;
7
- import org.unimodules.core.errors.CurrentActivityNotFoundException;
8
- import org.unimodules.core.interfaces.ActivityProvider;
9
- import org.unimodules.core.interfaces.InternalModule;
10
- import org.unimodules.core.interfaces.services.KeepAwakeManager;
11
-
12
- import java.util.Collections;
13
- import java.util.HashSet;
14
- import java.util.List;
15
- import java.util.Set;
16
-
17
- public class ExpoKeepAwakeManager implements KeepAwakeManager, InternalModule {
18
-
19
- private ModuleRegistry mModuleRegistry;
20
- private Set<String> mTags = new HashSet<>();
21
-
22
- @Override
23
- public void onCreate(ModuleRegistry moduleRegistry) {
24
- mModuleRegistry = moduleRegistry;
25
- }
26
-
27
- private Activity getCurrentActivity() throws CurrentActivityNotFoundException {
28
- ActivityProvider activityProvider = mModuleRegistry.getModule(ActivityProvider.class);
29
- if (activityProvider.getCurrentActivity() != null) {
30
- return activityProvider.getCurrentActivity();
31
- } else {
32
- throw new CurrentActivityNotFoundException();
33
- }
34
- }
35
-
36
- @Override
37
- public void activate(final String tag, final Runnable done) throws CurrentActivityNotFoundException {
38
- final Activity activity = getCurrentActivity();
39
-
40
- if (!isActivated()) {
41
- if (activity != null) {
42
- activity.runOnUiThread(() -> activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
43
- }
44
- }
45
- mTags.add(tag);
46
- done.run();
47
- }
48
-
49
- @Override
50
- public void deactivate(final String tag, final Runnable done) throws CurrentActivityNotFoundException {
51
- final Activity activity = getCurrentActivity();
52
-
53
- if (mTags.size() == 1 && mTags.contains(tag) && activity != null) {
54
- activity.runOnUiThread(() -> activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
55
- }
56
- mTags.remove(tag);
57
- done.run();
58
- }
59
-
60
- @Override
61
- public boolean isActivated() {
62
- return mTags.size() > 0;
63
- }
64
-
65
- @Override
66
- public List<? extends Class> getExportedInterfaces() {
67
- return Collections.singletonList(KeepAwakeManager.class);
68
- }
69
- }
@@ -1,57 +0,0 @@
1
- // Copyright 2015-present 650 Industries. All rights reserved.
2
-
3
- package expo.modules.keepawake;
4
-
5
- import android.content.Context;
6
-
7
- import org.unimodules.core.ExportedModule;
8
- import org.unimodules.core.ModuleRegistry;
9
- import org.unimodules.core.Promise;
10
- import org.unimodules.core.errors.CurrentActivityNotFoundException;
11
- import org.unimodules.core.interfaces.ExpoMethod;
12
- import org.unimodules.core.interfaces.services.KeepAwakeManager;
13
-
14
- public class KeepAwakeModule extends ExportedModule {
15
- private static final String NAME = "ExpoKeepAwake";
16
- private final static String NO_ACTIVITY_ERROR_CODE = "NO_CURRENT_ACTIVITY";
17
-
18
- private KeepAwakeManager mKeepAwakeManager;
19
-
20
- public KeepAwakeModule(Context context) {
21
- super(context);
22
- }
23
-
24
- @Override
25
- public String getName() {
26
- return NAME;
27
- }
28
-
29
- @Override
30
- public void onCreate(ModuleRegistry moduleRegistry) {
31
- mKeepAwakeManager = moduleRegistry.getModule(KeepAwakeManager.class);
32
- }
33
-
34
-
35
- @ExpoMethod
36
- public void activate(String tag, final Promise promise) {
37
- try {
38
- mKeepAwakeManager.activate(tag, () -> promise.resolve(true));
39
- } catch (CurrentActivityNotFoundException ex) {
40
- promise.reject(NO_ACTIVITY_ERROR_CODE, "Unable to activate keep awake");
41
- }
42
- }
43
-
44
- @ExpoMethod
45
- public void deactivate(String tag, Promise promise) {
46
- try {
47
- mKeepAwakeManager.deactivate(tag, () -> promise.resolve(true));
48
- } catch (CurrentActivityNotFoundException ex) {
49
- promise.reject(NO_ACTIVITY_ERROR_CODE, "Unable to deactivate keep awake. However, it probably is deactivated already.");
50
- }
51
-
52
- }
53
-
54
- public boolean isActivated() {
55
- return mKeepAwakeManager.isActivated();
56
- }
57
- }
@@ -1,23 +0,0 @@
1
- package expo.modules.keepawake;
2
-
3
- import android.content.Context;
4
-
5
- import org.unimodules.core.ExportedModule;
6
- import org.unimodules.core.interfaces.InternalModule;
7
- import org.unimodules.core.interfaces.Package;
8
-
9
- import java.util.Collections;
10
- import java.util.List;
11
-
12
- public class KeepAwakePackage implements Package {
13
-
14
- @Override
15
- public List<ExportedModule> createExportedModules(Context context) {
16
- return Collections.<ExportedModule>singletonList(new KeepAwakeModule(context));
17
- }
18
-
19
- @Override
20
- public List<? extends InternalModule> createInternalModules(Context context) {
21
- return Collections.singletonList(new ExpoKeepAwakeManager());
22
- }
23
- }