chore: add mobile app

This commit is contained in:
2026-02-07 22:33:02 +01:00
parent db34640acc
commit e89384ad4e
29327 changed files with 3886944 additions and 12 deletions
+15
View File
@@ -0,0 +1,15 @@
plugins {
id 'com.android.library'
id 'expo-module-gradle-plugin'
}
group = 'host.exp.exponent'
version = '15.0.8'
android {
namespace "expo.modules.keepawake"
defaultConfig {
versionCode 16
versionName "15.0.8"
}
}
@@ -0,0 +1,3 @@
<manifest>
</manifest>
@@ -0,0 +1,59 @@
package expo.modules.keepawake
import android.app.Activity
import android.view.WindowManager
import expo.modules.core.ModuleRegistry
import expo.modules.core.errors.CurrentActivityNotFoundException
import expo.modules.core.interfaces.ActivityProvider
import expo.modules.core.interfaces.InternalModule
import expo.modules.core.interfaces.services.KeepAwakeManager
class ExpoKeepAwakeManager : KeepAwakeManager, InternalModule {
private val tags: MutableSet<String> = HashSet()
private lateinit var moduleRegistry: ModuleRegistry
override fun onCreate(moduleRegistry: ModuleRegistry) {
this.moduleRegistry = moduleRegistry
}
@get:Throws(CurrentActivityNotFoundException::class)
private val currentActivity: Activity
get() {
val activityProvider = moduleRegistry.getModule(ActivityProvider::class.java)
?: throw CurrentActivityNotFoundException()
return if (activityProvider.currentActivity != null) {
activityProvider.currentActivity
} else {
throw CurrentActivityNotFoundException()
}
}
@Throws(CurrentActivityNotFoundException::class)
override fun activate(tag: String, done: Runnable) {
val activity = currentActivity
if (!isActivated) {
activity.runOnUiThread { activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }
}
tags.add(tag)
done.run()
}
@Throws(CurrentActivityNotFoundException::class)
override fun deactivate(tag: String, done: Runnable) {
val activity = currentActivity
if (tags.size == 1 && tags.contains(tag)) {
activity.runOnUiThread { activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }
}
tags.remove(tag)
done.run()
}
override fun isActivated(): Boolean {
return tags.isNotEmpty()
}
override fun getExportedInterfaces(): List<Class<*>?> {
return listOf(KeepAwakeManager::class.java)
}
}
@@ -0,0 +1,9 @@
package expo.modules.keepawake
import expo.modules.kotlin.exception.CodedException
internal class ActivateKeepAwakeException :
CodedException("Unable to activate keep awake")
internal class MissingModuleException(moduleName: String) :
CodedException("Module '$moduleName' not found. Are you sure all modules are linked correctly?")
@@ -0,0 +1,37 @@
// Copyright 2015-present 650 Industries. All rights reserved.
package expo.modules.keepawake
import expo.modules.core.errors.CurrentActivityNotFoundException
import expo.modules.core.interfaces.services.KeepAwakeManager
import expo.modules.kotlin.Promise
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
class KeepAwakeModule : Module() {
private val keepAwakeManager: KeepAwakeManager
get() = appContext.legacyModule() ?: throw MissingModuleException("KeepAwakeManager")
override fun definition() = ModuleDefinition {
Name("ExpoKeepAwake")
AsyncFunction("activate") { tag: String, promise: Promise ->
try {
keepAwakeManager.activate(tag) { promise.resolve() }
} catch (ex: CurrentActivityNotFoundException) {
promise.reject(ActivateKeepAwakeException())
}
}
AsyncFunction("deactivate") { tag: String, promise: Promise ->
try {
keepAwakeManager.deactivate(tag) { promise.resolve() }
} catch (e: Exception) {
promise.resolve()
}
}
AsyncFunction<Boolean>("isActivated") {
return@AsyncFunction keepAwakeManager.isActivated
}
}
}
@@ -0,0 +1,12 @@
package expo.modules.keepawake
import android.content.Context
import expo.modules.core.interfaces.InternalModule
import expo.modules.core.interfaces.Package
class KeepAwakePackage : Package {
override fun createInternalModules(context: Context): List<InternalModule> {
return listOf(ExpoKeepAwakeManager())
}
}