diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cc2c14e..e3a3765 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,22 +40,6 @@ android { namespace = "com.loodos.samplecomposeandroid" } dependencies { - implementation(libs.accompanist.systemuicontroller) - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.appcompat) - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.lifecycle.runtime.ktx) - implementation(libs.android.material) - implementation(libs.compose.ui) - implementation(libs.compose.material) - implementation(libs.androidx.compose.material.iconsExtended) - implementation(libs.compose.ui.tooling) - implementation(libs.square.moshi.kotlin) - implementation(libs.square.retrofit) - implementation(libs.square.retrofit.converter.moshi) - implementation(libs.androidx.core.splashscreen) - implementation(libs.okhttp.logging.interceptor) - implementation(projects.feature.login) implementation(projects.feature.home) implementation(projects.feature.category) @@ -66,32 +50,38 @@ dependencies { implementation(projects.core.designsystem) implementation(projects.core.data) implementation(projects.core.domain) + implementation(projects.core.ui) - testImplementation(libs.junit4) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.core.splashscreen) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.runtimeCompose) + implementation(libs.accompanist.systemuicontroller) + implementation(libs.androidx.hilt.navigation.compose) + implementation(libs.androidx.navigation.compose) + implementation(libs.androidx.fragment.ktx) + implementation(libs.coil.kt) + implementation(libs.compose.state.events) + testImplementation(libs.junit4) androidTestImplementation(libs.androidx.test.junit) androidTestImplementation(libs.androidx.test.espresso.core) androidTestImplementation(libs.compose.ui.test.junit) androidTestImplementation(libs.hilt.android.testing) - implementation(libs.androidx.hilt.navigation.compose) - - - debugImplementation(libs.compose.ui.test.manifest) - debugImplementation(libs.compose.ui.tooling) + androidTestImplementation(libs.androidx.navigation.testing) debugImplementation(libs.square.leakcanary) - implementation(libs.retrofit.converter.gson) kapt(libs.square.moshi.kotlin.codegen) debugImplementation(libs.chucker) releaseImplementation(libs.chucker.no.op) - implementation(libs.androidx.compose.runtime) - implementation(libs.androidx.lifecycle.runtime.ktx) - implementation(libs.androidx.lifecycle.runtimeCompose) - implementation(libs.compose.state.events) - implementation(libs.androidx.fragment.ktx) - implementation(libs.androidx.navigation.compose) - + // Core functions + kaptTest(libs.hilt.compiler) + testImplementation(kotlin("test")) + testImplementation(libs.androidx.navigation.testing) } \ No newline at end of file diff --git a/app/src/main/java/com/loodos/MainApplication.kt b/app/src/main/java/com/loodos/MainApplication.kt index 9a6a087..57d4260 100644 --- a/app/src/main/java/com/loodos/MainApplication.kt +++ b/app/src/main/java/com/loodos/MainApplication.kt @@ -1,10 +1,20 @@ package com.loodos import android.app.Application +import coil.ImageLoader +import coil.ImageLoaderFactory import dagger.hilt.android.HiltAndroidApp +import javax.inject.Inject +import javax.inject.Provider /** * Created by mertcantoptas on 07.03.2023 */ @HiltAndroidApp -class MainApplication : Application() +class MainApplication : Application(), ImageLoaderFactory { + + @Inject + lateinit var imageLoader: Provider + + override fun newImageLoader(): ImageLoader = imageLoader.get() +} diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index cb4e853..bdd4f1b 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -23,6 +23,8 @@ secrets { } dependencies { + implementation(projects.core.common) + implementation(libs.androidx.core.ktx) implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlinx.serialization.json) @@ -34,5 +36,7 @@ dependencies { debugImplementation(libs.chucker) releaseImplementation(libs.chucker.no.op) - implementation(projects.core.common) + + implementation(libs.coil.kt) + implementation(libs.coil.kt.svg) } diff --git a/core/data/src/main/java/com/loodos/data/di/RemoteDataModule.kt b/core/data/src/main/java/com/loodos/data/di/RemoteDataModule.kt index 662b0b1..f25a674 100644 --- a/core/data/src/main/java/com/loodos/data/di/RemoteDataModule.kt +++ b/core/data/src/main/java/com/loodos/data/di/RemoteDataModule.kt @@ -1,6 +1,9 @@ package com.loodos.data.di import android.content.Context +import coil.ImageLoader +import coil.decode.SvgDecoder +import coil.util.DebugLogger import com.chuckerteam.chucker.api.ChuckerCollector import com.chuckerteam.chucker.api.ChuckerInterceptor import com.chuckerteam.chucker.api.RetentionManager @@ -11,6 +14,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent +import okhttp3.Call import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit @@ -90,4 +94,37 @@ object RemoteDataModule { fun provideLoginService(retrofit: Retrofit): AuthenticationService { return retrofit.create(AuthenticationService::class.java) } + + @Provides + @Singleton + fun provideOkHttpCallFactory(): Call.Factory = OkHttpClient.Builder() + .addInterceptor( + HttpLoggingInterceptor() + .apply { + if (BuildConfig.DEBUG) { + setLevel(HttpLoggingInterceptor.Level.BODY) + } + }, + ) + .build() + + @Provides + @Singleton + fun provideImageLoader( + okHttpCallFactory: Call.Factory, + @ApplicationContext application: Context, + ): ImageLoader = ImageLoader.Builder(application) + .callFactory(okHttpCallFactory) + .components { + add(SvgDecoder.Factory()) + } + // Assume most content images are versioned urls + // but some problematic images are fetching each time + .respectCacheHeaders(false) + .apply { + if (BuildConfig.DEBUG) { + logger(DebugLogger()) + } + } + .build() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9d8c10e..6eadc87 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -80,6 +80,7 @@ androidx-metrics = { group = "androidx.metrics", name = "metrics-performance", v androidx-room-testing = { group = "androidx.room", name = "room-testing", version.ref = "room" } androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" } androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidxTest" } +androidx-compose-ui-testManifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" } androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" } compose-material = { group = "androidx.compose.material3", name = "material3" }