diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d339a833..377ef50f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,9 +17,9 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("droidconke.android.hilt") - id("com.google.gms.google-services") - id("com.google.firebase.crashlytics") - id("com.google.firebase.firebase-perf") + id("droidconke.android.application.firebase") + id("org.jlleitschuh.gradle.ktlint") + id("io.gitlab.arturbosch.detekt") } android { @@ -85,8 +85,5 @@ dependencies { testImplementation(libs.bundles.test) - implementation(platform(libs.firebase.bom)) - implementation(libs.bundles.firebase) - coreLibraryDesugaring(libs.desugar.jdk.libs) } \ No newline at end of file diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index 37fc960f..1860b8f4 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -18,6 +18,8 @@ tasks.withType().configureEach dependencies { compileOnly(libs.android.gradlePlugin) compileOnly(libs.kotlin.gradlePlugin) + compileOnly(libs.firebase.crashlytics.gradlePlugin) + compileOnly(libs.firebase.performance.gradlePlugin) compileOnly(libs.ksp.gradlePlugin) } @@ -39,5 +41,13 @@ gradlePlugin { id = "droidconke.android.library.compose" implementationClass = "AndroidLibraryComposeConventionPlugin" } + register("androidFirebase") { + id = "droidconke.android.application.firebase" + implementationClass = "AndroidApplicationFirebaseConventionPlugin" + } + register("androidLibraryFirebase") { + id = "droidconke.android.library.firebase" + implementationClass = "AndroidLibraryFirebaseConventionPlugin" + } } } \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt new file mode 100644 index 00000000..d8f3ac24 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.android.build.api.dsl.ApplicationExtension +import com.android254.libs +import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies + +class AndroidApplicationFirebaseConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.google.gms.google-services") + apply("com.google.firebase.firebase-perf") + apply("com.google.firebase.crashlytics") + } + + dependencies { + + val bom = libs.findLibrary("firebase-bom").get() + add("implementation", platform(bom)) + "implementation"(libs.findLibrary("firebase.analytics").get()) + "implementation"(libs.findLibrary("firebase.performance").get()) + "implementation"(libs.findLibrary("firebase.crashlytics").get()) + "implementation"(libs.findLibrary("firebase.common").get()) + "implementation"(libs.findLibrary("firebase.remote.config").get()) + } + + extensions.configure { + buildTypes.configureEach { + // Disable the Crashlytics mapping file upload. This feature should only be + // enabled if a Firebase backend is available and configured in + // google-services.json. + configure { + mappingFileUploadEnabled = false + } + } + } + } + } +} \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryFirebaseConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryFirebaseConventionPlugin.kt new file mode 100644 index 00000000..047ee54b --- /dev/null +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryFirebaseConventionPlugin.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.android.build.api.dsl.ApplicationExtension +import com.android254.libs +import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies + +class AndroidLibraryFirebaseConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + dependencies { + + val bom = libs.findLibrary("firebase-bom").get() + add("implementation", platform(bom)) + "implementation"(libs.findLibrary("firebase.common").get()) + "implementation"(libs.findLibrary("firebase.remote.config").get()) + } + } + } +} \ No newline at end of file diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 71589f68..020618b5 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -17,6 +17,7 @@ plugins { id("droidconke.android.library") id("droidconke.android.room") id("droidconke.android.hilt") + id("droidconke.android.library.firebase") kotlin("plugin.serialization") } @@ -53,8 +54,6 @@ dependencies { implementation(libs.ktor.auth) implementation(libs.ktor.logging) implementation(libs.ktor.okhttp) - implementation(platform(libs.firebase.bom)) - implementation(libs.bundles.firebase) releaseImplementation(libs.chucker.release) debugImplementation(libs.chucker.debug) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 82f58a1a..20cc3e31 100755 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,11 +11,14 @@ lifecycle = "2.5.1" room = "2.5.0" ktor = "2.2.2" splash = "1.0.0" +firebaseCrashlyticsPlugin = "2.9.2" +firebasePerfPlugin = "1.4.2" junit4 = "4.13.2" agp = "7.4.1" chucker = "3.5.2" ksp = "1.8.20-1.0.11" androidxComposeBom = "2023.06.01" +remote_config = "21.4.1" [libraries] android-appCompat = "androidx.appcompat:appcompat:1.6.1" @@ -83,12 +86,14 @@ ktor-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = ktor-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" } ktor-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" } -firebase-bom = "com.google.firebase:firebase-bom:31.2.2" +firebase-bom = "com.google.firebase:firebase-bom:32.2.0" firebase-messaging = { module = "com.google.firebase:firebase-messaging-ktx" } firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics-ktx" } firebase-analytics = { module = "com.google.firebase:firebase-analytics-ktx" } firebase-performance = { module = "com.google.firebase:firebase-perf-ktx" } firebase-config = { module = "com.google.firebase:firebase-config-ktx" } +firebase-remote-config = { module = "com.google.firebase:firebase-config-ktx", version.ref = "remote_config" } +firebase-common = "com.google.firebase:firebase-common-ktx:20.3.3" chucker-debug = { module = "com.github.chuckerteam.chucker:library", version.ref = "chucker" } chucker-release = { module = "com.github.chuckerteam.chucker:library-no-op", version.ref = "chucker" } @@ -99,6 +104,8 @@ test-junit-ktx = "androidx.test.ext:junit-ktx:1.1.5" junit4 = { group = "junit", name = "junit", version.ref = "junit4" } # Dependencies of the included build-logic +firebase-crashlytics-gradlePlugin = { group = "com.google.firebase", name = "firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsPlugin" } +firebase-performance-gradlePlugin = { group = "com.google.firebase", name = "perf-plugin", version.ref = "firebasePerfPlugin" } android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } ksp-gradlePlugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } @@ -108,7 +115,7 @@ compose = ["coil-compose", "compose-activity", "compose-compiler", "compose-mate lifecycle = ["lifecycle-livedataKtx", "lifecycle-runtimeKtx", "lifecycle-viewmodel-compose"] room = ["room-ktx", "room-paging", "room-runtime"] ktor = ["ktor-core", "ktor-android", "ktor-json", "ktor-content-negotiation"] -firebase = ["firebase-messaging", "firebase-crashlytics", "firebase-analytics", "firebase-performance", "firebase-config"] +firebase = ["firebase-messaging", "firebase-crashlytics", "firebase-analytics", "firebase-performance", "firebase-remote-config", "firebase-common"] test = ["junit4", "test-junit-ktx"] [plugins] diff --git a/presentation/src/main/java/com/android254/presentation/feed/view/FeedScreen.kt b/presentation/src/main/java/com/android254/presentation/feed/view/FeedScreen.kt index 4bb4b85e..e8be2433 100644 --- a/presentation/src/main/java/com/android254/presentation/feed/view/FeedScreen.kt +++ b/presentation/src/main/java/com/android254/presentation/feed/view/FeedScreen.kt @@ -57,7 +57,8 @@ fun FeedScreen( feedViewModel: FeedViewModel = hiltViewModel() ) { val bottomSheetState = rememberModalBottomSheetState( - skipPartiallyExpanded= true) + skipPartiallyExpanded = true + ) val scope = rememberCoroutineScope() feedViewModel.fetchFeed() val feedUIState = feedViewModel.viewState