Merge "Mark Material 3 samples with @Preview" into androidx-main
diff --git a/compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/AppBarTest.kt b/compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/AppBarTest.kt
index 42821e5..fe9813d 100644
--- a/compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/AppBarTest.kt
+++ b/compose/material3/material3/src/androidAndroidTest/kotlin/androidx/compose/material3/AppBarTest.kt
@@ -588,9 +588,33 @@
         }
 
         assertMediumOrLargeScrolledColors(
-            TopAppBarMediumTokens.ContainerHeight,
-            TopAppBarSmallTokens.ContainerHeight,
-            content
+            appBarMaxHeight = TopAppBarMediumTokens.ContainerHeight,
+            appBarMinHeight = TopAppBarSmallTokens.ContainerHeight,
+            titleContentColor = Color.Unspecified,
+            content = content
+        )
+    }
+
+    @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
+    @Test
+    fun mediumTopAppBar_scrolledColorsWithCustomTitleTextColor() {
+        val content = @Composable { scrollBehavior: TopAppBarScrollBehavior? ->
+            MediumTopAppBar(
+                modifier = Modifier.testTag(TopAppBarTestTag),
+                title = {
+                    Text(
+                        text = "Title", Modifier.testTag(TitleTestTag),
+                        color = Color.Green
+                    )
+                },
+                scrollBehavior = scrollBehavior
+            )
+        }
+        assertMediumOrLargeScrolledColors(
+            appBarMaxHeight = TopAppBarMediumTokens.ContainerHeight,
+            appBarMinHeight = TopAppBarSmallTokens.ContainerHeight,
+            titleContentColor = Color.Green,
+            content = content
         )
     }
 
@@ -708,9 +732,33 @@
             )
         }
         assertMediumOrLargeScrolledColors(
-            TopAppBarLargeTokens.ContainerHeight,
-            TopAppBarSmallTokens.ContainerHeight,
-            content
+            appBarMaxHeight = TopAppBarLargeTokens.ContainerHeight,
+            appBarMinHeight = TopAppBarSmallTokens.ContainerHeight,
+            titleContentColor = Color.Unspecified,
+            content = content
+        )
+    }
+
+    @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
+    @Test
+    fun largeTopAppBar_scrolledColorsWithCustomTitleTextColor() {
+        val content = @Composable { scrollBehavior: TopAppBarScrollBehavior? ->
+            LargeTopAppBar(
+                modifier = Modifier.testTag(TopAppBarTestTag),
+                title = {
+                    Text(
+                        text = "Title", Modifier.testTag(TitleTestTag),
+                        color = Color.Red
+                    )
+                },
+                scrollBehavior = scrollBehavior,
+            )
+        }
+        assertMediumOrLargeScrolledColors(
+            appBarMaxHeight = TopAppBarLargeTokens.ContainerHeight,
+            appBarMinHeight = TopAppBarSmallTokens.ContainerHeight,
+            titleContentColor = Color.Red,
+            content = content
         )
     }
 
@@ -1284,6 +1332,7 @@
      *
      * @param appBarMaxHeight the max height of the app bar [content]
      * @param appBarMinHeight the min height of the app bar [content]
+     * @param titleContentColor text content color expected for the app bar's title.
      * @param content a Composable that adds a MediumTopAppBar or a LargeTopAppBar
      */
     @OptIn(ExperimentalMaterial3Api::class)
