diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6d03c099..6c83d9d7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,6 +30,7 @@ coroutines = "1.9.0" glide = "1.0.0-beta01" google-maps = "19.0.0" gradle-versions = "0.51.0" +guava = "33.2.1-android" hilt = "2.52" horologist = "0.6.20" junit = "4.13.2" @@ -44,12 +45,22 @@ media3 = "1.4.1" # @keep minSdk = "21" playServicesWearable = "18.2.0" +protolayout = "1.3.0-alpha04" +protolayoutExpression = "1.3.0-alpha04" +protolayoutMaterial = "1.3.0-alpha04" recyclerview = "1.3.2" # @keep targetSdk = "34" +tiles = "1.5.0-alpha04" +tilesRenderer = "1.5.0-alpha04" +tilesTesting = "1.5.0-alpha04" +tilesTooling = "1.5.0-alpha04" +tilesToolingPreview = "1.5.0-alpha04" version-catalog-update = "0.8.5" +wear = "1.3.0" wearComposeFoundation = "1.4.0" wearComposeMaterial = "1.4.0" +wearToolingPreview = "1.0.0" [libraries] accompanist-adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" } @@ -103,10 +114,20 @@ androidx-media3-common = { module = "androidx.media3:media3-common", version.ref androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" } androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "androidx-paging" } +androidx-protolayout = { module = "androidx.wear.protolayout:protolayout", version.ref = "protolayout" } +androidx-protolayout-expression = { module = "androidx.wear.protolayout:protolayout-expression", version.ref = "protolayoutExpression" } +androidx-protolayout-material = { module = "androidx.wear.protolayout:protolayout-material", version.ref = "protolayoutMaterial" } androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" } androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test" } androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-test-espresso" } androidx-test-runner = "androidx.test:runner:1.6.2" +androidx-tiles = { module = "androidx.wear.tiles:tiles", version.ref = "tiles" } +androidx-tiles-renderer = { module = "androidx.wear.tiles:tiles-renderer", version.ref = "tilesRenderer" } +androidx-tiles-testing = { module = "androidx.wear.tiles:tiles-testing", version.ref = "tilesTesting" } +androidx-tiles-tooling = { module = "androidx.wear.tiles:tiles-tooling", version.ref = "tilesTooling" } +androidx-tiles-tooling-preview = { module = "androidx.wear.tiles:tiles-tooling-preview", version.ref = "tilesToolingPreview" } +androidx-wear = { module = "androidx.wear:wear", version.ref = "wear" } +androidx-wear-tooling-preview = { module = "androidx.wear:wear-tooling-preview", version.ref = "wearToolingPreview" } androidx-window-core = { module = "androidx.window:window-core", version.ref = "androidx-window" } androidx-work-runtime-ktx = "androidx.work:work-runtime-ktx:2.10.0" coil-kt-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } @@ -117,6 +138,7 @@ glide-compose = { module = "com.github.bumptech.glide:compose", version.ref = "g google-android-material = { module = "com.google.android.material:material", version.ref = "material" } googlemaps-compose = { module = "com.google.maps.android:maps-compose", version.ref = "maps-compose" } googlemaps-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "google-maps" } +guava = { module = "com.google.guava:guava", version.ref = "guava" } hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" } hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" } horologist-compose-layout = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "horologist" } diff --git a/wear/build.gradle.kts b/wear/build.gradle.kts index 13fff794..154e7d37 100644 --- a/wear/build.gradle.kts +++ b/wear/build.gradle.kts @@ -55,6 +55,17 @@ dependencies { implementation(libs.compose.ui.tooling) implementation(libs.play.services.wearable) + implementation(libs.androidx.tiles) + implementation(libs.androidx.wear) + implementation(libs.androidx.protolayout) + implementation(libs.androidx.protolayout.material) + implementation(libs.androidx.protolayout.expression) + debugImplementation(libs.androidx.tiles.renderer) + testImplementation(libs.androidx.tiles.testing) + implementation(libs.androidx.wear.tooling.preview) + implementation(libs.androidx.tiles.tooling.preview) + debugImplementation(libs.androidx.tiles.tooling) + implementation(libs.guava) implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.compose.ui) implementation(libs.androidx.compose.ui.tooling.preview) diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index f0d2328e..84c4785a 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -34,6 +34,24 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/wear/src/main/java/com/example/wear/snippets/tile/Tile.kt b/wear/src/main/java/com/example/wear/snippets/tile/Tile.kt new file mode 100644 index 00000000..74a29483 --- /dev/null +++ b/wear/src/main/java/com/example/wear/snippets/tile/Tile.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.wear.snippets.tile + +import androidx.wear.protolayout.ColorBuilders.argb +import androidx.wear.protolayout.ResourceBuilders.Resources +import androidx.wear.protolayout.TimelineBuilders.Timeline +import androidx.wear.protolayout.material.Text +import androidx.wear.protolayout.material.Typography +import androidx.wear.tiles.RequestBuilders +import androidx.wear.tiles.RequestBuilders.ResourcesRequest +import androidx.wear.tiles.TileBuilders.Tile +import androidx.wear.tiles.TileService +import com.google.common.util.concurrent.Futures + +private const val RESOURCES_VERSION = "1" + +// [START android_wear_tile_mytileservice] +class MyTileService : TileService() { + + override fun onTileRequest(requestParams: RequestBuilders.TileRequest) = + Futures.immediateFuture(Tile.Builder() + .setResourcesVersion(RESOURCES_VERSION) + .setTileTimeline( + Timeline.fromLayoutElement( + Text.Builder(this, "Hello World!") + .setTypography(Typography.TYPOGRAPHY_BODY1) + .setColor(argb(0xFFFFFFFF.toInt())) + .build())) + .build()) + + override fun onTileResourcesRequest(requestParams: ResourcesRequest) = + Futures.immediateFuture(Resources.Builder() + .setVersion(RESOURCES_VERSION) + .build() + ) + +} +// [END android_wear_tile_mytileservice] \ No newline at end of file diff --git a/wear/src/main/res/drawable/tile_preview.png b/wear/src/main/res/drawable/tile_preview.png new file mode 100644 index 00000000..b2a254a1 Binary files /dev/null and b/wear/src/main/res/drawable/tile_preview.png differ diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 31b64b4d..fc59c67b 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -3,4 +3,6 @@ Voice Input Voice Text Entry Message List + Hello Tile + Hello Tile Description \ No newline at end of file