-
Notifications
You must be signed in to change notification settings - Fork 627
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
Add caching of favorites in Wear OS, resulting in prettier loading #2982
Conversation
Hi mads03dk It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
Hi 👋 This is a really nice idea For database changes please increase the version as you're changing something for it. Right now, upgrades of existing installs won't work. When increasing the version this also means that the existing JSON files that describe the database don't change, and you can probably use an |
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.
In addition to the more general comment about database changes above, a few more specific notes. If anything is unclear feel free to add a comment :)
common/src/main/java/io/homeassistant/companion/android/database/wear/Caches.kt
Outdated
Show resolved
Hide resolved
common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.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/MainViewModel.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/home/views/HomeView.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/MainView.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt
Outdated
Show resolved
Hide resolved
common/src/main/java/io/homeassistant/companion/android/database/wear/Caches.kt
Outdated
Show resolved
Hide resolved
…nViewModel.kt Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
Revert previous changes to database and implement properly
wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt
Outdated
Show resolved
Hide resolved
common/src/main/java/io/homeassistant/companion/android/database/wear/FavoriteCachesDao.kt
Outdated
Show resolved
Hide resolved
common/src/main/java/io/homeassistant/companion/android/database/wear/FavoriteCachesDao.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/MainViewModel.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
wear/src/main/java/io/homeassistant/companion/android/util/CommonFunctions.kt
Outdated
Show resolved
Hide resolved
I've been thinking, do we need a clear cache button in the settings? The app handles adding/updating/deleting on load, when the favorites are edited and on logout. |
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/MainViewModel.kt
Outdated
Show resolved
Hide resolved
wear/src/main/java/io/homeassistant/companion/android/home/views/MainView.kt
Outdated
Show resolved
Hide resolved
…ws/MainView.kt Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
Remove wrapper function to delete cached items
@mads03dk What is your opinion on this ^ ? |
Hmm. Since the cache is updated every time data is received, I also deem it unnecessary. If you feel the same way, let me know, and I will remove it :) |
Yes it also seems unnecessary to me, so feel free to remove it :) |
wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt
Outdated
Show resolved
Hide resolved
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.
Thanks, nice first contribution!
Summary
Added local caching of the
friendly_name
andicon
properties in the WearOS app, thus avoiding using the entity ID and a bookmark icon whilst waiting for the server to send the current states. Aimed to achieve a prettier visual while waiting for the connection to be establishedScreenshots
Before, whilst waiting for a connection:
Now, whilst waiting for a connection:
Settings:
Any other notes
Only favorites are cached, since they're the first entities to be shown. Cached is updated every time the entity is received from the server or added/removed from the list of favorites. Some internals of the
getIcon
function has also been updated to allow direct usage of icon-stringsPlease note;
This is my very first go at native app development (hereby Kotlin), so I expect some - if not all - of my changes to be suboptimal. I'm really open to suggestions and would love to get some constructive feedback, but don't go too harsh, haha!