@@ -1291,6 +1340,7 @@
     private fun assertMediumOrLargeScrolledColors(
         appBarMaxHeight: Dp,
         appBarMinHeight: Dp,
+        titleContentColor: Color,
         content: @Composable (TopAppBarScrollBehavior?) -> Unit
     ) {
         // Note: This value is specifically picked to avoid precision issues when asserting the
@@ -1299,7 +1349,7 @@
         var fullyCollapsedHeightOffsetPx = 0f
         var fullyCollapsedContainerColor: Color = Color.Unspecified
         var expandedAppBarBackgroundColor: Color = Color.Unspecified
-        var titleContentColor: Color = Color.Unspecified
+        var titleColor = titleContentColor
         lateinit var scrollBehavior: TopAppBarScrollBehavior
         rule.setMaterialContent(lightColorScheme()) {
             scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
@@ -1312,8 +1362,10 @@
 
             // Resolve the title's content color. The default implementation returns the same color
             // regardless of the fraction, and the color is applied later with alpha.
-            titleContentColor =
-                TopAppBarDefaults.mediumTopAppBarColors().titleContentColor
+            if (titleColor == Color.Unspecified) {
+                titleColor =
+                    TopAppBarDefaults.mediumTopAppBarColors().titleContentColor
+            }
 
             with(LocalDensity.current) {
                 fullyCollapsedHeightOffsetPx = fullyCollapsedOffsetDp.toPx()
@@ -1335,12 +1387,12 @@
         // Assert the content color at the top and bottom parts of the expanded app bar.
         topTitleNode.captureToImage()
             .assertContainsColor(
-                titleContentColor.copy(alpha = TopTitleAlphaEasing.transform(0f))
+                titleColor.copy(alpha = TopTitleAlphaEasing.transform(0f))
                     .compositeOver(expandedAppBarBackgroundColor)
             )
         bottomTitleNode.captureToImage()
             .assertContainsColor(
-                titleContentColor.compositeOver(expandedAppBarBackgroundColor)
+                titleColor.compositeOver(expandedAppBarBackgroundColor)
             )
 
         // Simulate fully collapsed content.
@@ -1353,7 +1405,7 @@
             .assertContainsColor(fullyCollapsedContainerColor)
         topTitleNode.captureToImage()
             .assertContainsColor(
-                titleContentColor.copy(alpha = TopTitleAlphaEasing.transform(1f))
+                titleColor.copy(alpha = TopTitleAlphaEasing.transform(1f))
                     .compositeOver(fullyCollapsedContainerColor)
             )
         // Only the top title should be visible in the collapsed form.
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
index af531f7..c77e134 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
@@ -68,6 +68,7 @@
 import androidx.compose.ui.draw.clipToBounds
 import androidx.compose.ui.geometry.Offset
 import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
 import androidx.compose.ui.graphics.lerp
 import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
 import androidx.compose.ui.input.nestedscroll.NestedScrollSource
@@ -1269,10 +1270,11 @@
                     .layoutId("title")
                     .padding(horizontal = TopAppBarHorizontalPadding)
                     .then(if (hideTitleSemantics) Modifier.clearAndSetSemantics { } else Modifier)
+                    .graphicsLayer(alpha = titleAlpha)
             ) {
                 ProvideTextStyle(value = titleTextStyle) {
                     CompositionLocalProvider(
-                        LocalContentColor provides titleContentColor.copy(alpha = titleAlpha),
+                        LocalContentColor provides titleContentColor,
                         content = title
                     )
                 }
diff --git a/development/build_log_simplifier/messages.ignore b/development/build_log_simplifier/messages.ignore
index 6ea1e3f..b3de5bd 100644
--- a/development/build_log_simplifier/messages.ignore
+++ b/development/build_log_simplifier/messages.ignore
@@ -195,11 +195,6 @@
 # see: https://github.com/JetBrains/kotlin/blob/master/native/commonizer/README.md
 # This warning is printed from: https://github.com/JetBrains/kotlin/blob/bc853e45e8982eff74e3263b0197c1af6086615d/native/commonizer/src/org/jetbrains/kotlin/commonizer/konan/LibraryCommonizer.kt#L41
 Warning\: No libraries found for target (macos|ios|ios_simulator)_(arm|x)[0-9]+\. This target will be excluded from commonization\.
-# > Task :tv:tv-foundation:processDebugManifest
-# > Task :tv:tv-material:processDebugManifest
-# > Task :tv:tv-material:processReleaseManifest
-# > Task :tv:tv-foundation:processReleaseManifest
-package="androidx\.tv\..*" found in source AndroidManifest\.xml: \$OUT_DIR/androidx/tv/tv\-[a-z]+/build/intermediates/tmp/ProcessLibraryManifest/[a-z]+/tempAndroidManifest[0-9]+\.xml\.
 void androidx.tv.foundation.lazy.list.LazyListKt.LazyList(androidx.compose.ui.Modifier, androidx.tv.foundation.lazy.list.TvLazyListState, androidx.compose.foundation.layout.PaddingValues, boolean, boolean, boolean, androidx.tv.foundation.PivotOffsets, androidx.compose.ui.Alignment$Horizontal, androidx.compose.foundation.layout.Arrangement$Vertical, androidx.compose.ui.Alignment$Vertical, androidx.compose.foundation.layout.Arrangement$Horizontal, kotlin.jvm.functions.Function1, androidx.compose.runtime.Composer, int, int, int)
 void androidx.tv.foundation.lazy.grid.LazyGridKt.LazyGrid(androidx.compose.ui.Modifier, androidx.tv.foundation.lazy.grid.TvLazyGridState, kotlin.jvm.functions.Function2, androidx.compose.foundation.layout.PaddingValues, boolean, boolean, boolean, androidx.compose.foundation.layout.Arrangement$Vertical, androidx.compose.foundation.layout.Arrangement$Horizontal, androidx.tv.foundation.PivotOffsets, kotlin.jvm.functions.Function1, androidx.compose.runtime.Composer, int, int, int)
 # > Task :room:integration-tests:room-testapp:mergeDexWithExpandProjectionDebugAndroidTest
@@ -246,14 +241,6 @@
 2 warnings
 # AGP warning that will go away soon
 WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8\.0\. To opt\-in to the future behavior, set the Gradle property android\.disableAutomaticComponentCreation=true in the `gradle\.properties` file or use the new publishing DSL\.
-# > Task :help
-Welcome to Gradle [0-9]+\.[0-9]+\.
-To run a build, run gradlew <task> \.\.\.
-To see a list of available tasks, run gradlew tasks
-To see more detail about a task, run gradlew help \-\-task <task>
-To see a list of command\-line options, run gradlew \-\-help
-For more detail on using Gradle, see https://docs\.gradle\.org/[0-9]+\.[0-9]+/userguide/command_line_interface\.html
-For troubleshooting, visit https://help\.gradle\.org
 # > Task :graphics:graphics-path:compileDebugKotlin
 w\: \$SUPPORT\/graphics\/graphics\-path\/src\/main\/java\/androidx\/graphics\/path\/Paths\.kt\: \([0-9]+\, [0-9]+\)\: Extension is shadowed by a member\: public open fun iterator\(\)\: PathIterator
 # > Task :core:core-splashscreen:core-splashscreen-samples:lintReportDebug
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 9f977ca..20606e3 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -26,12 +26,12 @@
 byteBuddy = "1.12.10"
 asm = "9.3"
 cmake = "3.22.1"
-dagger = "2.42"
+dagger = "2.44"
 dexmaker = "2.28.3"
 dokka = "1.7.20"
 espresso = "3.5.0-alpha06"
 guavaJre = "31.1-jre"
-hilt = "2.42"
+hilt = "2.44"
 incap = "0.2"
 jcodec = "0.2.5"
 kotlin = "1.7.20"
diff --git a/hilt/hilt-navigation-fragment/build.gradle b/hilt/hilt-navigation-fragment/build.gradle
index f3dd393..a7c9104 100644
--- a/hilt/hilt-navigation-fragment/build.gradle
+++ b/hilt/hilt-navigation-fragment/build.gradle
@@ -34,7 +34,7 @@
 dependencies {
     api(libs.kotlinStdlib)
     api(project(":hilt:hilt-navigation"))
-    api("androidx.navigation:navigation-fragment-ktx:2.3.2")
+    api("androidx.navigation:navigation-fragment-ktx:2.5.1")
 
     androidTestImplementation("androidx.fragment:fragment-testing:1.3.0")
     androidTestImplementation(libs.testExtJunit)
diff --git a/hilt/hilt-navigation-fragment/src/androidTest/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazyTest.kt b/hilt/hilt-navigation-fragment/src/androidTest/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazyTest.kt
index e15d290..b8ed629 100644
--- a/hilt/hilt-navigation-fragment/src/androidTest/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazyTest.kt
+++ b/hilt/hilt-navigation-fragment/src/androidTest/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazyTest.kt
@@ -16,6 +16,7 @@
 
 package androidx.hilt.navigation.fragment
 
+import android.content.Context
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
@@ -33,6 +34,7 @@
 import com.google.common.truth.Truth.assertThat
 import dagger.hilt.android.AndroidEntryPoint
 import dagger.hilt.android.lifecycle.HiltViewModel
+import dagger.hilt.android.qualifiers.ApplicationContext
 import dagger.hilt.android.testing.HiltAndroidRule
 import dagger.hilt.android.testing.HiltAndroidTest
 import org.junit.Rule
@@ -78,10 +80,9 @@
             assertThat(viewModel).isNotNull()
             assertThat(savedStateViewModel).isNotNull()
 
-            // First assert that we don't have any default value since the
-            // navigation graph wasn't sent any arguments
+            // First assert that we have the default value
             val initialState: String? = savedStateViewModel.savedStateHandle["test"]
-            assertThat(initialState).isNull()
+            assertThat(initialState).isEqualTo("first")
 
             // Now set arguments
             savedStateViewModel.savedStateHandle.set("test", "test")
@@ -131,6 +132,10 @@
 class TestVMFragment : Fragment() {
     val viewModel: TestViewModel by hiltNavGraphViewModels(R.id.vm_graph)
     val savedStateViewModel: TestSavedStateViewModel by hiltNavGraphViewModels(R.id.vm_graph)
+    // TODO(kuanyingchou) Remove this after https://github.com/google/dagger/issues/3601 is resolved
+    @Inject @ApplicationContext
+    lateinit var applicationContext: Context
+
     override fun onCreateView(
         inflater: LayoutInflater,
         container: ViewGroup?,
diff --git a/hilt/hilt-navigation-fragment/src/main/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazy.kt b/hilt/hilt-navigation-fragment/src/main/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazy.kt
index 637087f..8b900ac 100644
--- a/hilt/hilt-navigation-fragment/src/main/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazy.kt
+++ b/hilt/hilt-navigation-fragment/src/main/java/androidx/hilt/navigation/fragment/HiltNavGraphViewModelLazy.kt
@@ -53,7 +53,7 @@
     }
     return createViewModelLazy(
         VM::class, storeProducer,
-        {
+        factoryProducer = {
             HiltViewModelFactory(requireActivity(), backStackEntry)
         }
     )
diff --git a/hilt/hilt-navigation/build.gradle b/hilt/hilt-navigation/build.gradle
index c0d5630..fbabb51 100644
--- a/hilt/hilt-navigation/build.gradle
+++ b/hilt/hilt-navigation/build.gradle
@@ -26,7 +26,7 @@
 dependencies {
     api(libs.kotlinStdlib)
     api("androidx.annotation:annotation:1.1.0")
-    api("androidx.navigation:navigation-runtime:2.3.2")
+    api("androidx.navigation:navigation-runtime:2.5.1")
     api(libs.hiltAndroid)
     kapt(libs.hiltCompiler)
 }
diff --git a/paging/paging-testing/build.gradle b/paging/paging-testing/build.gradle
index cfe7df2..fd8d14d 100644
--- a/paging/paging-testing/build.gradle
+++ b/paging/paging-testing/build.gradle
@@ -40,7 +40,7 @@
     mavenGroup = LibraryGroups.PAGING
     inceptionYear = "2022"
     description = "Test artifact for Paging implementation"
-    publish = Publish.SNAPSHOT_ONLY
+    publish = Publish.SNAPSHOT_AND_RELEASE
 }
 
 android {