mirror of
https://github.com/PaulWoitaschek/Voice.git
synced 2026-03-13 08:02:45 +08:00
Replace app startup with a custom implementation
This commit is contained in:
@@ -153,6 +153,7 @@ dependencies {
|
||||
implementation(projects.core.data.impl)
|
||||
implementation(projects.core.playback)
|
||||
implementation(projects.core.scanner)
|
||||
implementation(projects.core.initializer)
|
||||
implementation(projects.features.playbackScreen)
|
||||
implementation(projects.navigation)
|
||||
implementation(projects.core.sleeptimer.api)
|
||||
@@ -171,7 +172,6 @@ dependencies {
|
||||
implementation(libs.appCompat)
|
||||
implementation(libs.material)
|
||||
implementation(libs.datastore)
|
||||
implementation(libs.appStartup)
|
||||
|
||||
implementation(libs.navigation3.ui)
|
||||
|
||||
@@ -198,9 +198,6 @@ dependencies {
|
||||
testImplementation(libs.junit)
|
||||
testImplementation(libs.mockk)
|
||||
|
||||
implementation(libs.leakcanary.plumber)
|
||||
debugImplementation(libs.leakcanary.android)
|
||||
|
||||
implementation(libs.media3.exoplayer)
|
||||
implementation(libs.media3.session)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.launch
|
||||
import voice.core.common.rootGraph
|
||||
import voice.core.data.store.DarkThemeStore
|
||||
import voice.core.initializer.AppInitializer
|
||||
import voice.core.scanner.MediaScanTrigger
|
||||
import voice.core.sleeptimer.AutoEnableSleepTimer
|
||||
import voice.core.ui.DARK_THEME_SETTABLE
|
||||
@@ -30,6 +31,9 @@ open class App : Application() {
|
||||
@Inject
|
||||
lateinit var autoEnableSleepTimer: AutoEnableSleepTimer
|
||||
|
||||
@Inject
|
||||
lateinit var appInitializers: Set<AppInitializer>
|
||||
|
||||
@field:[
|
||||
Inject
|
||||
DarkThemeStore
|
||||
@@ -62,6 +66,9 @@ open class App : Application() {
|
||||
}
|
||||
}
|
||||
|
||||
appInitializers.forEach {
|
||||
it.onAppStart(this)
|
||||
}
|
||||
mediaScanner.scan()
|
||||
triggerWidgetOnChange.init()
|
||||
autoEnableSleepTimer.startMonitoring()
|
||||
|
||||
3
core/initializer/build.gradle.kts
Normal file
3
core/initializer/build.gradle.kts
Normal file
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("voice.library")
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package voice.core.initializer
|
||||
|
||||
import android.app.Application
|
||||
|
||||
interface AppInitializer {
|
||||
|
||||
fun onAppStart(application: Application)
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
plugins {
|
||||
id("voice.library")
|
||||
alias(libs.plugins.metro)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.appStartup)
|
||||
implementation(projects.core.initializer)
|
||||
implementation(libs.firebase.crashlytics)
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<manifest xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
android:exported="false"
|
||||
tools:node="merge">
|
||||
|
||||
<meta-data
|
||||
android:name="voice.core.logging.crashlytics.CrashlyticsLogWriterInitializer"
|
||||
android:value="androidx.startup" />
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,15 +1,17 @@
|
||||
package voice.core.logging.crashlytics
|
||||
|
||||
import android.content.Context
|
||||
import androidx.startup.Initializer
|
||||
import android.app.Application
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesIntoSet
|
||||
import dev.zacsweers.metro.Inject
|
||||
import voice.core.initializer.AppInitializer
|
||||
import voice.core.logging.core.Logger
|
||||
|
||||
@Suppress("unused")
|
||||
class CrashlyticsLogWriterInitializer : Initializer<Unit> {
|
||||
@ContributesIntoSet(AppScope::class)
|
||||
@Inject
|
||||
class CrashlyticsLogWriterInitializer : AppInitializer {
|
||||
|
||||
override fun create(context: Context) {
|
||||
override fun onAppStart(application: Application) {
|
||||
Logger.install(CrashlyticsLogWriter())
|
||||
}
|
||||
|
||||
override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
plugins {
|
||||
id("voice.library")
|
||||
alias(libs.plugins.metro)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.appStartup)
|
||||
implementation(projects.core.initializer)
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<manifest xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
android:exported="false"
|
||||
tools:node="merge">
|
||||
|
||||
<meta-data
|
||||
android:name="voice.core.logging.debug.DebugLogWriterInitializer"
|
||||
android:value="androidx.startup" />
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,15 +1,17 @@
|
||||
package voice.core.logging.debug
|
||||
|
||||
import android.content.Context
|
||||
import androidx.startup.Initializer
|
||||
import android.app.Application
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesIntoSet
|
||||
import dev.zacsweers.metro.Inject
|
||||
import voice.core.initializer.AppInitializer
|
||||
import voice.core.logging.core.Logger
|
||||
|
||||
@Suppress("unused")
|
||||
class DebugLogWriterInitializer : Initializer<Unit> {
|
||||
@ContributesIntoSet(AppScope::class)
|
||||
@Inject
|
||||
class DebugLogWriterInitializer : AppInitializer {
|
||||
|
||||
override fun create(context: Context) {
|
||||
override fun onAppStart(application: Application) {
|
||||
Logger.install(DebugLogWriter())
|
||||
}
|
||||
|
||||
override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
[versions]
|
||||
leakcanary = "2.14"
|
||||
versionCode = "3603049"
|
||||
versionName = "8.6.2"
|
||||
|
||||
@@ -20,8 +19,6 @@ metro = "0.6.3"
|
||||
|
||||
[libraries]
|
||||
androidPluginForGradle = { module = "com.android.tools.build:gradle", version.ref = "agp" }
|
||||
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android-startup", version.ref = "leakcanary" }
|
||||
leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android-startup", version.ref = "leakcanary" }
|
||||
material = "com.google.android.material:material:1.12.0"
|
||||
junit = "junit:junit:4.13.2"
|
||||
mockk = "io.mockk:mockk:1.14.5"
|
||||
@@ -40,7 +37,6 @@ documentFile = "androidx.documentfile:documentfile:1.1.0"
|
||||
koTest-assert = "io.kotest:kotest-assertions-core:6.0.1"
|
||||
datastore = "androidx.datastore:datastore-preferences:1.1.7"
|
||||
seismic = "com.squareup:seismic:1.0.3"
|
||||
appStartup = "androidx.startup:startup-runtime:1.2.0"
|
||||
turbine = "app.cash.turbine:turbine:1.2.1"
|
||||
molecule = "app.cash.molecule:molecule-runtime:2.1.0"
|
||||
immutable = "org.jetbrains.kotlinx:kotlinx-collections-immutable:0.4.0"
|
||||
|
||||
@@ -66,6 +66,7 @@ include(":core:scanner")
|
||||
include(":core:search")
|
||||
include(":core:strings")
|
||||
include(":core:ui")
|
||||
include(":core:initializer")
|
||||
|
||||
include(":features:bookOverview")
|
||||
include(":features:bookmark")
|
||||
@@ -79,4 +80,4 @@ include(":features:settings")
|
||||
include(":features:sleepTimer")
|
||||
include(":features:widget")
|
||||
include(":core:sleeptimer:api")
|
||||
include(":core:sleeptimer:impl")
|
||||
include(":core:sleeptimer:impl")
|
||||
|
||||
Reference in New Issue
Block a user