diff --git a/Complications/gradle/libs.versions.toml b/Complications/gradle/libs.versions.toml index f38b2d211..d5e5dc1b6 100644 --- a/Complications/gradle/libs.versions.toml +++ b/Complications/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -android-gradle-plugin = "8.5.1" +android-gradle-plugin = "8.5.2" androidx-wear-watchface = "1.2.1" org-jetbrains-kotlin = "1.9.24" diff --git a/ComposeStarter/gradle/libs.versions.toml b/ComposeStarter/gradle/libs.versions.toml index c53c4c4c3..40e7a7272 100644 --- a/ComposeStarter/gradle/libs.versions.toml +++ b/ComposeStarter/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -android-gradle-plugin = "8.5.1" +android-gradle-plugin = "8.5.2" androidx-activity = "1.9.1" androidx-compose-bom = "2024.06.00" androidx-wear-compose = "1.3.1" @@ -9,7 +9,7 @@ horologist = "0.5.28" ktlint = "0.50.0" org-jetbrains-kotlin = "1.9.24" robolectric = "4.13" -roborazzi = "1.25.0" +roborazzi = "1.26.0" ui-test-junit4 = "1.6.8" ui-test-manifest = "1.6.8" diff --git a/DataLayer/gradle/libs.versions.toml b/DataLayer/gradle/libs.versions.toml index 260736eef..88039f24c 100644 --- a/DataLayer/gradle/libs.versions.toml +++ b/DataLayer/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -android-gradle-plugin = "8.5.1" +android-gradle-plugin = "8.5.2" androidx-activity = "1.9.1" androidx-compose-bom = "2024.06.00" # do not bump to 2.8.0 until bumping to beta version of Compose @@ -12,7 +12,7 @@ org-jetbrains-kotlinx = "1.8.1" horologist = "0.5.28" compose-ui-tooling = "1.3.1" robolectric = "4.13" -roborazzi = "1.25.0" +roborazzi = "1.26.0" ui-test-junit4 = "1.6.8" ui-test-manifest = "1.6.8" diff --git a/WatchFaceFormat/Complications/build.gradle.kts b/WatchFaceFormat/Complications/build.gradle.kts index 40bd59ac0..4610d97f7 100644 --- a/WatchFaceFormat/Complications/build.gradle.kts +++ b/WatchFaceFormat/Complications/build.gradle.kts @@ -14,5 +14,5 @@ * limitations under the License. */ plugins { - id("com.android.application") version "8.5.1" apply false + id("com.android.application") version "8.5.2" apply false } \ No newline at end of file diff --git a/WatchFaceFormat/Flavors/build.gradle.kts b/WatchFaceFormat/Flavors/build.gradle.kts index 40bd59ac0..4610d97f7 100644 --- a/WatchFaceFormat/Flavors/build.gradle.kts +++ b/WatchFaceFormat/Flavors/build.gradle.kts @@ -14,5 +14,5 @@ * limitations under the License. */ plugins { - id("com.android.application") version "8.5.1" apply false + id("com.android.application") version "8.5.2" apply false } \ No newline at end of file diff --git a/WatchFaceFormat/SimpleAnalog/build.gradle.kts b/WatchFaceFormat/SimpleAnalog/build.gradle.kts index 40bd59ac0..4610d97f7 100644 --- a/WatchFaceFormat/SimpleAnalog/build.gradle.kts +++ b/WatchFaceFormat/SimpleAnalog/build.gradle.kts @@ -14,5 +14,5 @@ * limitations under the License. */ plugins { - id("com.android.application") version "8.5.1" apply false + id("com.android.application") version "8.5.2" apply false } \ No newline at end of file diff --git a/WatchFaceFormat/SimpleDigital/build.gradle.kts b/WatchFaceFormat/SimpleDigital/build.gradle.kts index 40bd59ac0..4610d97f7 100644 --- a/WatchFaceFormat/SimpleDigital/build.gradle.kts +++ b/WatchFaceFormat/SimpleDigital/build.gradle.kts @@ -14,5 +14,5 @@ * limitations under the License. */ plugins { - id("com.android.application") version "8.5.1" apply false + id("com.android.application") version "8.5.2" apply false } \ No newline at end of file diff --git a/WatchFaceFormat/Weather/build.gradle.kts b/WatchFaceFormat/Weather/build.gradle.kts index 40bd59ac0..4610d97f7 100644 --- a/WatchFaceFormat/Weather/build.gradle.kts +++ b/WatchFaceFormat/Weather/build.gradle.kts @@ -14,5 +14,5 @@ * limitations under the License. */ plugins { - id("com.android.application") version "8.5.1" apply false + id("com.android.application") version "8.5.2" apply false } \ No newline at end of file diff --git a/WatchFaceKotlin/gradle/libs.versions.toml b/WatchFaceKotlin/gradle/libs.versions.toml index c75b03191..2736fa4dc 100644 --- a/WatchFaceKotlin/gradle/libs.versions.toml +++ b/WatchFaceKotlin/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -android-gradle-plugin = "8.5.1" +android-gradle-plugin = "8.5.2" androidx-activity = "1.9.1" androidx-lifecycle = "2.8.4" androidx-test = "1.4.0" @@ -12,11 +12,11 @@ org-jetbrains-kotlin = "1.9.24" org-jetbrains-kotlinx = "1.8.1" [libraries] -android-lint-gradle = "com.android.tools.lint:lint-gradle:31.5.1" +android-lint-gradle = "com.android.tools.lint:lint-gradle:31.5.2" android-material = "com.google.android.material:material:1.12.0" androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } androidx-core-ktx = "androidx.core:core-ktx:1.13.1" -androidx-databinding-viewbinding = "androidx.databinding:viewbinding:8.5.1" +androidx-databinding-viewbinding = "androidx.databinding:viewbinding:8.5.2" androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" } androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" } androidx-wear = "androidx.wear:wear:1.3.0" diff --git a/WearOAuth/gradle/libs.versions.toml b/WearOAuth/gradle/libs.versions.toml index 7207aba53..504f58b85 100644 --- a/WearOAuth/gradle/libs.versions.toml +++ b/WearOAuth/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -android-gradle-plugin = "8.5.1" +android-gradle-plugin = "8.5.2" androidx-compose-bom = "2024.06.00" androidx-activity = "1.9.1" androidx-lifecycle = "2.8.4" androidx-test = "1.5.2" androidx-wear-compose = "1.4.0-beta03" -compose = "1.7.0-beta06" +compose = "1.7.0-beta07" compose-compiler = "1.5.14" org-jetbrains-kotlin = "1.9.24" org-jetbrains-kotlinx = "1.8.1" @@ -13,15 +13,15 @@ ktlint = "0.50.0" compose-material3 = "1.0.0-alpha23" horologist = "0.6.12" robolectric = "4.13" -roborazzi = "1.25.0" +roborazzi = "1.26.0" ui-test-junit4 = "1.6.8" [libraries] android-build-gradle = { module = "com.android.tools.build:gradle", version.ref = "android-gradle-plugin" } android-desugarjdklibs = "com.android.tools:desugar_jdk_libs:2.0.4" -android-lint-gradle = "com.android.tools.lint:lint-gradle:31.5.1" +android-lint-gradle = "com.android.tools.lint:lint-gradle:31.5.2" android-material = "com.google.android.material:material:1.12.0" -android-tools-lint-gradle = "com.android.tools.lint:lint-gradle:31.5.1" +android-tools-lint-gradle = "com.android.tools.lint:lint-gradle:31.5.2" androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } androidx-appcompat = "androidx.appcompat:appcompat:1.7.0" @@ -30,7 +30,7 @@ androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", versi androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4" androidx-constraintlayout-compose = "androidx.constraintlayout:constraintlayout-compose:1.0.1" androidx-core-ktx = "androidx.core:core-ktx:1.13.1" -androidx-databinding-viewbinding = "androidx.databinding:viewbinding:8.5.1" +androidx-databinding-viewbinding = "androidx.databinding:viewbinding:8.5.2" androidx-datastore-preferences = "androidx.datastore:datastore-preferences:1.1.1" androidx-fragment-ktx = "androidx.fragment:fragment-ktx:1.8.2" androidx-lifecycle-common-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "androidx-lifecycle" } diff --git a/WearSpeakerSample/gradle/libs.versions.toml b/WearSpeakerSample/gradle/libs.versions.toml index 13be4ae8b..4beae3b18 100644 --- a/WearSpeakerSample/gradle/libs.versions.toml +++ b/WearSpeakerSample/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -android-gradle-plugin = "8.5.1" +android-gradle-plugin = "8.5.2" androidx-activity = "1.9.1" androidx-compose-bom = "2024.06.00" androidx-lifecycle = "2.7.0" @@ -10,7 +10,7 @@ compose-ui-tooling = "1.3.1" ktlint = "0.50.0" org-jetbrains-kotlin = "1.9.24" robolectric = "4.13" -roborazzi = "1.25.0" +roborazzi = "1.26.0" ui-test-junit4 = "1.6.8" ui-test-manifest = "1.6.8" horologist = "0.5.28" diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Alarm.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Alarm.kt index b23eb6709..61523f1f7 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Alarm.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Alarm.kt @@ -77,8 +77,8 @@ object Alarm { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) @Preview(device = WearDevices.LARGE_ROUND) -@Preview(device = WearDevices.LARGE_ROUND, fontScale = 1.24f) -fun AlarmPreview(context: Context) = TilePreviewData { +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun alarmPreview(context: Context) = TilePreviewData { TilePreviewHelper.singleTimelineEntryTileBuilder( Alarm.layout( context, diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Calendar.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Calendar.kt index 796fc7207..66c21d6c4 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Calendar.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Calendar.kt @@ -68,8 +68,8 @@ object Calendar { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) @Preview(device = WearDevices.LARGE_ROUND) -@Preview(device = WearDevices.LARGE_ROUND, fontScale = 1.24f) -fun CalendarPreview(context: Context) = TilePreviewData { +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun calendarPreview(context: Context) = TilePreviewData { TilePreviewHelper.singleTimelineEntryTileBuilder( Calendar.layout( context, diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Goal.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Goal.kt index fa0082210..4b0db0f8e 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Goal.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Goal.kt @@ -23,10 +23,15 @@ import androidx.wear.protolayout.material.ProgressIndicatorColors import androidx.wear.protolayout.material.Text import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.EdgeContentLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper.singleTimelineEntryTileBuilder +import androidx.wear.tooling.preview.devices.WearDevices object Goal { fun layout(context: Context, deviceParameters: DeviceParameters, steps: Int, goal: Int) = EdgeContentLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setEdgeContent( CircularProgressIndicator.Builder() .setProgress(steps.toFloat() / goal) @@ -60,3 +65,15 @@ private fun blueOnTranslucentWhite() = ProgressIndicatorColors( /* trackColor = */ ColorBuilders.argb(GoldenTilesColors.White10Pc) ) + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun goalPreview(context: Context) = TilePreviewData { + singleTimelineEntryTileBuilder( + Goal.layout( + context, it.deviceConfiguration, steps = 5168, goal = 8000 + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow1.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow1.kt index b74ded52e..51f25671c 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow1.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow1.kt @@ -19,90 +19,30 @@ import android.content.Context import androidx.wear.protolayout.ResourceBuilders import androidx.wear.tiles.RequestBuilders import androidx.wear.tiles.tooling.preview.Preview -import androidx.wear.tiles.tooling.preview.TilePreviewData -import androidx.wear.tiles.tooling.preview.TilePreviewHelper.singleTimelineEntryTileBuilder import androidx.wear.tooling.preview.devices.WearDevices -import com.example.wear.tiles.R -import com.example.wear.tiles.tools.emptyClickable -import com.google.android.horologist.tiles.images.drawableResToImageResource @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Goal(context: Context) = TilePreviewData { - singleTimelineEntryTileBuilder( - Goal.layout( - context, it.deviceConfiguration, steps = 5168, goal = 8000 - ) - ).build() -} +private fun goal(context: Context) = goalPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun WorkoutButtons(context: Context) = TilePreviewData(onTileResourceRequest = resources { - addIdToImageMapping( - Workout.BUTTON_1_ICON_ID, drawableResToImageResource(R.drawable.ic_run_24) - ) - addIdToImageMapping( - Workout.BUTTON_2_ICON_ID, drawableResToImageResource(R.drawable.ic_yoga_24) - ) - addIdToImageMapping( - Workout.BUTTON_3_ICON_ID, drawableResToImageResource(R.drawable.ic_cycling_24) - ) -}) { - singleTimelineEntryTileBuilder( - Workout.buttonsLayout( - context, - it.deviceConfiguration, - weekSummary = "1 run this week", - button1Clickable = emptyClickable, - button2Clickable = emptyClickable, - button3Clickable = emptyClickable, - chipClickable = emptyClickable - ) - ).build() -} +private fun workoutButtons(context: Context) = workoutButtonsPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun WorkoutLargeChip(context: Context) = TilePreviewData { - singleTimelineEntryTileBuilder( - Workout.largeChipLayout( - context, - it.deviceConfiguration, - clickable = emptyClickable, - lastWorkoutSummary = "Last session 45m" - ) - ).build() -} +private fun workoutLargeChip(context: Context) = workoutLargeChipPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Run(context: Context) = TilePreviewData { - singleTimelineEntryTileBuilder( - Run.layout( - context, - it.deviceConfiguration, - lastRunText = "2 days ago", - startRunClickable = emptyClickable, - moreChipClickable = emptyClickable - ) - ).build() -} +private fun run(context: Context) = runPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Ski(context: Context) = TilePreviewData { - singleTimelineEntryTileBuilder( - Ski.layout( - context, - stat1 = Ski.Stat("Max Spd", "46.5", "mph"), - stat2 = Ski.Stat("Distance", "21.8", "mile") - ) - ).build() -} +private fun ski(context: Context) = skiPreview(context) //@Preview -fun SleepTracker(context: Context) { +fun sleepTracker(context: Context) { // TODO: This tile doesn't use standard components; we can achieve it by drawing on a Canvas (Compose's DrawScope) then converting it to a bitmap using Horologist } diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow2.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow2.kt index 83c9ebd18..28e88e266 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow2.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow2.kt @@ -29,25 +29,16 @@ import com.google.android.horologist.tiles.images.drawableResToImageResource */ @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun HeartRateSimple(context: Context) = TilePreviewData { - TilePreviewHelper.singleTimelineEntryTileBuilder( - HeartRate.simpleLayout( - context, - it.deviceConfiguration, - heartRateBpm = 86, - clickable = emptyClickable - ) - ).build() -} +private fun heartRateSimple(context: Context) = heartRateSimplePreview(context) //@Preview -fun HeartRateGraph(context: Context) { +private fun heartRateGraph(context: Context) { TODO() } @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun MeditationChips(context: Context) = TilePreviewData(resources { +private fun meditationChips(context: Context) = TilePreviewData(resources { addIdToImageMapping( Meditation.CHIP_1_ICON_ID, drawableResToImageResource(R.drawable.ic_breathe_24) @@ -79,48 +70,12 @@ fun MeditationChips(context: Context) = TilePreviewData(resources { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun MeditationButtons(context: Context) = TilePreviewData { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Meditation.buttonsLayout( - context, - it.deviceConfiguration, - timer1 = Meditation.Timer(minutes = 5, clickable = emptyClickable), - timer2 = Meditation.Timer(minutes = 10, clickable = emptyClickable), - timer3 = Meditation.Timer(minutes = 15, clickable = emptyClickable), - clickable = emptyClickable - ) - ).build() -} +private fun meditationButtons(context: Context) = meditationButtonsPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Timer(context: Context) = TilePreviewData { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Timer.layout( - context, - it.deviceConfiguration, - timer1 = Timer.Timer(minutes = "05", clickable = emptyClickable), - timer2 = Timer.Timer(minutes = "10", clickable = emptyClickable), - timer3 = Timer.Timer(minutes = "15", clickable = emptyClickable), - timer4 = Timer.Timer(minutes = "20", clickable = emptyClickable), - timer5 = Timer.Timer(minutes = "30", clickable = emptyClickable), - timer6 = Timer.Timer(minutes = "45", clickable = emptyClickable), - clickable = emptyClickable - ) - ).build() -} +private fun timer(context: Context) = timerPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Alarm(context: Context) = TilePreviewData { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Alarm.layout( - context, - it.deviceConfiguration, - timeUntilAlarm = "Less than 1 min", - alarmTime = "14:58", - alarmDays = "Mon, Tue, Wed, Thu, Fri,Sat", - clickable = emptyClickable - ) - ).build() -} +private fun alarm(context: Context) = alarmPreview(context) diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow3.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow3.kt index 407bb1e73..8db7122a3 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow3.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/GoldenTilesPreviewsRow3.kt @@ -17,140 +17,33 @@ package com.example.wear.tiles.golden import android.content.Context import androidx.wear.tiles.tooling.preview.Preview -import androidx.wear.tiles.tooling.preview.TilePreviewData -import androidx.wear.tiles.tooling.preview.TilePreviewHelper import androidx.wear.tooling.preview.devices.WearDevices -import com.example.wear.tiles.R -import com.example.wear.tiles.tools.emptyClickable -import com.google.android.horologist.tiles.images.drawableResToImageResource -import java.time.Clock -import java.time.LocalDate -import java.time.LocalDateTime -import java.time.ZoneOffset /** * b/238560022 misaligned because we can't add an offset, small preview is clipped */ @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Weather(context: Context) = TilePreviewData(resources { - addIdToImageMapping( - Weather.SCATTERED_SHOWERS_ICON_ID, - drawableResToImageResource(R.drawable.scattered_showers) - ) -}) { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Weather.layout( - context, - it.deviceConfiguration, - location = "San Francisco", - weatherIconId = Weather.SCATTERED_SHOWERS_ICON_ID, - currentTemperature = "52°", - lowTemperature = "48°", - highTemperature = "64°", - weatherSummary = "Showers" - ) - ).build() -} +private fun weather(context: Context) = weatherPreview(context) /** * b/238556504 alignment doesn't match figma. */ @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun News(context: Context) = TilePreviewData { - val now = LocalDateTime.of(2024, 8, 1, 0, 0).toInstant(ZoneOffset.UTC) - val clock = Clock.fixed(now, Clock.systemUTC().zone) - - TilePreviewHelper.singleTimelineEntryTileBuilder( - News.layout( - context, - it.deviceConfiguration, - headline = "Millions still without power as new storm moves across US", - newsVendor = "The New York Times", - date = LocalDate.now(clock).minusDays(1), - clock = clock, - clickable = emptyClickable - ) - ).build() -} +private fun news(context: Context) = newsPreview(context) /** * b/238571095 Alignment doesn't match Figma */ @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Calendar(context: Context) = TilePreviewData { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Calendar.layout( - context, - it.deviceConfiguration, - eventTime = "6:30-7:30 PM", - eventName = "Morning Pilates with Christina Lloyd", - eventLocation = "216 Market Street", - clickable = emptyClickable - ) - ).build() -} +private fun calendar(context: Context) = calendarPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Social(context: Context) = TilePreviewData(resources { - addIdToImageMapping(Social.AVATAR_ID_1, drawableResToImageResource(R.drawable.avatar1)) - addIdToImageMapping(Social.AVATAR_ID_2, drawableResToImageResource(R.drawable.avatar2)) -}) { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Social.layout( - context, - it.deviceConfiguration, - Social.Contact( - initials = "AC", - clickable = emptyClickable, - avatarId = Social.AVATAR_ID_1 - ), - Social.Contact(initials = "AD", clickable = emptyClickable, avatarId = null), - Social.Contact( - initials = "BD", - color = GoldenTilesColors.Purple, - clickable = emptyClickable, - avatarId = null - ), - Social.Contact( - initials = "DC", - clickable = emptyClickable, - avatarId = Social.AVATAR_ID_2 - ) - ) - ).build() -} +private fun social(context: Context) = socialPreview(context) @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.LARGE_ROUND) -fun Media(context: Context) = TilePreviewData(resources { - addIdToImageMapping( - Media.CHIP_1_ICON_ID, - drawableResToImageResource(R.drawable.ic_music_queue_24) - ) - addIdToImageMapping( - Media.CHIP_2_ICON_ID, - drawableResToImageResource(R.drawable.ic_podcasts_24) - ) -}) { - TilePreviewHelper.singleTimelineEntryTileBuilder( - Media.layout( - context, - it.deviceConfiguration, - playlist1 = Media.Playlist( - label = "Liked songs", - iconId = Media.CHIP_1_ICON_ID, - clickable = emptyClickable - ), - playlist2 = Media.Playlist( - label = "Podcasts", - iconId = Media.CHIP_2_ICON_ID, - clickable = emptyClickable - ), - browseClickable = emptyClickable - ) - ).build() -} +private fun media(context: Context) = mediaPreview(context) diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/HeartRate.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/HeartRate.kt index 8581b32d1..6aaff4ffc 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/HeartRate.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/HeartRate.kt @@ -18,21 +18,30 @@ package com.example.wear.tiles.golden import android.content.Context import androidx.wear.protolayout.ColorBuilders import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters +import androidx.wear.protolayout.LayoutElementBuilders.Column import androidx.wear.protolayout.ModifiersBuilders.Clickable import androidx.wear.protolayout.material.ChipColors import androidx.wear.protolayout.material.CompactChip import androidx.wear.protolayout.material.Text import androidx.wear.protolayout.material.Typography +import androidx.wear.protolayout.material.layouts.MultiSlotLayout import androidx.wear.protolayout.material.layouts.PrimaryLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper +import androidx.wear.tooling.preview.devices.WearDevices +import com.example.wear.tiles.tools.emptyClickable object HeartRate { fun simpleLayout( context: Context, deviceParameters: DeviceParameters, - heartRateBpm: Int, + highestHeartRateBpm: Int, + lowestHeartRateBpm: Int, clickable: Clickable ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setPrimaryLabelTextContent( Text.Builder(context, "Now") .setTypography(Typography.TYPOGRAPHY_CAPTION1) @@ -40,9 +49,48 @@ object HeartRate { .build() ) .setContent( - Text.Builder(context, heartRateBpm.toString()) - .setTypography(Typography.TYPOGRAPHY_DISPLAY1) - .setColor(ColorBuilders.argb(GoldenTilesColors.White)) + MultiSlotLayout.Builder() + .setHorizontalSpacerWidth(16f) + .addSlotContent( + Column.Builder() + .apply { + if (deviceParameters.screenWidthDp > 225) { + addContent( + Text.Builder(context, "Highest") + .setTypography(Typography.TYPOGRAPHY_BUTTON) + .setColor(ColorBuilders.argb(GoldenTilesColors.LightRed)) + .build() + ) + } + } + .addContent( + Text.Builder(context, highestHeartRateBpm.toString()) + .setTypography(Typography.TYPOGRAPHY_DISPLAY1) + .setColor(ColorBuilders.argb(GoldenTilesColors.White)) + .build() + ) + .build() + ) + .apply { + if (deviceParameters.screenWidthDp > 225) { + addSlotContent( + Column.Builder() + .addContent( + Text.Builder(context, "Lowest") + .setTypography(Typography.TYPOGRAPHY_BUTTON) + .setColor(ColorBuilders.argb(GoldenTilesColors.LightRed)) + .build() + ) + .addContent( + Text.Builder(context, lowestHeartRateBpm.toString()) + .setTypography(Typography.TYPOGRAPHY_DISPLAY1) + .setColor(ColorBuilders.argb(GoldenTilesColors.White)) + .build() + ) + .build() + ) + } + } .build() ) @@ -66,3 +114,19 @@ object HeartRate { ) .build() } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun heartRateSimplePreview(context: Context) = TilePreviewData { + TilePreviewHelper.singleTimelineEntryTileBuilder( + HeartRate.simpleLayout( + context, + it.deviceConfiguration, + highestHeartRateBpm = 86, + lowestHeartRateBpm = 54, + clickable = emptyClickable + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Media.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Media.kt index e98c78bb7..3ac3eead6 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Media.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Media.kt @@ -114,8 +114,8 @@ object Media { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) @Preview(device = WearDevices.LARGE_ROUND) -@Preview(device = WearDevices.LARGE_ROUND, fontScale = 1.24f) -fun MediaPreview(context: Context) = TilePreviewData(resources { +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun mediaPreview(context: Context) = TilePreviewData(resources { addIdToImageMapping( Media.CHIP_1_ICON_ID, drawableResToImageResource(R.drawable.ic_music_queue_24) diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Meditation.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Meditation.kt index 4b8bf74cb..f2e68672c 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Meditation.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Meditation.kt @@ -121,8 +121,11 @@ object Meditation { timer1: Timer, timer2: Timer, timer3: Timer, + timer4: Timer, + timer5: Timer, clickable: Clickable ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setPrimaryLabelTextContent( Text.Builder(context, "Minutes") .setTypography(Typography.TYPOGRAPHY_CAPTION1) @@ -134,6 +137,12 @@ object Meditation { .addButtonContent(timerButton(context, timer1)) .addButtonContent(timerButton(context, timer2)) .addButtonContent(timerButton(context, timer3)) + .apply { + if (deviceParameters.screenWidthDp > 225) { + addButtonContent(timerButton(context, timer4)) + addButtonContent(timerButton(context, timer5)) + } + } .build() ) .setPrimaryChipContent( @@ -170,8 +179,8 @@ object Meditation { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) @Preview(device = WearDevices.LARGE_ROUND) -@Preview(device = WearDevices.LARGE_ROUND, fontScale = 1.24f) -fun MeditationChipsPreview(context: Context) = TilePreviewData(resources { +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun meditationChipsPreview(context: Context) = TilePreviewData(resources { addIdToImageMapping( Meditation.CHIP_1_ICON_ID, drawableResToImageResource(R.drawable.ic_breathe_24) @@ -200,3 +209,22 @@ fun MeditationChipsPreview(context: Context) = TilePreviewData(resources { ) ).build() } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun meditationButtonsPreview(context: Context) = TilePreviewData { + TilePreviewHelper.singleTimelineEntryTileBuilder( + Meditation.buttonsLayout( + context, + it.deviceConfiguration, + timer1 = Meditation.Timer(minutes = 5, clickable = emptyClickable), + timer2 = Meditation.Timer(minutes = 10, clickable = emptyClickable), + timer3 = Meditation.Timer(minutes = 15, clickable = emptyClickable), + timer4 = Meditation.Timer(minutes = 20, clickable = emptyClickable), + timer5 = Meditation.Timer(minutes = 25, clickable = emptyClickable), + clickable = emptyClickable + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/News.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/News.kt index 5f4427b82..3f9e2620b 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/News.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/News.kt @@ -48,14 +48,15 @@ object News { ) = PrimaryLayout.Builder(deviceParameters) .setResponsiveContentInsetEnabled(true) .apply { - if (deviceParameters.screenWidthDp > 225) { + if (deviceParameters.screenWidthDp > 225) { setPrimaryLabelTextContent( Text.Builder(context, date.formatLocalDateTime(today = LocalDate.now(clock))) .setColor(ColorBuilders.argb(GoldenTilesColors.White)) .setTypography(Typography.TYPOGRAPHY_CAPTION1) .build() ) - } } + } + } .setContent( Text.Builder(context, headline) .setMaxLines(3) @@ -75,7 +76,7 @@ object News { .build() } -fun LocalDate.formatLocalDateTime(today: LocalDate = LocalDate.now()): String { +internal fun LocalDate.formatLocalDateTime(today: LocalDate = LocalDate.now()): String { val yesterday = today.minusDays(1) return when { @@ -88,8 +89,8 @@ fun LocalDate.formatLocalDateTime(today: LocalDate = LocalDate.now()): String { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) @Preview(device = WearDevices.LARGE_ROUND) -@Preview(device = WearDevices.LARGE_ROUND, fontScale = 1.24f) -fun NewsPreview(context: Context) = TilePreviewData { +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun newsPreview(context: Context) = TilePreviewData { val now = LocalDateTime.of(2024, 8, 1, 0, 0).toInstant(ZoneOffset.UTC) val clock = Clock.fixed(now, Clock.systemUTC().zone) diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Run.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Run.kt index 25ad71f46..4dd777784 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Run.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Run.kt @@ -26,6 +26,11 @@ import androidx.wear.protolayout.material.Text import androidx.wear.protolayout.material.TitleChip import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.PrimaryLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper.singleTimelineEntryTileBuilder +import androidx.wear.tooling.preview.devices.WearDevices +import com.example.wear.tiles.tools.emptyClickable object Run { @@ -33,9 +38,11 @@ object Run { context: Context, deviceParameters: DeviceParameters, lastRunText: String, + chanceOfRain: Int, startRunClickable: Clickable, moreChipClickable: Clickable ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setPrimaryLabelTextContent( Text.Builder(context, lastRunText) .setTypography(Typography.TYPOGRAPHY_CAPTION1) @@ -58,6 +65,16 @@ object Run { ) .build() ) + .apply { + if (deviceParameters.screenWidthDp > 225) { + setSecondaryLabelTextContent( + Text.Builder(context, "$chanceOfRain% chance of rain") + .setTypography(Typography.TYPOGRAPHY_CAPTION1) + .setColor(ColorBuilders.argb(GoldenTilesColors.LightGray)) + .build() + ) + } + } .setPrimaryChipContent( CompactChip.Builder(context, "More", moreChipClickable, deviceParameters) .setChipColors( @@ -72,3 +89,20 @@ object Run { ) .build() } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun runPreview(context: Context) = TilePreviewData { + singleTimelineEntryTileBuilder( + Run.layout( + context, + it.deviceConfiguration, + lastRunText = "2 days ago", + chanceOfRain = 20, + startRunClickable = emptyClickable, + moreChipClickable = emptyClickable + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Ski.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Ski.kt index b3111ae7a..0966e3869 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Ski.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Ski.kt @@ -17,21 +17,29 @@ package com.example.wear.tiles.golden import android.content.Context import androidx.wear.protolayout.ColorBuilders -import androidx.wear.protolayout.DimensionBuilders +import androidx.wear.protolayout.DeviceParametersBuilders import androidx.wear.protolayout.LayoutElementBuilders import androidx.wear.protolayout.material.Text import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.MultiSlotLayout +import androidx.wear.protolayout.material.layouts.PrimaryLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper +import androidx.wear.tooling.preview.devices.WearDevices object Ski { - fun layout(context: Context, stat1: Stat, stat2: Stat) = LayoutElementBuilders.Box.Builder() - .setHorizontalAlignment(LayoutElementBuilders.HORIZONTAL_ALIGN_CENTER) - .setVerticalAlignment(LayoutElementBuilders.VERTICAL_ALIGN_CENTER) - .setHeight(DimensionBuilders.ExpandedDimensionProp.Builder().build()) - .setWidth(DimensionBuilders.ExpandedDimensionProp.Builder().build()) - .addContent( + fun layout( + context: Context, + deviceParameters: DeviceParametersBuilders.DeviceParameters, + stat1: Stat, + stat2: Stat + ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) + .setContent( MultiSlotLayout.Builder() + .setHorizontalSpacerWidth(16f) .addSlotContent(statColumn(context, stat1)) .addSlotContent(statColumn(context, stat2)) .build() @@ -61,3 +69,18 @@ object Ski { data class Stat(val label: String, val value: String, val unit: String) } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun skiPreview(context: Context) = TilePreviewData { + TilePreviewHelper.singleTimelineEntryTileBuilder( + Ski.layout( + context, + it.deviceConfiguration, + stat1 = Ski.Stat("Max Spd", "46.5", "mph"), + stat2 = Ski.Stat("Distance", "21.8", "mile") + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Social.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Social.kt index 629f4053d..77e33ee7e 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Social.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Social.kt @@ -25,26 +25,36 @@ import androidx.wear.protolayout.material.ButtonColors import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.MultiButtonLayout import androidx.wear.protolayout.material.layouts.PrimaryLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper +import androidx.wear.tooling.preview.devices.WearDevices +import com.example.wear.tiles.R +import com.example.wear.tiles.tools.emptyClickable +import com.google.android.horologist.tiles.images.drawableResToImageResource object Social { const val AVATAR_ID_1 = "social avatar id 1" const val AVATAR_ID_2 = "social avatar id 2" + const val AVATAR_ID_3 = "social avatar id 3" + const val AVATAR_ID_4 = "social avatar id 4" fun layout( context: Context, deviceParameters: DeviceParameters, - contact1: Contact, - contact2: Contact, - contact3: Contact, - contact4: Contact + contacts: List ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setContent( MultiButtonLayout.Builder() - .addButtonContent(button(context, contact1)) - .addButtonContent(button(context, contact2)) - .addButtonContent(button(context, contact3)) - .addButtonContent(button(context, contact4)) + .apply { + contacts + .take(if (deviceParameters.screenWidthDp > 225) 6 else 4) + .forEach { contact -> + addButtonContent(button(context, contact)) + } + } .build() ) .build() @@ -77,3 +87,50 @@ object Social { val avatarId: String? ) } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun socialPreview(context: Context) = TilePreviewData(resources { + addIdToImageMapping(Social.AVATAR_ID_1, drawableResToImageResource(R.drawable.avatar1)) + addIdToImageMapping(Social.AVATAR_ID_2, drawableResToImageResource(R.drawable.avatar2)) + addIdToImageMapping(Social.AVATAR_ID_3, drawableResToImageResource(R.drawable.avatar3)) + addIdToImageMapping(Social.AVATAR_ID_4, drawableResToImageResource(R.drawable.avatar4)) +}) { + TilePreviewHelper.singleTimelineEntryTileBuilder( + Social.layout( + context, + it.deviceConfiguration, + listOf( + Social.Contact( + initials = "AC", + clickable = emptyClickable, + avatarId = Social.AVATAR_ID_1 + ), + Social.Contact(initials = "AD", clickable = emptyClickable, avatarId = null), + Social.Contact( + initials = "BD", + color = GoldenTilesColors.Purple, + clickable = emptyClickable, + avatarId = null + ), + Social.Contact( + initials = "DC", + clickable = emptyClickable, + avatarId = Social.AVATAR_ID_2 + ), + Social.Contact( + initials = "DA", + clickable = emptyClickable, + avatarId = Social.AVATAR_ID_3 + ), + Social.Contact( + initials = "DB", + clickable = emptyClickable, + avatarId = Social.AVATAR_ID_4 + ), + ) + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Timer.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Timer.kt index 0a6cf0f4c..8d970102c 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Timer.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Timer.kt @@ -37,26 +37,18 @@ object Timer { fun layout( context: Context, deviceParameters: DeviceParameters, - timer1: Timer, - timer2: Timer, - timer3: Timer, - timer4: Timer, - timer5: Timer, - timer6: Timer, + timerList: List, clickable: Clickable ) = PrimaryLayout.Builder(deviceParameters) .setResponsiveContentInsetEnabled(true) .setContent( MultiButtonLayout.Builder() - .addButtonContent(timerButton(context, timer1)) - .addButtonContent(timerButton(context, timer2)) - .addButtonContent(timerButton(context, timer3)) - .addButtonContent(timerButton(context, timer4)) - .addButtonContent(timerButton(context, timer5)) .apply { - if (deviceParameters.screenWidthDp > 225) { - addButtonContent(timerButton(context, timer6)) - } + timerList + .take(if (deviceParameters.screenWidthDp > 225) 6 else 5) + .forEach { timer -> + addButtonContent(timerButton(context, timer)) + } } .build() ) @@ -93,18 +85,20 @@ object Timer { @Preview(device = WearDevices.SMALL_ROUND) @Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) @Preview(device = WearDevices.LARGE_ROUND) -@Preview(device = WearDevices.LARGE_ROUND, fontScale = 1.24f) -fun TimerPreview(context: Context) = TilePreviewData { +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun timerPreview(context: Context) = TilePreviewData { TilePreviewHelper.singleTimelineEntryTileBuilder( Timer.layout( context, it.deviceConfiguration, - timer1 = Timer.Timer(minutes = "05", clickable = emptyClickable), - timer2 = Timer.Timer(minutes = "10", clickable = emptyClickable), - timer3 = Timer.Timer(minutes = "15", clickable = emptyClickable), - timer4 = Timer.Timer(minutes = "20", clickable = emptyClickable), - timer5 = Timer.Timer(minutes = "30", clickable = emptyClickable), - timer6 = Timer.Timer(minutes = "45", clickable = emptyClickable), + timerList = listOf( + Timer.Timer(minutes = "05", clickable = emptyClickable), + Timer.Timer(minutes = "10", clickable = emptyClickable), + Timer.Timer(minutes = "15", clickable = emptyClickable), + Timer.Timer(minutes = "20", clickable = emptyClickable), + Timer.Timer(minutes = "30", clickable = emptyClickable), + Timer.Timer(minutes = "45", clickable = emptyClickable) + ), clickable = emptyClickable ) ).build() diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Weather.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Weather.kt index 9463b6841..4574ed669 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Weather.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Weather.kt @@ -25,6 +25,12 @@ import androidx.wear.protolayout.material.Text import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.MultiSlotLayout import androidx.wear.protolayout.material.layouts.PrimaryLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper +import androidx.wear.tooling.preview.devices.WearDevices +import com.example.wear.tiles.R +import com.google.android.horologist.tiles.images.drawableResToImageResource object Weather { @@ -40,6 +46,7 @@ object Weather { highTemperature: String, weatherSummary: String ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setPrimaryLabelTextContent( Text.Builder(context, location) .setColor(ColorBuilders.argb(GoldenTilesColors.Blue)) @@ -87,3 +94,27 @@ object Weather { ) .build() } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun weatherPreview(context: Context) = TilePreviewData(resources { + addIdToImageMapping( + Weather.SCATTERED_SHOWERS_ICON_ID, + drawableResToImageResource(R.drawable.scattered_showers) + ) +}) { + TilePreviewHelper.singleTimelineEntryTileBuilder( + Weather.layout( + context, + it.deviceConfiguration, + location = "San Francisco", + weatherIconId = Weather.SCATTERED_SHOWERS_ICON_ID, + currentTemperature = "52°", + lowTemperature = "48°", + highTemperature = "64°", + weatherSummary = "Showers" + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Workout.kt b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Workout.kt index 459c73d8d..a344081ec 100644 --- a/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Workout.kt +++ b/WearTilesKotlin/app/src/debug/java/com/example/wear/tiles/golden/Workout.kt @@ -28,6 +28,13 @@ import androidx.wear.protolayout.material.TitleChip import androidx.wear.protolayout.material.Typography import androidx.wear.protolayout.material.layouts.MultiButtonLayout import androidx.wear.protolayout.material.layouts.PrimaryLayout +import androidx.wear.tiles.tooling.preview.Preview +import androidx.wear.tiles.tooling.preview.TilePreviewData +import androidx.wear.tiles.tooling.preview.TilePreviewHelper.singleTimelineEntryTileBuilder +import androidx.wear.tooling.preview.devices.WearDevices +import com.example.wear.tiles.R +import com.example.wear.tiles.tools.emptyClickable +import com.google.android.horologist.tiles.images.drawableResToImageResource object Workout { const val BUTTON_1_ICON_ID = "workout 1" @@ -44,6 +51,7 @@ object Workout { chipClickable: ModifiersBuilders.Clickable ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setPrimaryLabelTextContent( Text.Builder(context, weekSummary) .setTypography(Typography.TYPOGRAPHY_CAPTION1) @@ -86,6 +94,7 @@ object Workout { clickable: ModifiersBuilders.Clickable, lastWorkoutSummary: String ) = PrimaryLayout.Builder(deviceParameters) + .setResponsiveContentInsetEnabled(true) .setPrimaryLabelTextContent( Text.Builder(context, "Power Yoga") .setTypography(Typography.TYPOGRAPHY_CAPTION1) @@ -116,3 +125,48 @@ object Workout { ) .build() } + + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun workoutButtonsPreview(context: Context) = + TilePreviewData(onTileResourceRequest = resources { + addIdToImageMapping( + Workout.BUTTON_1_ICON_ID, drawableResToImageResource(R.drawable.ic_run_24) + ) + addIdToImageMapping( + Workout.BUTTON_2_ICON_ID, drawableResToImageResource(R.drawable.ic_yoga_24) + ) + addIdToImageMapping( + Workout.BUTTON_3_ICON_ID, drawableResToImageResource(R.drawable.ic_cycling_24) + ) + }) { + singleTimelineEntryTileBuilder( + Workout.buttonsLayout( + context, + it.deviceConfiguration, + weekSummary = "1 run this week", + button1Clickable = emptyClickable, + button2Clickable = emptyClickable, + button3Clickable = emptyClickable, + chipClickable = emptyClickable + ) + ).build() + } + +@Preview(device = WearDevices.SMALL_ROUND) +@Preview(device = WearDevices.SMALL_ROUND, fontScale = 1.24f) +@Preview(device = WearDevices.LARGE_ROUND) +@Preview(device = WearDevices.LARGE_ROUND, fontScale = 0.94f) +internal fun workoutLargeChipPreview(context: Context) = TilePreviewData { + singleTimelineEntryTileBuilder( + Workout.largeChipLayout( + context, + it.deviceConfiguration, + clickable = emptyClickable, + lastWorkoutSummary = "Last session 45m" + ) + ).build() +} diff --git a/WearTilesKotlin/app/src/main/res/drawable/avatar3.png b/WearTilesKotlin/app/src/main/res/drawable/avatar3.png new file mode 100644 index 000000000..c6f0fbb2a Binary files /dev/null and b/WearTilesKotlin/app/src/main/res/drawable/avatar3.png differ diff --git a/WearTilesKotlin/app/src/main/res/drawable/avatar4.png b/WearTilesKotlin/app/src/main/res/drawable/avatar4.png new file mode 100644 index 000000000..a2ae7d487 Binary files /dev/null and b/WearTilesKotlin/app/src/main/res/drawable/avatar4.png differ diff --git a/WearTilesKotlin/gradle/libs.versions.toml b/WearTilesKotlin/gradle/libs.versions.toml index 42144eab6..46b3b3964 100644 --- a/WearTilesKotlin/gradle/libs.versions.toml +++ b/WearTilesKotlin/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -android-gradle-plugin = "8.5.1" -androidx-wear-tiles = "1.4.0-rc01" +android-gradle-plugin = "8.5.2" +androidx-wear-tiles = "1.4.0" androidx-wear-tooling-preview = "1.0.0" compose = "1.6.8" compose-compiler = "1.5.14" @@ -8,7 +8,7 @@ horologist = "0.6.9" ktlint = "0.50.0" org-jetbrains-kotlin = "1.9.24" org-jetbrains-kotlinx = "1.8.1" -tiles-tooling-preview = "1.3.0" +tiles-tooling-preview = "1.4.0" [libraries] androidx-datastore = "androidx.datastore:datastore-preferences:1.1.1"