Skip to content

Commit 1cb68a6

Browse files
authored
Merge pull request #1 from android/main
Fixing Imports on ResizableComponent changes
2 parents 222fd4f + 70285ac commit 1cb68a6

File tree

12 files changed

+830
-15
lines changed

12 files changed

+830
-15
lines changed

gradle/libs.versions.toml

+9-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ google-maps = "19.2.0"
4444
gradle-versions = "0.52.0"
4545
guava = "33.4.8-jre"
4646
hilt = "2.56.2"
47-
horologist = "0.6.23"
47+
horologist = "0.7.10-alpha"
4848
junit = "4.13.2"
4949
kotlin = "2.1.20"
5050
kotlinCoroutinesOkhttp = "1.0"
@@ -60,18 +60,19 @@ media3 = "1.6.1"
6060
minSdk = "21"
6161
okHttp = "4.12.0"
6262
playServicesWearable = "19.0.0"
63-
protolayout = "1.2.1"
63+
protolayout = "1.3.0-beta02"
6464
recyclerview = "1.4.0"
6565
# @keep
6666
androidx-xr-arcore = "1.0.0-alpha04"
6767
androidx-xr-scenecore = "1.0.0-alpha04"
6868
androidx-xr-compose = "1.0.0-alpha04"
6969
targetSdk = "34"
70-
tiles = "1.4.1"
70+
tiles = "1.5.0-beta01"
7171
version-catalog-update = "1.0.0"
7272
wear = "1.3.0"
73-
wearComposeFoundation = "1.4.1"
74-
wearComposeMaterial = "1.4.1"
73+
wearComposeFoundation = "1.5.0-beta01"
74+
wearComposeMaterial = "1.5.0-beta01"
75+
wearComposeMaterial3 = "1.5.0-beta01"
7576
wearToolingPreview = "1.0.0"
7677
webkit = "1.13.0"
7778

@@ -135,6 +136,7 @@ androidx-paging-compose = { module = "androidx.paging:paging-compose", version.r
135136
androidx-protolayout = { module = "androidx.wear.protolayout:protolayout", version.ref = "protolayout" }
136137
androidx-protolayout-expression = { module = "androidx.wear.protolayout:protolayout-expression", version.ref = "protolayout" }
137138
androidx-protolayout-material = { module = "androidx.wear.protolayout:protolayout-material", version.ref = "protolayout" }
139+
androidx-protolayout-material3 = { module = "androidx.wear.protolayout:protolayout-material3", version.ref = "protolayout" }
138140
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
139141
androidx-startup-runtime = { module = "androidx.startup:startup-runtime", version.ref = "androidx-startup-runtime" }
140142
androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test" }
@@ -159,7 +161,7 @@ androidx-xr-scenecore = { module = "androidx.xr.scenecore:scenecore", version.re
159161
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
160162
coil-kt-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
161163
compose-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "wearComposeFoundation" }
162-
compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "wearComposeMaterial" }
164+
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "wearComposeMaterial" }
163165
compose-ui-tooling = { module = "androidx.wear.compose:compose-ui-tooling", version.ref = "composeUiTooling" }
164166
glide-compose = { module = "com.github.bumptech.glide:compose", version.ref = "glide" }
165167
google-android-material = { module = "com.google.android.material:material", version.ref = "material" }
@@ -179,6 +181,7 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t
179181
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
180182
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okHttp" }
181183
play-services-wearable = { module = "com.google.android.gms:play-services-wearable", version.ref = "playServicesWearable" }
184+
wear-compose-material3 = { module = "androidx.wear.compose:compose-material3", version.ref = "wearComposeMaterial3" }
182185

183186
[plugins]
184187
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }

