New Android module (no Compose, no DI) with broadcastTicks, a coroutine BroadcastReceiver.goAsync, Context.hasPermission, AlarmManager.setWakeup and Flow.stateWhileSubscribed.
48 lines
1.3 KiB
Kotlin
48 lines
1.3 KiB
Kotlin
// core-android — small Android plumbing every app in the family writes again:
|
|
// a broadcast-driven tick Flow, a coroutine `goAsync` for receivers, a
|
|
// permission check, the exact-or-inexact alarm wake-up, and the
|
|
// `stateIn(WhileSubscribed(5s))` idiom. No Compose and no DI, so only the
|
|
// Android library plugin is applied; coroutines are part of the public API.
|
|
plugins {
|
|
alias(libs.plugins.android.library)
|
|
}
|
|
|
|
android {
|
|
namespace = "de.jeanlucmakiola.floret.android"
|
|
compileSdk = 37
|
|
|
|
defaultConfig {
|
|
minSdk = 29
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
testOptions {
|
|
unitTests {
|
|
all { it.useJUnitPlatform() }
|
|
isReturnDefaultValues = true
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
// `Flow`/`StateFlow`/`CoroutineScope` appear in the public API.
|
|
api(libs.kotlinx.coroutines.core)
|
|
implementation(libs.androidx.core.ktx)
|
|
|
|
testImplementation(libs.junit.jupiter.api)
|
|
testRuntimeOnly(libs.junit.jupiter.engine)
|
|
testRuntimeOnly(libs.junit.platform.launcher)
|
|
testImplementation(libs.truth)
|
|
testImplementation(libs.kotlinx.coroutines.test)
|
|
}
|