Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aliumujib committed Jul 1, 2024
1 parent f152c06 commit 9bf9773
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.externalNativeBuild
.cxx
local.properties
credentials.properties
/*.apk
/*.aab
/app/release
Expand Down
40 changes: 35 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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()
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/aliumujib/catbrowser/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ import com.ramcosta.composedestinations.spec.NavGraphSpec
fun StandardScaffold(
navController: NavController,
showBottomBar: Boolean = true,
isLoggedIn: Boolean,
items: List<BottomNavItem>,
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,
Expand Down Expand Up @@ -107,7 +106,7 @@ fun StandardScaffold(
*/
@Stable
@Composable
fun NavController.currentScreenAsState(isLoggedIn: Boolean): State<NavGraphSpec> {
fun NavController.currentScreenAsState(): State<NavGraphSpec> {
val selectedItem = remember { mutableStateOf(NavGraphs.home) }

DisposableEffect(this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
3 changes: 0 additions & 3 deletions base-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ dependencies {
// Gson
implementation(libs.retrofit.converter.gson)

// Lottie
api(libs.lottie.compose)

// Compose Paging
implementation(libs.paging.runtime)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -65,7 +74,7 @@ object NetworkModule {

@Provides
@Singleton
fun provideMealDbApi(retrofit: Retrofit): CatAPIService {
fun provideCatApi(retrofit: Retrofit): CatAPIService {
return retrofit.create()
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -21,7 +19,6 @@ object BreedsDataModule {
@Provides
@Singleton
fun provideSongsRepository(
@ApplicationContext context: Context,
songDao: BreedsDAO,
favoritesDao: FavoritesDAO,
catAPIService: CatAPIService,
Expand Down
36 changes: 17 additions & 19 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,45 @@ 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"
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" }
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 9bf9773

Please sign in to comment.