Update to the 1.4/1.6 releases of android.wear.{protolayout,tiles}#1359
Update to the 1.4/1.6 releases of android.wear.{protolayout,tiles}#1359ithinkihaveacat wants to merge 18 commits intoandroid:mainfrom
Conversation
Also updates: - Compose to 1.10.3 - Android Gradle Plugin to 8.13.2
- Refactor MessagingTileService to inherit from Material3TileService - Move resource loading and tile construction into tileResponse - Refactor tileLayout to be an extension on MaterialScope - Remove dependency on Horologist's SuspendingTileService for this component
- Use MaterialScope.image with ProtoLayoutScope for automatic resource registration - Simplify tileResponse to leverage the new automated system in Material3TileService - Fix Ali's avatar URL extension (.png -> .jpg) to resolve 404 error - Ensure contacts without avatars correctly fallback to themed initials
Summary of ChangesHello @ithinkihaveacat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on upgrading the Android Wear OS Protobuf Layout and Tiles libraries to their latest beta versions (1.4 and 1.6 respectively). This update necessitates significant refactoring across the codebase, particularly in how tile services are implemented and how image resources are managed and provided. The changes aim to align the sample code with the latest best practices and API changes introduced in these new library versions, ensuring compatibility and leveraging new features for more efficient resource handling and simplified tile creation. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the android.wear.protolayout and android.wear.tiles dependencies to new major versions and refactors the codebase to adopt the new APIs. The changes are extensive, moving from manual resource management and BaseTileService to the more integrated TileService and materialScopeWithResources. Overall, the migration is well-executed across most of the tile implementations.
However, I've identified a few critical issues. There's a bug in Calendar.kt where an image resource is hardcoded due to an incomplete migration of its data model. Additionally, messaging/Layout.kt contains a couple of errors: a call to a non-existent method setImageResource and incorrect syntax for Kotlin's associate function, both of which will prevent the code from compiling. Please address these points to ensure the migration is complete and correct.
- Update Gradle to 9.3.1 - Update Android Gradle Plugin to 9.1.0 - Update Kotlin to 2.2.10 - Add recommended build features and compatibility flags to gradle.properties
Update androidx-wear-tiles to 1.6.0 and androidx-wear-protolayout to 1.4.0. These represent the final stable releases for these libraries. The update was verified with a clean build and manual deployment to an API 36 Wear OS emulator. Visual inspection confirmed that the tile correctly adopts Material 3 dynamic colors and displays the required branding header icon.
Resolve merge conflicts with upstream/main in libs.versions.toml, gradle-wrapper.properties, and gradle-daemon-jvm.properties. - Update ktlint to 1.4.0 and Kotlin to 2.3.20 in libs.versions.toml. - Update Gradle wrapper to 9.4.1. - Revert gradle-daemon-jvm.properties to upstream version. - Fix build errors in app/build.gradle.kts by migrating kotlinOptions to compilerOptions DSL.
Remove leftover Horologist dependencies and update the messaging tile screenshots to reflect the recent migration to Material3TileService. - Removed `horologist-tiles` from `WearTilesKotlin/app` dependencies and the associated experimental compiler flag. - Updated `tile_messaging.png` in resources and README screenshots to show the new Material 3 Dynamic Colors and branding header. - Replaced `?attr/colorControlNormal` in vector drawables with white to fix resource linking errors caused by the dependency removal. - Removed Horologist mentions from the README.
- Add ratchetFrom = "origin/main" to spotless configuration. - Increase max line length to 120 in .editorconfig. - Fix build errors in app/build.gradle.kts by adding compose runtime and migrating to compilerOptions DSL. - Fix lint errors (suppressions, imports, file renaming). - Revert Kotlin version to 2.2.10 in libs.versions.toml to fix compose compiler error. - Apply formatting to files modified in this branch.
Remove implementation(libs.horologist.tiles) from app/build.gradle.kts as it was accidentally re-added and the branch has migrated to use Material3TileService directly.
Merge branch 'upstream/main' into tiles-1.6-update. Resolve conflicts in app/build.gradle.kts and libs.versions.toml by: - Removing Horologist dependency as requested. - Keeping max versions or buildable versions.
Remove org.jetbrains.kotlin.plugin.compose and buildFeatures.compose from app/build.gradle.kts as it is not needed for Tile layouts and causes compilation errors in release builds with newer Kotlin versions. Also remove the explicitly added compose runtime dependency.
- Fix non-existent setImageResource call in Layout.kt by using setResourceId. - Remove unnecessary type arguments in associate in Layout.kt. - Fix hardcoded image resource in Calendar.kt by updating Event data class to use @DrawableRes Int and updating call sites. - Add missing DrawableRes import in Calendar.kt.
Replace deprecated setResourceId and custom image builder with protoLayoutScope.basicImage in contactButton in Layout.kt. This uses the modern API introduced in 1.4 and removes the deprecation warning.
Run spotlessApply to fix formatting violations in Calendar.kt and Layout.kt as reported by CI. This includes line wrapping and import sorting.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the Wear Tiles sample to migrate from Horologist to the native Material3TileService and updates dependencies to Wear Tiles 1.6.0 and ProtoLayout 1.4.0. Key changes include transitioning to materialScopeWithResources, updating image handling with androidImageResource, and implementing a coroutine-based MessagingTileService using Coil. Feedback highlights unused variables in News.kt, a redundant build() call in Timer.kt, and a recommendation to use the idiomatic isNotEmpty() extension in Layout.kt.
| val now = LocalDateTime.of(2024, 8, 1, 0, 0).toInstant(ZoneOffset.UTC) | ||
| Clock.fixed(now, Clock.systemUTC().zone) |
| buttonGroupItem { timerButton("25", "Mins") } | ||
| } | ||
| ) | ||
| build() |
| } | ||
| } | ||
| ) | ||
| if (!row2.isEmpty()) { |
|
This PR is too big. Splitting; first part is #1367. |
Summary / Goal
Update Wear OS Jetpack library dependencies to their final stable releases and remove redundant Horologist dependencies from the sample app.
Motivation
The project was previously using beta/RC versions of the
androidx.wear.tilesandandroidx.wear.protolayoutlibraries. With these libraries now stable and the main sample having migrated toMaterial3TileServicenatively, we can finalize the versions, remove the unneeded Horologist abstraction, and ensure our preview assets reflect the modern Material 3 design system.Proposed Changes
androidx-wear-tilesto1.6.0andandroidx-wear-protolayoutto1.4.0in the version catalog.horologist-tilesfrom theWearTilesKotlin/appdependencies and deleted the associated experimental compiler opt-in flag.MessagingTileServicewith fresh captures from an API 36 emulator, reflecting the new Material 3 Dynamic Colors and required header icon.?attr/colorControlNormalreferences in vector drawables with@android:color/whiteto fix resource linking errors caused by the dependency removal.Rationale & Safety
This cleanup aligns the sample with the intended stable usage of the APIs. The removal of Horologist does not impact runtime behavior, as the main tile was already refactored to use
Material3TileService.(Note on Golden Tiles: The reference layouts in
com.example.wear.tiles.goldenhave not been refactored yet. However, they remain functionally sound and self-contained, correctly inheriting dynamic colors viamaterialScopeWithResources. They will be architecturally unified in a follow-up commit.)Verification
./gradlew assembleDebug) successfully.MessagingTileServiceto an API 36 Wear OS emulator and verified dynamic color support and layout integrity.