A fully functional Android app built entirely with Kotlin and Jetpack Compose
Merge branch 'main' into bw/initialMetrics
Ben Weissefb76d49410b
diff --cc app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.ktindex d005f2014,d5ca8bf5e..28f02a410--- a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt+++ b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt@@@ -43,7 -44,8 +44,9 @@@ import androidx.compose.ui.Modifieimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.res.stringResource+ import androidx.compose.ui.semantics.semantics+ import androidx.compose.ui.semantics.testTagsAsResourceId+import androidx.navigation.NavControllerimport androidx.navigation.NavDestinationimport androidx.navigation.NavDestination.Companion.hierarchyimport androidx.navigation.compose.currentBackStackEntryAsStatediff --cc feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/AuthorsCarousel.ktindex fcd400c46,d744db7cd..6c74240ce--- a/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/AuthorsCarousel.kt+++ b/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/AuthorsCarousel.kt@@@ -64,11 -65,11 +67,15 @@@ fun AuthorsCarouselonAuthorClick: (String, Boolean) -> Unit,modifier: Modifier = Modifier) {+ val lazyListState = rememberLazyListState()-+ TrackScrollJank(lazyListState, "ForYou:AuthorsCarousel")+- LazyRow(modifier, lazyListState) {+ LazyRow(+ modifier = modifier.testTag("forYou:authors"),+ contentPadding = PaddingValues(24.dp),- horizontalArrangement = Arrangement.spacedBy(24.dp)++ horizontalArrangement = Arrangement.spacedBy(24.dp),++ state = lazyListState+ ) {items(items = authors, key = { item -> item.author.id }) { followableAuthor ->AuthorItem(author = followableAuthor.author,diff --cc feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.ktindex a6ec3c42e,7a607be0c..ab3342d0c--- 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@@@ -164,12 -167,31 +170,35 @@@ fun ForYouScreenelse -> floor(maxWidth / 300.dp).toInt().coerceAtLeast(1)}+ // Workaround to call Activity.reportFullyDrawn from Jetpack Compose.+ // This code should be called when the UI is ready for use+ // and relates to Time To Full Display.+ val interestsLoaded =+ interestsSelectionState !is ForYouInterestsSelectionUiState.Loading+ val feedLoaded = feedState !is ForYouFeedUiState.Loading++ if (interestsLoaded && feedLoaded) {+ val localView = LocalView.current+ // We use Unit to call reportFullyDrawn only on the first recomposition,+ // however it will be called again if this composable goes out of scope.+ // Activity.reportFullyDrawn() has its own check for this+ // and is safe to call multiple times though.+ LaunchedEffect(Unit) {+ // We're leveraging the fact, that the current view is directly set as content of Activity.+ val activity = localView.context as? Activity ?: return@LaunchedEffect+ // To be sure not to call in the middle of a frame draw.+ localView.doOnPreDraw { activity.reportFullyDrawn() }+ }+ }++ val lazyListState = rememberLazyListState()+ TrackScrollJank(lazyListState, "ForYou:Feed")+LazyColumn(+ modifier = Modifier+ .fillMaxSize()+ .testTag("forYou:feed"),+ state = lazyListState,- modifier = Modifier.fillMaxSize(),) {InterestsSelection(interestsSelectionState = interestsSelectionState,@@@ -292,13 -315,8 +322,12 @@@ private fun TopicSelectioninterestsSelectionState: ForYouInterestsSelectionUiState.WithInterestsSelection,onTopicCheckedChanged: (String, Boolean) -> Unit,modifier: Modifier = Modifier- ) {+ ) = trace("TopicSelection") {+ val lazyGridState = rememberLazyGridState()-+ TrackScrollJank(scrollableState = lazyGridState, stateName = "ForYou:TopicSelection")+LazyHorizontalGrid(+ state = lazyGridState,rows = GridCells.Fixed(3),horizontalArrangement = Arrangement.spacedBy(12.dp),verticalArrangement = Arrangement.spacedBy(12.dp),