diff --git a/.gitignore b/.gitignore index 93166e0..9038427 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ .externalNativeBuild .cxx local.properties +credentials.properties /*.apk /*.aab /app/release diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 46f7539..c245fd4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.Properties + @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { alias(libs.plugins.android.application) @@ -12,6 +14,15 @@ apply { from("$rootDir/base-module.gradle") } + +val credentialsPropertiesFile = rootProject.file("credentials.properties") +val credentialsProperties = Properties() +if (credentialsPropertiesFile.exists()) { + credentialsProperties.load(credentialsPropertiesFile.inputStream()) +} else { + throw GradleException("Missing credentials.properties file.") +} + android { compileSdk = AndroidConfig.compileSDK @@ -29,14 +40,19 @@ android { } buildTypes { - release { + getByName("debug") { isMinifyEnabled = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) + buildConfigField("String", "BASE_URL", "\"https://api.thecatapi.com/v1/\"") + buildConfigField("String", "CAT_API_KEY", "\"${credentialsProperties["CAT_API_KEY"]}\"") + } + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + buildConfigField("String", "BASE_URL", "\"https://api.thecatapi.com/v1/\"") + buildConfigField("String", "CAT_API_KEY", "\"${credentialsProperties["CAT_API_KEY"]}\"") } } + compileOptions { sourceCompatibility = AndroidConfig.javaVersion targetCompatibility = AndroidConfig.javaVersion @@ -48,6 +64,20 @@ android { compose = true buildConfig = true } + + packaging { + resources { + excludes += setOf( + "META-INF/LICENSE-notice.md", + "META-INF/LICENSE.md", + "META-INF/DEPENDENCIES", + "META-INF/NOTICE", + "META-INF/NOTICE.txt", + "META-INF/LICENSE.txt" + ) + } + } + composeOptions { kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() } diff --git a/app/src/main/java/com/aliumujib/catbrowser/MainActivity.kt b/app/src/main/java/com/aliumujib/catbrowser/MainActivity.kt index cb7e06a..6673333 100644 --- a/app/src/main/java/com/aliumujib/catbrowser/MainActivity.kt +++ b/app/src/main/java/com/aliumujib/catbrowser/MainActivity.kt @@ -92,7 +92,6 @@ class MainActivity : ComponentActivity() { StandardScaffold( navController = navController, items = getNavItems(context = this), - isLoggedIn = true, showBottomBar = route in listOf( "home/${BreedsScreenDestination.route}", "favorites/${FavoritesScreenDestination.route}", diff --git a/app/src/main/java/com/aliumujib/catbrowser/component/StandardScaffold.kt b/app/src/main/java/com/aliumujib/catbrowser/component/StandardScaffold.kt index c801251..05d1206 100644 --- a/app/src/main/java/com/aliumujib/catbrowser/component/StandardScaffold.kt +++ b/app/src/main/java/com/aliumujib/catbrowser/component/StandardScaffold.kt @@ -33,14 +33,13 @@ import com.ramcosta.composedestinations.spec.NavGraphSpec fun StandardScaffold( navController: NavController, showBottomBar: Boolean = true, - isLoggedIn: Boolean, items: List, content: @Composable (paddingValues: PaddingValues) -> Unit ) { Scaffold( bottomBar = { if (showBottomBar) { - val currentSelectedItem by navController.currentScreenAsState(isLoggedIn) + val currentSelectedItem by navController.currentScreenAsState() NavigationBar( containerColor = MaterialTheme.colorScheme.background, @@ -107,7 +106,7 @@ fun StandardScaffold( */ @Stable @Composable -fun NavController.currentScreenAsState(isLoggedIn: Boolean): State { +fun NavController.currentScreenAsState(): State { val selectedItem = remember { mutableStateOf(NavGraphs.home) } DisposableEffect(this) { diff --git a/app/src/main/java/com/aliumujib/catbrowser/di/BuildConfigModule.kt b/app/src/main/java/com/aliumujib/catbrowser/di/BuildConfigModule.kt index 6b8c893..3e9199c 100644 --- a/app/src/main/java/com/aliumujib/catbrowser/di/BuildConfigModule.kt +++ b/app/src/main/java/com/aliumujib/catbrowser/di/BuildConfigModule.kt @@ -21,8 +21,8 @@ object BuildConfigModule { buildType = BuildConfig.BUILD_TYPE, versionCode = BuildConfig.VERSION_CODE, versionName = BuildConfig.VERSION_NAME, - baseUrl = "https://api.thecatapi.com/v1/", - apiKey = "live_WRRSUbYuEPByUfgMPRWgq3lPRWWYBLNUwmtzHr5L7FAkCPynWDM23oldD5kNQFfm" + baseUrl = BuildConfig.BASE_URL, + apiKey = BuildConfig.CAT_API_KEY ) } diff --git a/base-module.gradle b/base-module.gradle index 4a056d3..e79eca2 100644 --- a/base-module.gradle +++ b/base-module.gradle @@ -69,9 +69,6 @@ dependencies { // Gson implementation(libs.retrofit.converter.gson) - // Lottie - api(libs.lottie.compose) - // Compose Paging implementation(libs.paging.runtime) diff --git a/core/network/src/main/java/com/aliumujib/network/di/NetworkModule.kt b/core/network/src/main/java/com/aliumujib/network/di/NetworkModule.kt index ccc5399..71d6696 100644 --- a/core/network/src/main/java/com/aliumujib/network/di/NetworkModule.kt +++ b/core/network/src/main/java/com/aliumujib/network/di/NetworkModule.kt @@ -21,9 +21,15 @@ object NetworkModule { @Singleton @Provides - fun provideLoggingInterceptor(): HttpLoggingInterceptor { + fun provideLoggingInterceptor(buildConfiguration: BuildConfiguration): HttpLoggingInterceptor { return HttpLoggingInterceptor() - .setLevel(HttpLoggingInterceptor.Level.BODY) + .apply { + if (buildConfiguration.debug) { + setLevel(HttpLoggingInterceptor.Level.BODY) + } else { + setLevel(HttpLoggingInterceptor.Level.NONE) + } + } } @Provides @@ -55,7 +61,10 @@ object NetworkModule { @Provides @Singleton - fun provideRetrofit(okHttpClient: OkHttpClient, buildConfiguration: BuildConfiguration): Retrofit { + fun provideRetrofit( + okHttpClient: OkHttpClient, + buildConfiguration: BuildConfiguration + ): Retrofit { return Retrofit.Builder() .baseUrl(buildConfiguration.baseUrl) .addConverterFactory(GsonConverterFactory.create()) @@ -65,7 +74,7 @@ object NetworkModule { @Provides @Singleton - fun provideMealDbApi(retrofit: Retrofit): CatAPIService { + fun provideCatApi(retrofit: Retrofit): CatAPIService { return retrofit.create() } } diff --git a/feature/breeds/breeds-data/src/main/java/com/aliumujib/songs/data/di/BreedsDataModule.kt b/feature/breeds/breeds-data/src/main/java/com/aliumujib/songs/data/di/BreedsDataModule.kt index 2c24f99..04e68db 100644 --- a/feature/breeds/breeds-data/src/main/java/com/aliumujib/songs/data/di/BreedsDataModule.kt +++ b/feature/breeds/breeds-data/src/main/java/com/aliumujib/songs/data/di/BreedsDataModule.kt @@ -1,6 +1,5 @@ package com.aliumujib.songs.data.di -import android.content.Context import com.aliumujib.database.dao.BreedsDAO import com.aliumujib.database.dao.FavoritesDAO import com.aliumujib.network.CatAPIService @@ -10,7 +9,6 @@ import com.aliumujib.songs.domain.repo.CatBreedsRepository import dagger.Module import dagger.Provides import dagger.hilt.InstallIn -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton @@ -21,7 +19,6 @@ object BreedsDataModule { @Provides @Singleton fun provideSongsRepository( - @ApplicationContext context: Context, songDao: BreedsDAO, favoritesDao: FavoritesDAO, catAPIService: CatAPIService, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3235a60..69481ba 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,39 +12,37 @@ hilt-compiler = "1.1.0" squigglyslider = "1.0.0" timber = "5.0.1" desugar-jdk-libs = "2.0.4" -compose = "1.6.7" -compose-compiler = "1.5.8" -coil = "2.5.0" -compose-activity = "1.8.2" +compose = "1.6.8" +coil = "2.6.0" +compose-activity = "1.9.0" compose-paging = "3.2.1" -compose-livedata = "1.5.4" +compose-livedata = "1.6.8" composeMaterial3 = "1.2.1" onebone = "2.3.5" mixpanel = "7.3.3" accompanist = "0.32.0" compose-destinations = "1.9.62" room = "2.6.1" -paging = "3.2.1" +paging = "3.3.0" datastore = "1.0.0" -lottie = "6.3.0" arch-core-testing = "2.2.0" -truth = "1.2.0" +truth = "1.4.2" leakcanary = "2.13" -junit-ext = "1.1.5" -espresso-core = "3.5.1" +junit-ext = "1.2.1" +espresso-core = "3.6.1" core-splash-screen = "1.0.1" -appcompat = "1.6.1" +appcompat = "1.7.0" chucker = "4.0.0" -material-icons-extended = "1.5.4" -compose-hilt-navigation = "1.1.0" -compose-lifecycle = "2.8.0" +material-icons-extended = "1.6.8" +compose-hilt-navigation = "1.2.0" +compose-lifecycle = "2.8.2" spotless = "6.24.0" -android-material = "1.11.0" +android-material = "1.12.0" konsist = "0.13.0" iconsax = "1.0.0" -kotlinx-coroutines-test = "1.6.1" -turbine = "0.7.0" -mockk = "1.12.0" +kotlinx-coroutines-test = "1.8.1" +turbine = "1.1.0" +mockk = "1.13.4" junit4 = "4.13.2" graphicsShapes = "1.0.0-beta01" media3Session = "1.3.1" @@ -52,6 +50,7 @@ media3Exoplayer = "1.3.1" retrofit = "2.11.0" okhttp = "5.0.0-alpha.12" fixture = "1.2.0" +compose-compiler = "1.5.8" [libraries] accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" } @@ -97,7 +96,6 @@ leakcanary-android = { group = "com.squareup.leakcanary", name = "leakcanary-and truth = { group = "com.google.truth", name = "truth", version.ref = "truth" } arch-core-testing = { group = "androidx.arch.core", name = "core-testing", version.ref = "arch-core-testing" } retrofit-converter-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit" } -lottie-compose = { group = "com.airbnb.android", name = "lottie-compose", version.ref = "lottie" } datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" } paging-runtime = { group = "androidx.paging", name = "paging-runtime", version.ref = "paging" } junit-ext = { group = "androidx.test.ext", name = "junit", version.ref = "junit-ext" }