wear/build.gradle.kts

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ dependencies {
5959
implementation(libs.androidx.wear)
6060
implementation(libs.androidx.protolayout)
6161
implementation(libs.androidx.protolayout.material)
62+
implementation(libs.androidx.protolayout.material3)
6263
implementation(libs.androidx.protolayout.expression)
6364
debugImplementation(libs.androidx.tiles.renderer)
6465
testImplementation(libs.androidx.tiles.testing)
@@ -69,7 +70,8 @@ dependencies {
6970
implementation(platform(libs.androidx.compose.bom))
7071
implementation(libs.androidx.compose.ui)
7172
implementation(libs.androidx.compose.ui.tooling.preview)
72-
implementation(libs.compose.material)
73+
implementation(libs.wear.compose.material)
74+
implementation(libs.wear.compose.material3)
7375
implementation(libs.compose.foundation)
7476
implementation(libs.androidx.activity.compose)
7577
implementation(libs.androidx.core.splashscreen)

wear/src/main/AndroidManifest.xml

+18-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
android:value="true" />
2525

2626
<activity
27-
android:name=".snippets.MainActivity"
27+
android:name=".snippets.m3.MainActivity"
2828
android:exported="true"
2929
android:taskAffinity=""
3030
android:theme="@android:style/Theme.DeviceDefault">
@@ -52,6 +52,23 @@
5252
</service>
5353
<!-- [END android_wear_tile_manifest] -->
5454

55+
<!-- [START android_wear_m3_tile_manifest] -->
56+
<service
57+
android:name=".snippets.m3.tile.MyTileService"
58+
android:label="@string/tile_label"
59+
android:description="@string/tile_description"
60+
android:icon="@mipmap/ic_launcher"
61+
android:exported="true"
62+
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER">
63+
<intent-filter>
64+
<action android:name="androidx.wear.tiles.action.BIND_TILE_PROVIDER" />
65+
</intent-filter>
66+
67+
<meta-data android:name="androidx.wear.tiles.PREVIEW"
68+
android:resource="@drawable/tile_preview" />
69+
</service>
70+
<!-- [END android_wear_m3_tile_manifest] -->
71+
5572
</application>
5673

5774
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2021 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.wear.snippets.m3
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.compose.runtime.Composable
23+
import com.example.wear.snippets.m3.list.ComposeList
24+
25+
class MainActivity : ComponentActivity() {
26+
override fun onCreate(savedInstanceState: Bundle?) {
27+
super.onCreate(savedInstanceState)
28+
29+
setContent {
30+
WearApp()
31+
}
32+
}
33+
}
34+
35+
@Composable
36+
fun WearApp() {
37+
// insert here the snippet you want to test
38+
ComposeList()
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
* Copyright 2022 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.wear.snippets.m3.list
18+
19+
import androidx.compose.foundation.layout.fillMaxWidth
20+
import androidx.compose.material.icons.Icons
21+
import androidx.compose.material.icons.filled.Build
22+
import androidx.compose.runtime.Composable
23+
import androidx.compose.ui.Modifier
24+
import androidx.compose.ui.platform.LocalConfiguration
25+
import androidx.compose.ui.text.style.TextOverflow
26+
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
27+
import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
28+
import androidx.wear.compose.material3.Button
29+
import androidx.wear.compose.material3.Icon
30+
import androidx.wear.compose.material3.ListHeader
31+
import androidx.wear.compose.material3.ScreenScaffold
32+
import androidx.wear.compose.material3.SurfaceTransformation
33+
import androidx.wear.compose.material3.Text
34+
import androidx.wear.compose.material3.lazy.rememberTransformationSpec
35+
import androidx.wear.compose.material3.lazy.transformedHeight
36+
import androidx.wear.compose.ui.tooling.preview.WearPreviewDevices
37+
import androidx.wear.compose.ui.tooling.preview.WearPreviewFontScales
38+
import com.google.android.horologist.annotations.ExperimentalHorologistApi
39+
import com.google.android.horologist.compose.layout.ColumnItemType
40+
import com.google.android.horologist.compose.layout.ScalingLazyColumn
41+
import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults
42+
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
43+
import com.google.android.horologist.compose.layout.ScreenScaffold
44+
import com.google.android.horologist.compose.layout.rememberResponsiveColumnPadding
45+
import com.google.android.horologist.compose.layout.rememberResponsiveColumnState
46+
import com.google.android.horologist.compose.material.Button
47+
import com.google.android.horologist.compose.material.ListHeaderDefaults.firstItemPadding
48+
import com.google.android.horologist.compose.material.ResponsiveListHeader
49+
50+
@Composable
51+
fun ComposeList() {
52+
// [START android_wear_list]
53+
val columnState = rememberTransformingLazyColumnState()
54+
val contentPadding = rememberResponsiveColumnPadding(
55+
first = ColumnItemType.ListHeader,
56+
last = ColumnItemType.Button,
57+
)
58+
val transformationSpec = rememberTransformationSpec()
59+
ScreenScaffold(
60+
scrollState = columnState,
61+
contentPadding = contentPadding
62+
) { contentPadding ->
63+
TransformingLazyColumn(
64+
state = columnState,
65+
contentPadding = contentPadding
66+
) {
67+
item {
68+
ListHeader(
69+
modifier = Modifier.fillMaxWidth().transformedHeight(this, transformationSpec),
70+
transformation = SurfaceTransformation(transformationSpec)
71+
) {
72+
Text(text = "Header")
73+
}
74+
}
75+
// ... other items
76+
item {
77+
Button(
78+
modifier = Modifier.fillMaxWidth().transformedHeight(this, transformationSpec),
79+
transformation = SurfaceTransformation(transformationSpec),
80+
onClick = { /* ... */ },
81+
icon = {
82+
Icon(
83+
imageVector = Icons.Default.Build,
84+
contentDescription = "build",
85+
)
86+
},
87+
) {
88+
Text(
89+
text = "Build",
90+
maxLines = 1,
91+
overflow = TextOverflow.Ellipsis,
92+
)
93+
}
94+
}
95+
}
96+
}
97+
// [END android_wear_list]
98+
}
99+
100+
@OptIn(ExperimentalHorologistApi::class)
101+
@Composable
102+
fun SnapAndFlingComposeList() {
103+
// [START android_wear_snap]
104+
val columnState = rememberResponsiveColumnState(
105+
// ...
106+
// [START_EXCLUDE]
107+
contentPadding = ScalingLazyColumnDefaults.padding(
108+
first = ScalingLazyColumnDefaults.ItemType.Text,
109+
last = ScalingLazyColumnDefaults.ItemType.SingleButton
110+
),
111+
// [END_EXCLUDE]
112+
rotaryMode = ScalingLazyColumnState.RotaryMode.Snap
113+
)
114+
ScreenScaffold(scrollState = columnState) {
115+
ScalingLazyColumn(
116+
columnState = columnState
117+
) {
118+
// ...
119+
// [START_EXCLUDE]
120+
item {
121+
ResponsiveListHeader(contentPadding = firstItemPadding()) {
122+
androidx.wear.compose.material.Text(text = "Header")
123+
}
124+
}
125+
// ... other items
126+
item {
127+
Button(
128+
imageVector = Icons.Default.Build,
129+
contentDescription = "Example Button",
130+
onClick = { }
131+
)
132+
}
133+
// [END_EXCLUDE]
134+
}
135+
}
136+
// [END android_wear_snap]
137+
}
138+
139+
// [START android_wear_list_breakpoint]
140+
const val LARGE_DISPLAY_BREAKPOINT = 225
141+
142+
@Composable
143+
fun isLargeDisplay() =
144+
LocalConfiguration.current.screenWidthDp >= LARGE_DISPLAY_BREAKPOINT
145+
146+
// [START_EXCLUDE]
147+
@Composable
148+
fun breakpointDemo() {
149+
// [END_EXCLUDE]
150+
// ... use in your Composables:
151+
if (isLargeDisplay()) {
152+
// Show additional content.
153+
} else {
154+
// Show content only for smaller displays.
155+
}
156+
// [START_EXCLUDE]
157+
}
158+
// [END_EXCLUDE]
159+
// [END android_wear_list_breakpoint]
160+
161+
// [START android_wear_list_preview]
162+
@WearPreviewDevices
163+
@WearPreviewFontScales
164+
@Composable
165+
fun ComposeListPreview() {
166+
ComposeList()
167+
}
168+
// [END android_wear_list_preview]
169+
170+
@WearPreviewDevices
171+
@WearPreviewFontScales
172+
@Composable
173+
fun SnapAndFlingComposeListPreview() {
174+
SnapAndFlingComposeList()
175+
}

0 commit comments

Comments
 (0)