From 13a6f857fa8b4b26ff462b172097f96d7f638dfa Mon Sep 17 00:00:00 2001 From: Don Turner Date: Tue, 2 May 2023 23:53:04 +0100 Subject: [PATCH 01/20] Change JAVA_HOME path to use JDK 17 from prebuilts repo Change-Id: I91933628d32de2a703c4a6955827044533dd7cdd --- build_android_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_android_release.sh b/build_android_release.sh index c7e5fc835..3817d4cda 100755 --- a/build_android_release.sh +++ b/build_android_release.sh @@ -21,7 +21,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" APP_OUT=$DIR/app/build/outputs -export JAVA_HOME="$(cd $DIR/../../../prebuilts/studio/jdk/jdk11/linux && pwd )" +export JAVA_HOME="$(cd $DIR/../nowinandroid-prebuilts/jdk17/linux && pwd )" echo "JAVA_HOME=$JAVA_HOME" export ANDROID_HOME="$(cd $DIR/../../../prebuilts/fullsdk/linux && pwd )" From 8c9f656eec0ecfa31b6c695416964b4e928aeccc Mon Sep 17 00:00:00 2001 From: Don Turner Date: Thu, 4 May 2023 12:04:46 +0100 Subject: [PATCH 02/20] Add path to JDK 17 Change-Id: If6fd6fab4517242f7bad9149ae2fdbdbbca7ef34 --- kokoro/build.sh | 5 ++++- kokoro/continuous.cfg | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kokoro/build.sh b/kokoro/build.sh index c217e995c..456752516 100755 --- a/kokoro/build.sh +++ b/kokoro/build.sh @@ -36,7 +36,10 @@ echo y | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses cd $KOKORO_ARTIFACTS_DIR/git/nowinandroid # The build needs Java 17, set it as the default Java version. -sudo update-java-alternatives --set java-1.17.0-openjdk-amd64 +sudo apt-get update +sudo apt-get install -y openjdk-17-jdk +sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java +java -version # Also clear JAVA_HOME variable so java -version is used instead export JAVA_HOME= diff --git a/kokoro/continuous.cfg b/kokoro/continuous.cfg index e0db4f172..b7f4c4ac8 100644 --- a/kokoro/continuous.cfg +++ b/kokoro/continuous.cfg @@ -1,2 +1,4 @@ # Location of the bash script. -build_file: "nowinandroid/kokoro/build.sh" \ No newline at end of file +build_file: "nowinandroid/kokoro/build.sh" + +gfile_resources: "/x20/projects/java-platform/linux-amd64/jdk-17-latest" \ No newline at end of file From db5198f08546fa53c9996c091085a6ac17b4fe31 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Thu, 4 May 2023 15:49:06 +0100 Subject: [PATCH 03/20] Remove path to JDK 17 (this is installed using apt instead) Change-Id: I6650999f5f750366d2c7277614e26cbb05828b98 --- kokoro/continuous.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kokoro/continuous.cfg b/kokoro/continuous.cfg index b7f4c4ac8..e0db4f172 100644 --- a/kokoro/continuous.cfg +++ b/kokoro/continuous.cfg @@ -1,4 +1,2 @@ # Location of the bash script. -build_file: "nowinandroid/kokoro/build.sh" - -gfile_resources: "/x20/projects/java-platform/linux-amd64/jdk-17-latest" \ No newline at end of file +build_file: "nowinandroid/kokoro/build.sh" \ No newline at end of file From 0829cb73f732c65e45a048497a062eaaad2b6ae6 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Tue, 9 May 2023 17:05:59 +0100 Subject: [PATCH 04/20] Bump version name to 0.1.0 (versionCode 6) Change-Id: I880683a37b4324f91499eeb47b418ab5e2d1242b --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e172ed8bb..00568cce7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,8 +28,8 @@ plugins { android { defaultConfig { applicationId = "com.google.samples.apps.nowinandroid" - versionCode = 5 - versionName = "0.0.5" // X.Y.Z; X = Major, Y = minor, Z = Patch level + versionCode = 6 + versionName = "0.1.0" // X.Y.Z; X = Major, Y = minor, Z = Patch level // Custom test runner to set up Hilt dependency graph testInstrumentationRunner = "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner" From 3114b2eeaac6afd5a72f5750a16b67a5bb8d80e4 Mon Sep 17 00:00:00 2001 From: ahmedmadhoun1 Date: Thu, 29 Jun 2023 15:47:25 +0300 Subject: [PATCH 05/20] Allow localised date format --- .../samples/apps/nowinandroid/core/ui/NewsResourceCard.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt index 009fb1249..c9a327881 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt @@ -70,6 +70,7 @@ import kotlinx.datetime.Instant import kotlinx.datetime.toJavaInstant import java.time.ZoneId import java.time.format.DateTimeFormatter +import java.time.format.FormatStyle import java.util.Locale import com.google.samples.apps.nowinandroid.core.designsystem.R as DesignsystemR @@ -230,8 +231,11 @@ fun dateFormatted(publishDate: Instant): String { } } - return DateTimeFormatter.ofPattern("MMM d, yyyy") - .withZone(zoneId).format(publishDate.toJavaInstant()) + return DateTimeFormatter + .ofLocalizedDate(FormatStyle.MEDIUM) + .withLocale(Locale.getDefault()) + .withZone(zoneId) + .format(publishDate.toJavaInstant()) } @Composable From 7dc03367117ae153a3a9a3584d0f8daebbdd9b70 Mon Sep 17 00:00:00 2001 From: Murat Yener Date: Thu, 29 Jun 2023 15:04:12 -0700 Subject: [PATCH 06/20] Ads PowerMetric benchmark which scrolls through the topics list in Light vs Dark theme --- .../interests/InterestsActions.kt | 14 ++++ .../ScrollTopicListPowerMetricsBenchmark.kt | 82 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt index e94369ce2..7bc1feaae 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt @@ -48,3 +48,17 @@ fun MacrobenchmarkScope.interestsToggleBookmarked() { checkable.click() device.waitForIdle() } + +fun MacrobenchmarkScope.setAppTheme(isDark: Boolean) { + when (isDark){ + true -> device.findObject(By.text("Dark")).click() + false -> device.findObject(By.text("Light")).click() + } + device.waitForIdle() + device.findObject(By.text("OK")).click() + + // Wait until interests are shown on screen + device.wait(Until.hasObject(By.res("niaTopAppBar")), 2_000) + val topAppBar = device.findObject(By.res("niaTopAppBar")) + topAppBar.wait(Until.hasObject(By.text("Now in Android")), 2_000) +} diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt new file mode 100644 index 000000000..4a996a9d6 --- /dev/null +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2023 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. + */ + +package com.google.samples.apps.nowinandroid.interests + +import android.os.Build.VERSION_CODES +import androidx.annotation.RequiresApi +import androidx.benchmark.macro.CompilationMode +import androidx.benchmark.macro.ExperimentalMetricApi +import androidx.benchmark.macro.FrameTimingMetric +import androidx.benchmark.macro.PowerCategory +import androidx.benchmark.macro.PowerCategoryDisplayLevel +import androidx.benchmark.macro.PowerMetric +import androidx.benchmark.macro.StartupMode +import androidx.benchmark.macro.junit4.MacrobenchmarkRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.uiautomator.By +import com.google.samples.apps.nowinandroid.PACKAGE_NAME +import com.google.samples.apps.nowinandroid.allowNotifications +import com.google.samples.apps.nowinandroid.foryou.forYouScrollFeedDownUp +import com.google.samples.apps.nowinandroid.foryou.forYouSelectTopics +import com.google.samples.apps.nowinandroid.foryou.forYouWaitForContent +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@OptIn(ExperimentalMetricApi::class) +@RequiresApi(VERSION_CODES.Q) +@RunWith(AndroidJUnit4::class) +class ScrollTopicListPowerMetricsBenchmark { + @get:Rule + val benchmarkRule = MacrobenchmarkRule() + + private val categories = PowerCategory.values() + .associateWith { PowerCategoryDisplayLevel.TOTAL } + + @Test + fun benchmarkStateChangeCompilationLight() = + benchmarkStateChangeWithTheme(CompilationMode.Partial(), false) + + @Test + fun benchmarkStateChangeCompilationDark() = + benchmarkStateChangeWithTheme(CompilationMode.Partial(), true) + + private fun benchmarkStateChangeWithTheme(compilationMode: CompilationMode, isDark: Boolean) = + benchmarkRule.measureRepeated( + packageName = PACKAGE_NAME, + metrics = listOf(FrameTimingMetric(), PowerMetric(PowerMetric.Energy(categories))), + compilationMode = compilationMode, + iterations = 2, + startupMode = StartupMode.WARM, + setupBlock = { + // Start the app + pressHome() + startActivityAndWait() + allowNotifications() + // Navigate to interests screen + device.findObject(By.desc("Settings")).click() + device.waitForIdle() + setAppTheme(isDark) + }, + ) { + forYouWaitForContent() + forYouSelectTopics() + repeat(3) { + forYouScrollFeedDownUp() + } + } +} From f79b19c3779d6dd683f51b72ffa2c66431219080 Mon Sep 17 00:00:00 2001 From: Murat Yener Date: Thu, 29 Jun 2023 15:10:42 -0700 Subject: [PATCH 07/20] Spotless fixes --- .../interests/InterestsActions.kt | 2 +- .../ScrollTopicListPowerMetricsBenchmark.kt | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt index 7bc1feaae..a6420a7fd 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt @@ -50,7 +50,7 @@ fun MacrobenchmarkScope.interestsToggleBookmarked() { } fun MacrobenchmarkScope.setAppTheme(isDark: Boolean) { - when (isDark){ + when (isDark) { true -> device.findObject(By.text("Dark")).click() false -> device.findObject(By.text("Light")).click() } diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt index 4a996a9d6..8ede75e4b 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt @@ -1,17 +1,17 @@ /* - * Copyright 2023 The Android Open Source Project + * 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 + * 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 + * 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. + * 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. */ package com.google.samples.apps.nowinandroid.interests From 445c18a80363bb03fc3d3d39f2620652fa145699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Moczkowski?= Date: Wed, 5 Jul 2023 13:18:57 +0200 Subject: [PATCH 08/20] Refactor InterestsItem to Material3 ListItem Change-Id: I12adc8820964aecd97ea0b4e22ae13e95e1428ab --- .../feature/interests/InterestsItem.kt | 101 +++++++----------- .../feature/search/SearchScreenTest.kt | 24 +++-- 2 files changed, 56 insertions(+), 69 deletions(-) diff --git a/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt b/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt index ec9fd8f10..7456ba92b 100644 --- a/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt +++ b/feature/interests/src/main/java/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt @@ -18,22 +18,20 @@ package com.google.samples.apps.nowinandroid.feature.interests import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.material3.Icon +import androidx.compose.material3.ListItem +import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.google.samples.apps.nowinandroid.core.designsystem.component.DynamicAsyncImage import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaIconToggleButton @@ -51,63 +49,46 @@ fun InterestsItem( modifier: Modifier = Modifier, iconModifier: Modifier = Modifier, description: String = "", - itemSeparation: Dp = 16.dp, ) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = modifier, - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .weight(1f) - .clickable { onClick() } - .padding(vertical = itemSeparation), - ) { + ListItem( + leadingContent = { InterestsIcon(topicImageUrl, iconModifier.size(64.dp)) - Spacer(modifier = Modifier.width(24.dp)) - InterestContent(name, description) - } - NiaIconToggleButton( - checked = following, - onCheckedChange = onFollowButtonClick, - icon = { - Icon( - imageVector = NiaIcons.Add, - contentDescription = stringResource( - id = string.card_follow_button_content_desc, - ), - ) - }, - checkedIcon = { - Icon( - imageVector = NiaIcons.Check, - contentDescription = stringResource( - id = string.card_unfollow_button_content_desc, - ), - ) - }, - ) - } -} - -@Composable -private fun InterestContent(name: String, description: String, modifier: Modifier = Modifier) { - Column(modifier) { - Text( - text = name, - style = MaterialTheme.typography.headlineSmall, - modifier = Modifier.padding( - vertical = if (description.isEmpty()) 0.dp else 4.dp, - ), - ) - if (description.isNotEmpty()) { - Text( - text = description, - style = MaterialTheme.typography.bodyMedium, + }, + headlineContent = { + Text(text = name) + }, + supportingContent = { + Text(text = description) + }, + trailingContent = { + NiaIconToggleButton( + checked = following, + onCheckedChange = onFollowButtonClick, + icon = { + Icon( + imageVector = NiaIcons.Add, + contentDescription = stringResource( + id = string.card_follow_button_content_desc, + ), + ) + }, + checkedIcon = { + Icon( + imageVector = NiaIcons.Check, + contentDescription = stringResource( + id = string.card_unfollow_button_content_desc, + ), + ) + }, ) - } - } + }, + colors = ListItemDefaults.colors( + containerColor = Color.Transparent, + ), + modifier = modifier + .semantics(mergeDescendants = true) { /* no-op */ } + .clickable(enabled = true, onClick = onClick), + ) } @Composable diff --git a/feature/search/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt b/feature/search/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt index 53f00c0dc..d6c07221e 100644 --- a/feature/search/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt +++ b/feature/search/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt @@ -20,11 +20,14 @@ import androidx.activity.ComponentActivity import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsFocused +import androidx.compose.ui.test.hasScrollToNodeAction import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onAllNodesWithContentDescription +import androidx.compose.ui.test.onFirst import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performScrollToIndex import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.DARK import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.ANDROID @@ -139,15 +142,18 @@ class SearchScreenTest { composeTestRule .onNodeWithText(topicsString) .assertIsDisplayed() - composeTestRule - .onNodeWithText(followableTopicTestData[0].topic.name) - .assertIsDisplayed() - composeTestRule - .onNodeWithText(followableTopicTestData[1].topic.name) - .assertIsDisplayed() - composeTestRule - .onNodeWithText(followableTopicTestData[2].topic.name) - .assertIsDisplayed() + + val scrollableNode = composeTestRule + .onAllNodes(hasScrollToNodeAction()) + .onFirst() + + followableTopicTestData.forEachIndexed { index, followableTopic -> + scrollableNode.performScrollToIndex(index) + + composeTestRule + .onNodeWithText(followableTopic.topic.name) + .assertIsDisplayed() + } composeTestRule .onAllNodesWithContentDescription(followButtonContentDesc) From 14e53e2bb7e1ba7b60f304d0712023e1788fe011 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Fri, 7 Jul 2023 14:48:35 +0100 Subject: [PATCH 09/20] Remove problematic API 23 device from FTL tests Change-Id: I85b3979ffda637d558f071ac10663f5578f85db7 --- kokoro/nightly.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kokoro/nightly.sh b/kokoro/nightly.sh index 94946020e..1423f4f44 100755 --- a/kokoro/nightly.sh +++ b/kokoro/nightly.sh @@ -21,12 +21,11 @@ set -e set -x # Run the normal build, but replace the default virtual devices with physical ones. -# hammerhead | Nexus 5 | API 23 | Phone # walleye | Pixel 2 | API 27 | Phone # gts4lltevzw | Galaxy Tab S4 | API 28 | Tablet # a10 | Samsung A10 | API 29 | Phone # redfin | Pixel 5e | API 30 | Phone # oriole | Pixel 6 | API 31 | Phone -bash $KOKORO_ARTIFACTS_DIR/git/nowinandroid/kokoro/build.sh "hammerhead,walleye,gts4lltevzw,a10,redfin,oriole" "23,27,28,29,30,31" +bash $KOKORO_ARTIFACTS_DIR/git/nowinandroid/kokoro/build.sh "walleye,gts4lltevzw,a10,redfin,oriole" "27,28,29,30,31" exit $? From 2731e9817b620598a7de0f8899612f0e771c9aa4 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Sun, 9 Jul 2023 10:44:40 +0200 Subject: [PATCH 10/20] Kotlin 1.9.0 - https://github.com/JetBrains/kotlin/releases/tag/v1.9.0 - https://github.com/google/ksp/releases/tag/1.9.0-1.0.11 - Compose compiler `1.5.0-dev-k1.9.0-6a60475e07f` --- gradle/libs.versions.toml | 6 +++--- settings.gradle.kts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 20afadb36..be13af451 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ androidxActivity = "1.7.0" androidxAppCompat = "1.5.1" androidxBrowser = "1.4.0" androidxComposeBom = "2023.06.01" -androidxComposeCompiler = "1.4.8" +androidxComposeCompiler = "1.5.0-dev-k1.9.0-6a60475e07f" androidxComposeRuntimeTracing = "1.0.0-alpha03" androidxCore = "1.9.0" androidxCoreSplashscreen = "1.0.0" @@ -38,11 +38,11 @@ hilt = "2.46.1" hiltExt = "1.0.0" jacoco = "0.8.7" junit4 = "4.13.2" -kotlin = "1.8.22" +kotlin = "1.9.0" kotlinxCoroutines = "1.6.4" kotlinxDatetime = "0.4.0" kotlinxSerializationJson = "1.5.1" -ksp = "1.8.22-1.0.11" +ksp = "1.9.0-1.0.11" lint = "30.3.1" okhttp = "4.10.0" protobuf = "3.23.0" diff --git a/settings.gradle.kts b/settings.gradle.kts index d0c477b3d..390416cfb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,6 +28,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven("https://androidx.dev/storage/compose-compiler/repository/") } } rootProject.name = "nowinandroid" From e18f7cb3764cbaf30658ed2944230f10d2f2c258 Mon Sep 17 00:00:00 2001 From: Murat Yener Date: Mon, 10 Jul 2023 16:18:30 -0700 Subject: [PATCH 11/20] addressed comments --- .../apps/nowinandroid/foryou/ForYouActions.kt | 14 ++++++++++++++ .../nowinandroid/interests/InterestsActions.kt | 14 -------------- .../ScrollTopicListPowerMetricsBenchmark.kt | 5 +++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt index 5e4952fbb..8599bddd0 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt @@ -88,3 +88,17 @@ fun MacrobenchmarkScope.forYouScrollFeedDownUp() { val feedList = device.findObject(By.res("forYou:feed")) device.flingElementDownUp(feedList) } + +fun MacrobenchmarkScope.setAppTheme(isDark: Boolean) { + when (isDark) { + true -> device.findObject(By.text("Dark")).click() + false -> device.findObject(By.text("Light")).click() + } + device.waitForIdle() + device.findObject(By.text("OK")).click() + + // Wait until the top app bar is visible on screen + device.wait(Until.hasObject(By.res("niaTopAppBar")), 2_000) + val topAppBar = device.findObject(By.res("niaTopAppBar")) + topAppBar.wait(Until.hasObject(By.text("Now in Android")), 2_000) +} diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt index a6420a7fd..e94369ce2 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt @@ -48,17 +48,3 @@ fun MacrobenchmarkScope.interestsToggleBookmarked() { checkable.click() device.waitForIdle() } - -fun MacrobenchmarkScope.setAppTheme(isDark: Boolean) { - when (isDark) { - true -> device.findObject(By.text("Dark")).click() - false -> device.findObject(By.text("Light")).click() - } - device.waitForIdle() - device.findObject(By.text("OK")).click() - - // Wait until interests are shown on screen - device.wait(Until.hasObject(By.res("niaTopAppBar")), 2_000) - val topAppBar = device.findObject(By.res("niaTopAppBar")) - topAppBar.wait(Until.hasObject(By.text("Now in Android")), 2_000) -} diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt index 8ede75e4b..13c6f55e3 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/interests/ScrollTopicListPowerMetricsBenchmark.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2023 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. @@ -33,6 +33,7 @@ import com.google.samples.apps.nowinandroid.allowNotifications import com.google.samples.apps.nowinandroid.foryou.forYouScrollFeedDownUp import com.google.samples.apps.nowinandroid.foryou.forYouSelectTopics import com.google.samples.apps.nowinandroid.foryou.forYouWaitForContent +import com.google.samples.apps.nowinandroid.foryou.setAppTheme import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -67,7 +68,7 @@ class ScrollTopicListPowerMetricsBenchmark { pressHome() startActivityAndWait() allowNotifications() - // Navigate to interests screen + // Navigate to Settings device.findObject(By.desc("Settings")).click() device.waitForIdle() setAppTheme(isDark) From 7f62b725a6e3cb0a607af62d06ea6583b463912b Mon Sep 17 00:00:00 2001 From: Don Turner Date: Thu, 13 Jul 2023 11:34:45 +0100 Subject: [PATCH 12/20] Bump version to code=7, name=0.1.1 Change-Id: I2d8fa940dc5e4c14e3c9df650bc1f1432a330f02 --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1a1450258..c3c0aca4f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -29,8 +29,8 @@ plugins { android { defaultConfig { applicationId = "com.google.samples.apps.nowinandroid" - versionCode = 6 - versionName = "0.1.0" // X.Y.Z; X = Major, Y = minor, Z = Patch level + versionCode = 7 + versionName = "0.1.1" // X.Y.Z; X = Major, Y = minor, Z = Patch level // Custom test runner to set up Hilt dependency graph testInstrumentationRunner = "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner" From aa66cbb596e1b76f288d9e39cf0fbe3eed732503 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Sun, 16 Jul 2023 22:33:37 +0200 Subject: [PATCH 13/20] allow notifications --- .../samples/apps/nowinandroid/startup/StartupBenchmark.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt index 8e396eda3..dd79b319f 100644 --- a/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt +++ b/benchmarks/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt @@ -27,6 +27,7 @@ import androidx.benchmark.macro.StartupTimingMetric import androidx.benchmark.macro.junit4.MacrobenchmarkRule import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner import com.google.samples.apps.nowinandroid.PACKAGE_NAME +import com.google.samples.apps.nowinandroid.allowNotifications import com.google.samples.apps.nowinandroid.foryou.forYouWaitForContent import org.junit.Rule import org.junit.Test @@ -86,6 +87,7 @@ abstract class AbstractStartupBenchmark(private val startupMode: StartupMode) { }, ) { startActivityAndWait() + allowNotifications() // Waits until the content is ready to capture Time To Full Display forYouWaitForContent() } From f7ed38182d5fdd101b02279e9aa879b38751154d Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Thu, 25 May 2023 21:17:52 +0200 Subject: [PATCH 14/20] Add protobuf generated sources to the sourceSets And update to version 3.23.4. --- core/datastore/build.gradle.kts | 7 +++++++ gradle/libs.versions.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index a9ec7a78f..d6ca7ebcd 100644 --- a/core/datastore/build.gradle.kts +++ b/core/datastore/build.gradle.kts @@ -52,6 +52,13 @@ protobuf { } } +androidComponents.beforeVariants { + android.sourceSets.register(it.name) { + java.srcDir(buildDir.resolve("generated/source/proto/${it.name}/java")) + kotlin.srcDir(buildDir.resolve("generated/source/proto/${it.name}/kotlin")) + } +} + dependencies { implementation(project(":core:common")) implementation(project(":core:model")) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index be13af451..bb356f006 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -45,7 +45,7 @@ kotlinxSerializationJson = "1.5.1" ksp = "1.9.0-1.0.11" lint = "30.3.1" okhttp = "4.10.0" -protobuf = "3.23.0" +protobuf = "3.23.4" protobufPlugin = "0.9.3" retrofit = "2.9.0" retrofitKotlinxSerializationJson = "1.0.0" From ba82b06cc3cc1a169d8adead9584aea42e3781b7 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Sun, 9 Jul 2023 11:22:15 +0200 Subject: [PATCH 15/20] Fix Lint `RememberReturnType` issue with explicit type --- .../com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt index 2457af900..1560a74eb 100644 --- a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt +++ b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt @@ -183,7 +183,7 @@ class NiaAppStateTest { @Composable private fun rememberTestNavController(): TestNavHostController { val context = LocalContext.current - val navController = remember { + return remember { TestNavHostController(context).apply { navigatorProvider.addNavigator(ComposeNavigator()) graph = createGraph(startDestination = "a") { @@ -193,5 +193,4 @@ private fun rememberTestNavController(): TestNavHostController { } } } - return navController } From bc0a7e63a13bbaf2c0ace7d25e236ad2906cbc96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Braun?= Date: Wed, 19 Jul 2023 09:18:51 +0200 Subject: [PATCH 16/20] Update Compose compiler version to 1.5.0 Change-Id: Ieddb8410a592bb38c5764b7288fd4828306d6743 --- gradle/libs.versions.toml | 2 +- settings.gradle.kts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bb356f006..2dd3f379d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ androidxActivity = "1.7.0" androidxAppCompat = "1.5.1" androidxBrowser = "1.4.0" androidxComposeBom = "2023.06.01" -androidxComposeCompiler = "1.5.0-dev-k1.9.0-6a60475e07f" +androidxComposeCompiler = "1.5.0" androidxComposeRuntimeTracing = "1.0.0-alpha03" androidxCore = "1.9.0" androidxCoreSplashscreen = "1.0.0" diff --git a/settings.gradle.kts b/settings.gradle.kts index 390416cfb..d0c477b3d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,7 +28,6 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven("https://androidx.dev/storage/compose-compiler/repository/") } } rootProject.name = "nowinandroid" From c64fb895b4f3ff09481b33fc6dbc91f51472539d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Braun?= Date: Wed, 19 Jul 2023 09:19:51 +0200 Subject: [PATCH 17/20] Upgrade Hilt to 2.47 Change-Id: I344cb7542107f134b71c62b652211eba370762ec --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2dd3f379d..71b692851 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,7 +34,7 @@ firebasePerfPlugin = "1.4.2" gmsPlugin = "4.3.14" googleOss = "17.0.1" googleOssPlugin = "0.10.6" -hilt = "2.46.1" +hilt = "2.47" hiltExt = "1.0.0" jacoco = "0.8.7" junit4 = "4.13.2" From 05e1656ea44b0cdcd7eef726323e6ad980461de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Braun?= Date: Wed, 19 Jul 2023 09:23:14 +0200 Subject: [PATCH 18/20] Update lint to 31.0.2 Change-Id: I11a2cf41f1428931794cf26ebc655ccb0cda33ab --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 71b692851..99248c8bf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -43,7 +43,7 @@ kotlinxCoroutines = "1.6.4" kotlinxDatetime = "0.4.0" kotlinxSerializationJson = "1.5.1" ksp = "1.9.0-1.0.11" -lint = "30.3.1" +lint = "31.0.2" okhttp = "4.10.0" protobuf = "3.23.4" protobufPlugin = "0.9.3" From 3a0ce45c1b791c8507926380d211fa069f5a6a2e Mon Sep 17 00:00:00 2001 From: Don Turner Date: Wed, 19 Jul 2023 10:23:27 +0100 Subject: [PATCH 19/20] Use newer lint version Change-Id: Ifb8f9495a01b4916c3e1ec0cd6ff4bd47080df37 --- gradle.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gradle.properties b/gradle.properties index b57dc01ed..22e1dc72e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,3 +38,7 @@ android.nonTransitiveRClass=true # https://developer.android.com/build/releases/gradle-plugin#default-changes android.defaults.buildfeatures.resvalues=false android.defaults.buildfeatures.shaders=false + +# Use newer lint version +# https://googlesamples.github.io/android-custom-lint-rules/usage/newer-lint.md.html +android.experimental.lint.version=8.1.0-rc01 \ No newline at end of file From 5fa8c1d7263526e998cdcd5e14425dc6cffe77ac Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Wed, 19 Jul 2023 12:35:19 +0200 Subject: [PATCH 20/20] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 22e1dc72e..de14513e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,6 +39,6 @@ android.nonTransitiveRClass=true android.defaults.buildfeatures.resvalues=false android.defaults.buildfeatures.shaders=false -# Use newer lint version +# Use newer lint version to support Kotlin 1.9 and corresponding kotlinx-metadata-jvm # https://googlesamples.github.io/android-custom-lint-rules/usage/newer-lint.md.html android.experimental.lint.version=8.1.0-rc01 \ No newline at end of file