-
-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple Template tiles on Wear OS #3783
Support multiple Template tiles on Wear OS #3783
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very very early draft, the code is not even compiling right now. But happy to get any kind of feedback anyway 🙂
...rc/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepositoryImpl.kt
Outdated
Show resolved
Hide resolved
...src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt
Outdated
Show resolved
Hide resolved
app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt
Outdated
Show resolved
Hide resolved
...on/src/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepository.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepositoryImpl.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/phone/PhoneSettingsListener.kt
Outdated
Show resolved
Hide resolved
While testing this locally, I somehow ended up with stale data in the HA app 🤔 I removed some Template tiles from the Wear OS tile carousel, but some of them remained in the Home Assistant app data, and hence are visible in the list of Template tiles in the settings. @marazmarci did you see anything like this when implementing support for multiple shortcuts tiles? |
Yes, I encountered this when I was in the middle of development, and the app was crashing when Other than this, I didn't encounter such issues. However, I can imagine that Wear OS may give up calling |
To make users able to fix a potential issue like this themselves, maybe we could provide an option to force remove a Template/Shortcut Tile 🤔 |
I still don't understand how it happened for me. It worked for one of the tiles I removed but the other one was left in place 🤷 AFAICT the
Yeah, that could be an option 👍 I suppose there is no way to query the currently active tiles? Or could we through some other side-channel keep track of whether a tile is in use or not? 🤔 For Template tiles with a refresh interval set, we could actually keep track of it. But maybe it's overkill, and an option to manually force remove a tile would be better. But still not easy and obvious, how would a user know from the HA Template tile config whether a tile is in use or not? It would be quite easy to remove a tile config for an active tile, and that means that tile is in some kind of limbo state. |
wear/src/main/java/io/homeassistant/companion/android/home/views/SelectTemplateTileView.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/home/views/HomeView.kt
Outdated
Show resolved
Hide resolved
03fe581
to
80754d8
Compare
Good to know: a new camera tile with support for multiple instances has been merged into the app. As a result there is a merge conflict, but also things like a single launcher activity for the tile settings that would be good to adopt. |
Another good to know: the Wear app switched to Material 3 components. While your current build won't fail, please update UI composables to M3 components when updating 🙏 |
Thanks for the heads up 👍 I haven't given up on this, I've just been very short on time and energy lately. If someone else feels like picking this up while I'm dragging my feet, I won't mind. Otherwise I'll try to get it forward in the coming weeks. |
Regarding the stale tile discussion: I recently was debugging for issues with the camera tile and found that the current setup with |
Wow, nice, thank you for that! 👍 This was the thing that made getting this PR over the goal line feel hard or impossible. I'll pick it up again now 🙂 |
80754d8
to
c5a4001
Compare
Fixed in bee0a79 ✔️
Fixed in f39f1b4 ✔️
Fixed in 7ef7a61 ✔️ |
...src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearHomeView.kt
Outdated
Show resolved
Hide resolved
Had a chance to run a test on the debug APK and the feature is working as expected. Adding tiles updates the phone and watch and templates and options are reflected in teh appropriate location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just make sure to clean up the TODO comment and also let us know if you had checked the one existing data case mentioned.
Thanks 👍
While testing this I think I found another problem. After upgrading both apps, if the phone settings are opened before an existing template tile on the watch has been refreshed at least once the phone settings will hang because of a crash on the wear side:
I guess it fails because we have not yet been able to persist the tile ID for the existing template tile, and we cannot serialize a map with a I managed to work around the initial problem by using
I guess we can handle that too by changing the argument type for
But this does not feel like a sustainable path forward overall 🤔 Any ideas? Could we somehow trigger a refresh of the tiles after updating the app so we minimize the window for this to happen? |
IIRC I think the OS handles this outside the freshness interval. Maybe its best not to send any data when the tile hasn't been refreshed yet and just provide a friendly message to the user? Either way though we shouldn't crash in any of these cases so would be good to add some try/catch blocks so we don't have a crash unexpectedly. |
Using That also nicely solved the problem I had with serializing a AFAIK, everything should finally work now and the PR is ready for (final) review. |
By having the view model variable outside the block, the updated template tile might not be propagated to the template settings view.
70e612c
to
8fc2726
Compare
@slovdahl I don't mind reviewing but you literally pushed a |
efde4e4
to
5c9e7a6
Compare
@jpelgrom I'm sorry for the confusion, it was not intentional. I didn't notice that there was a rebase conflict before I requested the review, so I rebased it and fixed the trivial import-related conflict locally, and tried to push all the commits except the last It should all be fixed now, and the PR is ready for review whenever you have time. 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in getting back to the review. As a result I've noticed some new things to address... Thanks for the efforts so far, almost there 🙏
app/src/full/java/io/homeassistant/companion/android/settings/wear/SettingsWearViewModel.kt
Outdated
Show resolved
Hide resolved
.../java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt
Show resolved
Hide resolved
.../java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt
Outdated
Show resolved
Hide resolved
...ava/io/homeassistant/companion/android/common/data/prefs/impl/entities/TemplateTileConfig.kt
Outdated
Show resolved
Hide resolved
.../java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt
Outdated
Show resolved
Hide resolved
.../java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/home/views/HomeView.kt
Show resolved
Hide resolved
…wear/views/SettingsWearTemplateTileList.kt Co-authored-by: Joris Pelgröm <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Summary
Support any number of Template tiles in the Wear OS app. Fixes #3291.
Screenshots
Template tiles settings view with 2 tiles:
Companion app:
Wear app:
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes