From 0272b6d38d66815f3c4e62eeac1562c62a85c80e Mon Sep 17 00:00:00 2001
From: Meghan <magicalmeghan@google.com>
Date: Thu, 3 Apr 2025 18:14:12 -0400
Subject: [PATCH 1/2] Update to state based TFs

---
 .../compose/snippets/text/AutofillSnippets.kt | 37 ++++---------------
 gradle/libs.versions.toml                     |  9 +++--
 2 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt
index acb4e608c..13f3bd5a7 100644
--- a/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt
+++ b/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.Spacer
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.text.LocalAutofillHighlightColor
+import androidx.compose.foundation.text.input.rememberTextFieldState
 import androidx.compose.material3.TextField
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
@@ -38,13 +39,9 @@ import com.example.compose.snippets.touchinput.Button
 
 @Composable
 fun AddAutofill() {
-    var textFieldValue = remember {
-        mutableStateOf(TextFieldValue(""))
-    }
     // [START android_compose_autofill_1]
     TextField(
-        value = textFieldValue.value,
-        onValueChange = {textFieldValue.value = it},
+        state = rememberTextFieldState(),
         modifier = Modifier.semantics { contentType = ContentType.Username }
     )
     // [END android_compose_autofill_1]
@@ -52,13 +49,9 @@ fun AddAutofill() {
 
 @Composable
 fun AddMultipleTypesOfAutofill() {
-    var textFieldValue = remember {
-        mutableStateOf(TextFieldValue(""))
-    }
     // [START android_compose_autofill_2]
     TextField(
-        value = textFieldValue.value,
-        onValueChange = { textFieldValue.value = it },
+        state = rememberTextFieldState(),
         modifier = Modifier.semantics {
             contentType = ContentType.Username + ContentType.EmailAddress
         }
@@ -75,24 +68,19 @@ fun AutofillManager() {
 
 @Composable
 fun SaveDataWithAutofill() {
-    var textFieldValue = remember {
-        mutableStateOf(TextFieldValue(""))
-    }
     // [START android_compose_autofill_4]
     val autofillManager = LocalAutofillManager.current
 
     Column {
         TextField(
-            value = textFieldValue.value,
-            onValueChange = { textFieldValue.value = it },
+            state = rememberTextFieldState(),
             modifier = Modifier.semantics { contentType = ContentType.NewUsername }
         )
 
         Spacer(modifier = Modifier.height(16.dp))
 
         TextField(
-            value = textFieldValue.value,
-            onValueChange = { textFieldValue.value = it },
+            state = rememberTextFieldState(),
             modifier = Modifier.semantics { contentType = ContentType.NewPassword }
         )
     }
@@ -101,24 +89,19 @@ fun SaveDataWithAutofill() {
 
 @Composable
 fun SaveDataWithAutofillOnClick() {
-    var textFieldValue = remember {
-        mutableStateOf(TextFieldValue(""))
-    }
     // [START android_compose_autofill_5]
     val autofillManager = LocalAutofillManager.current
 
     Column {
         TextField(
-            value = textFieldValue.value,
-            onValueChange = { textFieldValue.value = it },
+            state = rememberTextFieldState(),
             modifier = Modifier.semantics { contentType = ContentType.NewUsername },
         )
 
         Spacer(modifier = Modifier.height(16.dp))
 
         TextField(
-            value = textFieldValue.value,
-            onValueChange = { textFieldValue.value = it },
+            state = rememberTextFieldState(),
             modifier = Modifier.semantics { contentType = ContentType.NewPassword },
         )
 
@@ -130,16 +113,12 @@ fun SaveDataWithAutofillOnClick() {
 
 @Composable
 fun CustomAutofillHighlight(customHighlightColor: Color = Color.Red) {
-    var textFieldValue = remember {
-        mutableStateOf(TextFieldValue(""))
-    }
     // [START android_compose_autofill_6]
     val customHighlightColor = Color.Red
 
     CompositionLocalProvider(LocalAutofillHighlightColor provides customHighlightColor) {
         TextField(
-            value = textFieldValue.value,
-            onValueChange = { textFieldValue.value = it },
+            state = rememberTextFieldState(),
             modifier = Modifier.semantics { contentType = ContentType.Username }
         )
     }
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index e987a4996..d6274ae6f 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,9 +1,9 @@
 [versions]
 accompanist = "0.36.0"
 androidGradlePlugin = "8.8.0"
-androidx-activity-compose = "1.10.0"
+androidx-activity-compose = "1.10.1"
 androidx-appcompat = "1.7.0"
-androidx-compose-bom = "2025.01.00"
+androidx-compose-bom = "2025.03.01"
 androidx-compose-ui-test = "1.7.0-alpha08"
 androidx-constraintlayout = "2.2.0"
 androidx-constraintlayout-compose = "1.1.0"
@@ -38,7 +38,8 @@ kotlin = "2.1.0"
 kotlinxSerializationJson = "1.8.0"
 ksp = "2.1.0-1.0.29"
 maps-compose = "6.4.1"
-material = "1.13.0-alpha09"
+material = "1.13.0-alpha12"
+material3-alpha = "1.4.0-alpha11"
 material3-adaptive = "1.0.0"
 material3-adaptive-navigation-suite = "1.3.1"
 media3 = "1.5.1"
@@ -77,7 +78,7 @@ androidx-compose-foundation-layout = { module = "androidx.compose.foundation:fou
 androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose-latest" }
 androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" }
 androidx-compose-material-ripple = { module = "androidx.compose.material:material-ripple", version.ref = "compose-latest" }
-androidx-compose-material3 = { module = "androidx.compose.material3:material3" }
+androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "material3-alpha" }
 androidx-compose-material3-adaptive = { module = "androidx.compose.material3.adaptive:adaptive", version.ref = "material3-adaptive" }
 androidx-compose-material3-adaptive-layout = { module = "androidx.compose.material3.adaptive:adaptive-layout", version.ref = "material3-adaptive" }
 androidx-compose-material3-adaptive-navigation = { module = "androidx.compose.material3.adaptive:adaptive-navigation", version.ref = "material3-adaptive" }

From 928a4cb621b6c3437f8cf032f094635ef5bfbbcd Mon Sep 17 00:00:00 2001
From: MagicalMeghan <46006059+MagicalMeghan@users.noreply.github.com>
Date: Thu, 3 Apr 2025 22:16:28 +0000
Subject: [PATCH 2/2] Apply Spotless

---
 .../com/example/compose/snippets/text/AutofillSnippets.kt    | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt
index 13f3bd5a7..d083e9fe7 100644
--- a/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt
+++ b/compose/snippets/src/main/java/com/example/compose/snippets/text/AutofillSnippets.kt
@@ -21,19 +21,16 @@ import androidx.compose.foundation.layout.Spacer
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.text.LocalAutofillHighlightColor
 import androidx.compose.foundation.text.input.rememberTextFieldState
-import androidx.compose.material3.TextField
 import androidx.compose.material3.Text
+import androidx.compose.material3.TextField
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.CompositionLocalProvider
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.autofill.ContentType
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.platform.LocalAutofillManager
 import androidx.compose.ui.semantics.contentType
 import androidx.compose.ui.semantics.semantics
-import androidx.compose.ui.text.input.TextFieldValue
 import androidx.compose.ui.unit.dp
 import com.example.compose.snippets.touchinput.Button