* Add 'Sign in on phone' button to Wear OS login
- Detects a compatible app and shows a button to sign in on your phone instead, which is a lot easier than typing everything on the watch
* Include exception for phone sign in in log
* Initial Wear MFA support
- Added support for authentication with MFA to the Wear OS login flow
- Renamed the existing Authentication* stuff to PasswordAuthentication*
- For the authentication flow, specify a base class used for responses and depending on the response return the appropriate data class that extends the base class
* Add MFA screens
- Adjusting the existing view to add a new title and input and showing/hiding based on state created a buggy experience on the emulator where the keyboard confirm/next buttons didn't work properly any more, so the MFA input is a full new activity. Copied from the existing activity for username/password.
* Fix MFA activity tools:context
* Move MFA in to the existing AuthenticationActivity
- Actually it is possible to get the MFA input in the same activity with a little effort, but the end result works great and doesn't use as much duplicate code
* Remove MFA activity, rename PasswordAuthentication* back
- Remove the MFA activity now that MFA is integrated into the other activity for authentication
- Rename back PasswordAuthentication* to Authentication* (end result compared to existing app: no change)
* Remove unnecessary JsonIgnoreProperties annotation
* Initial implementation of template tile
Includes settings on phone and watch. Watch settings will be removed in next commit
* Add refresh interval setting to wear app
* Update wear settings layout
* Add interval setting to phone app
* ktlint
* Add example image to the manifest
* Add preview of rendered template in phone settings
* Process review comments
* Use resources for interval strings
- Add support for entities in the new button domain (2021.12) and input_button domain (2022.2) to device controls
- Rename the existing SceneControl as that already acted as a button
* First area implementation for Wear
* Fix import / ktlint
* Area IDs are only nullable in core, not for clients
* A new approach to managing the entity lists
- Change the approach to getting state lists to support any number of lists per type. By nesting a state list inside the list Compose should still be able to update on any changes. To display, loop through the items.
- The main view model now filters the main/source entity list that is used everywhere by supported entities to prevent unusable domains from showing up.
- Fix padding above all entities/settings to make sure that there is still padding even if there are no entities.
- Temporary fix for favorites/tiles: hardcode the lists used. Should be updated to read items dynamically but I couldn't get the rememberSaveable to work in time.
* Filter entities in EntityListView to keep live updates
- Keep the updates in the EntityListView always live by allowing filtering the list in the view itself. Without these changes, selecting any domain from the main screen would give a static list because filtering creates a copy of the original.
- Fix ktlint import ordering
* Listen for registry updates in the main list
- Subscribe to events for registry updates and update any lists. Compose will take care of updating views if necessary, which basically makes this plug and play.
* Load entities for favorites+tiles dynamically
- Load all the entities by domain when setting favorites or tiles, instead of using hardcoded references to specific domains. This is a proper fix for the updated list structure introduced in a previous commit.
- Reuse saving the expanded states of lists from EntityListView because favorites and tiles can now also be any number of headers
* Fix 'All entities' icon filter
* Move names for supported domains
- For determining which tiles are toggleable we already access the implementation directly so remove todos and move names for those domains over to the implementation to keep everything in one place. The main view model will include a simple function to convert the string ID to an actual string.
* Order area/domain lists alphabetically
- Create a new observable list that can be used to determine the order in which to display the list or areas/entities. A mutableMapOf in Kotlin by default respects the insert order but it looks like the mutableStateMapOf doesn't follow that as the items are already inserted alphabetically.
- Allow passing in a list order for the EntityListView to prevent entities from suddenly ending up in a different place on a different screen
* Order entities in area, util object for area
- Order the list of entities displayed in one area alphabetically by their friendly name instead of domain, as it would otherwise still use domains internally to sort but not show them which is not a good experience.
- Create an util object in the common package for getting the area of an entity, as the same code was used both in the device controls and Wear main list.
* Restore domain descriptions to original (plural)
* Update manifest per Quest specifications, hide fmore features that are no longer usable due to changes
* Remove unused imports
* Hide more location based features
- Refactor HaControl to include a default implementation of the createControl function, add functions to provide class-specific information and features
* Add a work profile sensor
The information on whether the work profile is available only seems to
be given by tracking the state of the last received broadcast intent
indication - MANAGED_PROFILE_[UN]AVAILABLE
Thus add a receiver for these intents, and slightly change the architecture
so that the intent can be passed down when the sensor needs to be updated.
I think there's a ineffciency in the architecture - currently all
sensors are asked to update whenever any broadcast the app tracks is
received, regardless of whether than broadcast is relevant to the the
sensor or now - for example all sensors update when battery state changes.
* Revert typo fix to keep this PR focused.
* Pass lint checks
- Set the device's zone to the area if present, else set to domain.
- Android groups device controls by the zone that is set, in order of the first encountered zones. So make sure that we first emit devices by area a-z, and then in the list order (domain a-z).
* Add entity state changed function to widgets
- Add a function to widgets implementing the BaseWidgetProvider that is called whenever a new state change for an entity is received. Implemented it by refreshing all widgets (match existing behaviour).
* Use state update in widget if there's a widget for the entity
- Only refresh the entity and media widget if the state of the entity they're displaying is changed. For the template widget we don't know since it is rendered on the server so just keep refreshing on any state change (no change).
- Allow passing in a suggested entity for updating the view to allow the widgets to re-use the received state update object, removing the need to make another API call if the view is requested as a result from a state update.
* Add last used app sensor
* Use app label for state if possible
* Update string for new state logic
* Review comments
* Review comment
* Update app/src/main/java/io/homeassistant/companion/android/sensors/LastAppSensorManager.kt
Co-authored-by: Justin Bassett <bassett.justint@gmail.com>
* Lint
* Lint again
Co-authored-by: Justin Bassett <bassett.justint@gmail.com>
* Read registries using websocket, show in Controls
- Quick first implementation of reading area/device/entity registries via websocket
- Use these registries when loading Android's device controls to display the area in the subtitle on load
* Move data classes to websocket package
- Merge the general and response data classes into one and move them to the websocket.impl.entities package
- Rename classes from RegistryX to XRegistry to match websocket API
* Single line Control subtitles
* Directly call WebSocketRepository to get registries
* Add fields to registry response
- Add fields that will be included in the registry response to the XRegistryResponse data class and change order, based on the HA core code
- Fix nullability on AreaRegistryResponse.kt: area id could be null?
* Generalize websocket event subscriptions, fix cancelling Controls
- Generalized the implementation for 'get updates' subscriptions on the websockets, to allow for many similar calls without repeating the same lines of codes over and over.
- Fix cancelling websocket connections from HaControlsProviderService: takeWhile is only evaluated when there is a new message, so when there are no new messages (as expected for the registries) the subscription to the flow would remain active and the websocket connection open for longer than necessary.
* Fix websocket event to class handling
* Refresh controls when registry is updated
- If the area or device registry is updated, reload the registry and refresh all controls to show changes.
- If the entity registry is updated and at least one of the entities is provided, reload the registry and refresh all controls to show changes. (If not related to one of the entities provided, this could never result in a visible change.)
* Fix getting area if set in entity registry
* Replace entity updates on registry update with function
- To limit duplicate code replace the code to update all entities when a registry is updated with a function, and also use it for the initial state
- Fixes potential crash if entity registry state update had an old value of null
* Use constants for websocket event types
* Update device registry functions to use return try/catch pattern
* Use one Mutex for all subscribe_events messages