diff --git a/api/build.gradle.kts b/api/build.gradle.kts index ff29e76dea2e4ed3ca65fec4f9a3968441372d26..b6e578e86d7e22376b808571f654a4f44aa56ec5 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -25,16 +25,6 @@ plugins { } dependencies { - implementation(libs.kotlin.stdlib) - - implementation(libs.kotlinx.coroutines.core) - testImplementation(libs.kotlinx.coroutines.test) - - testImplementation(libs.kotlin.test) - testImplementation(libs.junit.api) - testImplementation(libs.junit.params) - testRuntimeOnly(libs.junit.engine) - implementation(libs.kotlinx.datetime) implementation(libs.okhttp) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b64fb07f37feb6cce7896abcc69f783ccbe04dd6..5692fb96ceb2f1d237749c5a9c90b01d4e3e27c4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -21,6 +21,9 @@ plugins { id("justjanne.android.app") + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.kotlin.ksp) + alias(libs.plugins.dagger.hilt) } android { @@ -85,6 +88,10 @@ dependencies { implementation(libs.okhttp) implementation(libs.kotlinx.serialization.json) implementation(libs.coil.compose) + + implementation(libs.hilt.android) + ksp(libs.hilt.compiler) + implementation(project(":api")) implementation(project(":persistence")) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3ae67d5ae61dbb0dfc50a8c2ffce2a3cb7f2a18d..9cd15e022abd46dfcd485724ffc606d111d563f3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ <uses-permission android:name="android.permission.INTERNET" /> <application + android:name=".MeteroidApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/application_name" diff --git a/app/src/main/kotlin/de/chaosdorf/meteroid/App.kt b/app/src/main/kotlin/de/chaosdorf/meteroid/App.kt new file mode 100644 index 0000000000000000000000000000000000000000..710454e4db6933341dec22c2043297704eda1c5f --- /dev/null +++ b/app/src/main/kotlin/de/chaosdorf/meteroid/App.kt @@ -0,0 +1,38 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013-2023 Chaosdorf e.V. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package de.chaosdorf.meteroid + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import de.chaosdorf.meteroid.di.RootViewModel +import de.chaosdorf.meteroid.routes.RootRouter + +@Composable +fun App(viewModel: RootViewModel) { + val route by viewModel.route.collectAsState() + + RootRouter(route) +} diff --git a/app/src/main/kotlin/de/chaosdorf/meteroid/MainActivity.kt b/app/src/main/kotlin/de/chaosdorf/meteroid/MainActivity.kt index 875e72b70e622265bed12b57871ffb7f9a8206b5..af1770b77548ed403dd95a30288edfe870ab8ff8 100644 --- a/app/src/main/kotlin/de/chaosdorf/meteroid/MainActivity.kt +++ b/app/src/main/kotlin/de/chaosdorf/meteroid/MainActivity.kt @@ -27,16 +27,14 @@ package de.chaosdorf.meteroid import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue +import dagger.hilt.android.AndroidEntryPoint import de.chaosdorf.meteroid.di.RootViewModel import de.chaosdorf.meteroid.di.RootViewModelFactory -import de.chaosdorf.meteroid.routes.RootRouter import de.chaosdorf.meteroid.ui.theme.MeteroidTheme import kotlinx.coroutines.MainScope +@AndroidEntryPoint class MainActivity : ComponentActivity() { private val rootViewModelFactory = object : RootViewModelFactory {} private lateinit var rootViewModel: RootViewModel @@ -54,10 +52,3 @@ class MainActivity : ComponentActivity() { } } } - -@Composable -fun App(viewModel: RootViewModel) { - val route by viewModel.route.collectAsState() - - RootRouter(route) -} diff --git a/app/src/main/kotlin/de/chaosdorf/meteroid/MeteroidApplication.kt b/app/src/main/kotlin/de/chaosdorf/meteroid/MeteroidApplication.kt new file mode 100644 index 0000000000000000000000000000000000000000..1d67c5c2bc01be4ded6a03bd310c9a5d85d9bc86 --- /dev/null +++ b/app/src/main/kotlin/de/chaosdorf/meteroid/MeteroidApplication.kt @@ -0,0 +1,31 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013-2023 Chaosdorf e.V. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package de.chaosdorf.meteroid + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp + +@HiltAndroidApp +class MeteroidApplication : Application() diff --git a/build.gradle.kts b/build.gradle.kts index 6c489d0d6e8930fae68bee7deed61dfb24ff31a8..51555c936419520612da3e49f0e66229d86fbaa1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,4 +11,6 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.kotlin.serialization) apply false + alias(libs.plugins.kotlin.ksp) apply false + alias(libs.plugins.dagger.hilt) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b1ef11609752905ed6396ae66043312ab8ff1367..1cd49f73a3106d7e901fd0b8ae6a4f7600acf3dd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,6 +11,7 @@ androidx-compose-tooling = "1.6.0-alpha08" androidx-navigation = "2.7.4" androidx-room = "2.6.0" coil = "2.4.0" +dagger-hilt = "2.48.1" kotlin = "1.9.10" kotlin-ksp = "1.9.10-1.0.13" kotlinxCoroutines = "1.7.1" @@ -49,6 +50,8 @@ androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "an coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } +hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "dagger-hilt" } +hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "dagger-hilt" } okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" } retrofit-core = { module = "com.squareup.retrofit2:retrofit", version = "2.9.0" } retrofit-converter-kotlinx = { module = "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter", version = "1.0.0" } @@ -75,6 +78,7 @@ kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-pl android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" } +dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger-hilt" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "kotlin.ksp" } diff --git a/persistence/build.gradle.kts b/persistence/build.gradle.kts index 56a70fe39af3e93fc9daca1c463a792a8f130cc5..fe766b996906bd3699652432eaea9ca24a80c6ea 100644 --- a/persistence/build.gradle.kts +++ b/persistence/build.gradle.kts @@ -23,6 +23,7 @@ plugins { id("justjanne.android.library") alias(libs.plugins.kotlin.serialization) alias(libs.plugins.kotlin.ksp) + alias(libs.plugins.dagger.hilt) } android { @@ -50,6 +51,9 @@ dependencies { implementation(libs.androidx.room.ktx) implementation(libs.androidx.room.paging) + implementation(libs.hilt.android) + ksp(libs.hilt.compiler) + implementation(libs.kotlinx.datetime) implementation(libs.kotlinx.serialization.json) implementation(project(":api"))