From aa5d254435ee6f89c4b54e643c4812b3f9e17d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= Date: Tue, 9 Aug 2022 15:41:35 +0200 Subject: [PATCH 1/2] Use [plugins] block in version catalog Change-Id: Ib2aa30405dfe8e5f5017f2f1b45e972d8e19ddca --- build-logic/convention/build.gradle.kts | 6 +++--- build.gradle.kts | 16 +++++++++------- gradle/libs.versions.toml | 19 +++++++++++++------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index a7841103f..52dfeafb5 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -26,9 +26,9 @@ java { } dependencies { - implementation(libs.android.gradlePlugin) - implementation(libs.kotlin.gradlePlugin) - implementation(libs.spotless.gradlePlugin) + compileOnly(libs.android.gradlePlugin) + compileOnly(libs.kotlin.gradlePlugin) + compileOnly(libs.spotless.gradlePlugin) } gradlePlugin { diff --git a/build.gradle.kts b/build.gradle.kts index 7543f4e20..d418a768c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,11 +23,13 @@ buildscript { maven { url = uri("../nowinandroid-prebuilts/m2repository") } } - dependencies { - classpath(libs.android.gradlePlugin) - classpath(libs.kotlin.gradlePlugin) - classpath(libs.kotlin.serializationPlugin) - classpath(libs.hilt.gradlePlugin) - classpath(libs.secrets.gradlePlugin) - } } + +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.hilt) apply false + alias(libs.plugins.secrets) apply false + alias(libs.plugins.spotless) apply false +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a58115498..2e5448415 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -51,7 +51,6 @@ turbine = "0.8.0" [libraries] accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanist" } android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" } -android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } androidx-benchmark-macro = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "androidxMacroBenchmark" } @@ -98,10 +97,7 @@ hilt-ext-work = { group = "androidx.hilt", name = "hilt-work", version.ref = "hi hilt-ext-compiler = { group = "androidx.hilt", name = "hilt-compiler", version.ref = "hiltExt" } hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" } -hilt-gradlePlugin = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "hilt" } junit4 = { group = "junit", name = "junit", version.ref = "junit4" } -kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } -kotlin-serializationPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } @@ -118,9 +114,20 @@ retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "re room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" } room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } -secrets-gradlePlugin = { group = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", name = "secrets-gradle-plugin", version.ref = "secrets" } + +# Dependencies of the included build-logic +android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } +kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } spotless-gradlePlugin = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" } [plugins] -protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } +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" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } +secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } From 728fe630865af58b9be8ec0dd96c4d6ace6f22c8 Mon Sep 17 00:00:00 2001 From: Simona Stojanovic Date: Fri, 19 Aug 2022 14:02:52 +0100 Subject: [PATCH 2/2] Fix Lazy grid item paddings Change-Id: I3441ed1964d9f680fcef468d4209fc1fdec55a24 --- .../feature/foryou/ForYouScreen.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt index f53525e36..f4ad00aed 100644 --- a/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt +++ b/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt @@ -62,6 +62,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.layout import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.testTag @@ -177,7 +178,7 @@ fun ForYouScreen( LazyVerticalGrid( columns = Adaptive(300.dp), contentPadding = PaddingValues(16.dp), - horizontalArrangement = Arrangement.spacedBy(32.dp), + horizontalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(24.dp), modifier = modifier .padding(innerPadding) @@ -190,7 +191,19 @@ fun ForYouScreen( interestsSelectionState = interestsSelectionState, onAuthorCheckedChanged = onAuthorCheckedChanged, onTopicCheckedChanged = onTopicCheckedChanged, - saveFollowedTopics = saveFollowedTopics + saveFollowedTopics = saveFollowedTopics, + // Custom LayoutModifier to remove the enforced parent 16.dp contentPadding + // from the LazyVerticalGrid and enable edge-to-edge scrolling for this section + interestsItemModifier = Modifier.layout { measurable, constraints -> + val placeable = measurable.measure( + constraints.copy( + maxWidth = constraints.maxWidth + 32.dp.roundToPx() + ) + ) + layout(placeable.width, placeable.height) { + placeable.place(0, 0) + } + } ) newsFeed( @@ -223,7 +236,8 @@ private fun LazyGridScope.interestsSelection( interestsSelectionState: ForYouInterestsSelectionUiState, onAuthorCheckedChanged: (String, Boolean) -> Unit, onTopicCheckedChanged: (String, Boolean) -> Unit, - saveFollowedTopics: () -> Unit + saveFollowedTopics: () -> Unit, + interestsItemModifier: Modifier = Modifier ) { when (interestsSelectionState) { ForYouInterestsSelectionUiState.Loading -> { @@ -240,7 +254,7 @@ private fun LazyGridScope.interestsSelection( ForYouInterestsSelectionUiState.NoInterestsSelection -> Unit is ForYouInterestsSelectionUiState.WithInterestsSelection -> { item(span = { GridItemSpan(maxLineSpan) }) { - Column { + Column(modifier = interestsItemModifier) { Text( text = stringResource(R.string.onboarding_guidance_title), textAlign = TextAlign.Center,