From fb654a90218dec10d36fc058b7350505f391bc30 Mon Sep 17 00:00:00 2001 From: Michael Stillwell Date: Wed, 27 Nov 2024 13:45:18 +0000 Subject: [PATCH] Init Wear Tiles snippets (#400) * Init Wear Tiles snippets * Add snippet markers * Add manifest snippet markers * Rename manifest snippet markers --- gradle/libs.versions.toml | 22 ++++++++ wear/build.gradle.kts | 11 ++++ wear/src/main/AndroidManifest.xml | 18 ++++++ .../com/example/wear/snippets/tile/Tile.kt | 53 ++++++++++++++++++ wear/src/main/res/drawable/tile_preview.png | Bin 0 -> 7335 bytes wear/src/main/res/values/strings.xml | 2 + 6 files changed, 106 insertions(+) create mode 100644 wear/src/main/java/com/example/wear/snippets/tile/Tile.kt create mode 100644 wear/src/main/res/drawable/tile_preview.png 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 0000000000000000000000000000000000000000..b2a254a16c2d32f4b8df60587fd240228e1f0505 GIT binary patch literal 7335 zcmeHM={uC~+rOo#?1lMe8CoTxvhRc_dt+_vLRpg-24g9aZBijyif>`Y81%K9p~6%X zD#locnrt%|+ZelN_&v|>#q$q5&x_xSd2!!!9p`mj=Vv)T$8kTgwlv{8Ds~hA0KV&{ zMmGU~BW~|^n2Y`9Z$fP=031oUYiMX4deh{pv}f4efCm@v1_3}s!CbDdweXLeoS8afP*c{%d*a$(&kmfs9dgKCQ0RJ!ba5O{rGkOIjZjD2`Sb4j zu&2iQP9O&%ku1p-0tFRCr!?sWkFFyM5VSc6lR2Ynw{0s4+$J2?xL#hx0bFlU#uugP zD5;-$@kH{_8EJtsfafovg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