Skip to content

Commit 9420aff

Browse files
committed
Update to 1.5.0-beta01
Change-Id: I5acad074c6dc067b10d37ff1416c671e7c9c91b9
1 parent 187d70f commit 9420aff

File tree

11 files changed

+802
-14
lines changed

11 files changed

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

0 commit comments

Comments
 (0)