Skip to content

Commit 6c5fdab

Browse files
committed
Merge branch 'main' into nav3
2 parents 7a4ea77 + 48adb11 commit 6c5fdab

File tree

206 files changed

+7453
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+7453
-174
lines changed

.github/workflows/apply_spotless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ jobs:
4545
run: ./gradlew spotlessApply --stacktrace
4646

4747
- name: Auto-commit if spotlessApply has changes
48-
uses: stefanzweifel/git-auto-commit-action@v5
48+
uses: stefanzweifel/git-auto-commit-action@v7
4949
with:
5050
commit_message: Apply Spotless

CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* @yrezgui @kkuan2011
2+
/compose/ @android/devrel-compose
3+
/car/ @android/devrel-car
4+
/watchface/ @android/devrel-wear
5+
/wear/ @android/devrel-wear
6+
/wearcompanion/ @android/devrel-wear
7+
/xr/ @android/devrel-xr
8+
/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/ @android/devrel-adaptive-apps

bluetoothle/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
plugins {
33
alias(libs.plugins.android.application)
4-
alias(libs.plugins.kotlin.android)
54
}
65
android {
76
compileSdk = libs.versions.compileSdk.get().toInt()

compose/recomposehighlighter/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
alias(libs.plugins.android.application)
3-
alias(libs.plugins.kotlin.android)
43
alias(libs.plugins.compose.compiler)
54
}
65
android {

compose/snippets/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
plugins {
1818
alias(libs.plugins.android.application)
19-
alias(libs.plugins.kotlin.android)
2019
alias(libs.plugins.ksp)
2120
alias(libs.plugins.hilt)
2221
alias(libs.plugins.kotlin.parcelize)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright 2026 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.compose.snippets.test
18+
19+
import androidx.compose.material3.Text
20+
import androidx.compose.runtime.LaunchedEffect
21+
import androidx.compose.runtime.getValue
22+
import androidx.compose.runtime.mutableStateOf
23+
import androidx.compose.runtime.remember
24+
import androidx.compose.runtime.setValue
25+
import androidx.compose.ui.test.ExperimentalTestApi
26+
import androidx.compose.ui.test.assertIsDisplayed
27+
import androidx.compose.ui.test.junit4.v2.createComposeRule
28+
import androidx.compose.ui.test.onNodeWithText
29+
import androidx.compose.ui.test.v2.runComposeUiTest
30+
import kotlinx.coroutines.delay
31+
import kotlinx.coroutines.test.advanceTimeBy
32+
import kotlinx.coroutines.test.runTest
33+
import org.junit.Rule
34+
import org.junit.Test
35+
36+
class RunComposeUiTest {
37+
38+
@OptIn(ExperimentalTestApi::class)
39+
// [START android_compose_test_runComposeUiTest]
40+
@Test
41+
fun testWithCoroutines() = runComposeUiTest {
42+
setContent {
43+
var status by remember { mutableStateOf("Loading...") }
44+
LaunchedEffect(Unit) {
45+
delay(1000)
46+
status = "Done!"
47+
}
48+
Text(text = status)
49+
}
50+
51+
onNodeWithText("Loading...").assertIsDisplayed()
52+
mainClock.advanceTimeBy(1000 + 16 /* Frame buffer */)
53+
onNodeWithText("Done!").assertIsDisplayed()
54+
}
55+
}
56+
// [END android_compose_test_runComposeUiTest]
57+
58+
class Test2 {
59+
// [START android_compose_test_v2_apis]
60+
@get:Rule
61+
val composeTestRule = createComposeRule()
62+
63+
@Test
64+
fun testWithCoroutines() {
65+
composeTestRule.setContent {
66+
var status by remember { mutableStateOf("Loading...") }
67+
LaunchedEffect(Unit) {
68+
delay(1000)
69+
status = "Done!"
70+
}
71+
Text(text = status)
72+
}
73+
74+
// NOT RECOMMENDED
75+
// Fails: runTest creates a new, separate scheduler.
76+
// Advancing time here does NOT advance the compose clock.
77+
// To fix this without migrating, you would need to share the scheduler
78+
// by passing 'composeTestRule.mainClock.scheduler' to runTest.
79+
runTest {
80+
composeTestRule.onNodeWithText("Loading...").assertIsDisplayed()
81+
advanceTimeBy(1000)
82+
composeTestRule.onNodeWithText("Done!").assertIsDisplayed()
83+
}
84+
}
85+
// [END android_compose_test_v2_apis]
86+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright 2026 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.compose.snippets.adaptivelayouts
18+
19+
import androidx.compose.foundation.lazy.grid.GridCells
20+
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
21+
import androidx.compose.foundation.lazy.grid.items
22+
import androidx.compose.material3.Text
23+
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
24+
import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffold
25+
import androidx.compose.material3.adaptive.layout.SupportingPaneScaffold
26+
import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator
27+
import androidx.compose.material3.adaptive.navigation.rememberSupportingPaneScaffoldNavigator
28+
import androidx.compose.runtime.Composable
29+
import androidx.compose.ui.unit.dp
30+
31+
32+
// [START android_compose_canonical_layouts_sample_my_feed]
33+
@Composable
34+
fun MyFeed(names: List<String>) {
35+
LazyVerticalGrid(
36+
// GridCells.Adaptive automatically adapts column count based on available width
37+
columns = GridCells.Adaptive(minSize = 180.dp),
38+
) {
39+
items(names) { name ->
40+
Text(name)
41+
}
42+
}
43+
}
44+
// [END android_compose_canonical_layouts_sample_my_feed]
45+
46+
// [START android_compose_canonical_layouts_list_detail_pane_scaffold]
47+
@OptIn(ExperimentalMaterial3AdaptiveApi::class)
48+
@Composable
49+
fun MyListDetailPaneScaffold() {
50+
val navigator = rememberListDetailPaneScaffoldNavigator()
51+
ListDetailPaneScaffold(
52+
directive = navigator.scaffoldDirective,
53+
value = navigator.scaffoldValue,
54+
listPane = {
55+
// Listing Pane
56+
},
57+
detailPane = {
58+
// Details Pane
59+
}
60+
)
61+
}
62+
// [END android_compose_canonical_layouts_list_detail_pane_scaffold]
63+
64+
// [START android_compose_canonical_layouts_supporting_pane_scaffold]
65+
@OptIn(ExperimentalMaterial3AdaptiveApi::class)
66+
@Composable
67+
fun MySupportingPaneScaffold() {
68+
// Creates and remembers a navigator to control pane visibility and navigation
69+
val navigator = rememberSupportingPaneScaffoldNavigator()
70+
SupportingPaneScaffold(
71+
// Directive and value help control pane visibility based on screen size and state
72+
directive = navigator.scaffoldDirective,
73+
value = navigator.scaffoldValue,
74+
mainPane = {
75+
// Main Pane for the primary content
76+
},
77+
supportingPane = {
78+
//Supporting Pane for supplementary content
79+
}
80+
)
81+
}
82+
// [END android_compose_canonical_layouts_supporting_pane_scaffold]

compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ private fun ListsSnippetsContentSpacing3(photos: List<Photo>) {
203203

204204
private object ListsSnippetsStickyHeaders1 {
205205
// [START android_compose_layouts_lazy_column_sticky_header]
206-
@OptIn(ExperimentalFoundationApi::class)
207206
@Composable
208207
fun ListWithHeader(items: List<Item>) {
209208
LazyColumn {
@@ -224,7 +223,6 @@ private object ListsSnippetsStickyHeaders2 {
224223
// This ideally would be done in the ViewModel
225224
val grouped = contacts.groupBy { it.firstName[0] }
226225

227-
@OptIn(ExperimentalFoundationApi::class)
228226
@Composable
229227
fun ContactsList(grouped: Map<Char, List<Contact>>) {
230228
LazyColumn {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.compose.snippets.performance
18+
19+
import android.app.Application
20+
import androidx.compose.runtime.Composer
21+
import androidx.compose.runtime.tooling.ComposeStackTraceMode
22+
23+
// [START android_compose_stacktraces_enable]
24+
// Enable stack traces at application level: onCreate
25+
class SampleStackTracesEnabledApp : Application() {
26+
27+
override fun onCreate() {
28+
super.onCreate()
29+
// Enable Compose stack traces for minified builds only.
30+
Composer.setDiagnosticStackTraceMode(ComposeStackTraceMode.Auto)
31+
32+
// Alternatively:
33+
// Enable verbose Compose stack traces for local debugging
34+
Composer.setDiagnosticStackTraceMode(ComposeStackTraceMode.SourceInformation)
35+
}
36+
}
37+
// [END android_compose_stacktraces_enable]

0 commit comments

Comments
 (0)