Commit graph

21 commits

Author SHA1 Message Date
Joris Pelgröm b0ad11d04f
Add troubleshooting tool: location history (#3886)
* Add location history (location, trigger, result)

 - Initial setup saving data, no UI, cleanup or preferences yet

* On/off setting, limit history size and basic UI

 - Add a on/off setting for location history (default on)
 - Limit the history size to 48 hours, any older entries will be deleted during regular sensor updates
 - Add a basic UI for location history based on paging considering the possible data size with multiserver/high accuracy. The list looks good and shows status at a glance, detail view still needs work.

* Finish expanded UI

 - Make the expanded UI nicer and show relevant data, buttons for opening the location in a maps app and sharing log data
 - Add empty states for location history

* Filter by state, improve list speed

 - Add option to filter by state
 - Simplify Room configuration and sort by indexed ID to improve list loading speed

* Remove duplicate source

* Fix minimal

* Split sent into sent and failed to send
2023-09-28 17:37:37 -04:00
Joris Pelgröm 2c20baf0f5
Add camera tile to Wear OS (#3870)
* [WIP] Prepare camera snapshot tile

* Deduplicate refresh views

* Get/save tile config in the database

* Deduplicate haptic click, add to camera refresh

* [WIP] Camera tile settings UI

 - Create UI to set camera tile settings
 - Reuse shortcut tile settings activity as a general tile settings activity

* Rename camera snapshot tile to camera tile

* Cleanup: camera entities selection, empty state, preview image

 - On initial load also create a list of camera entities to make it possible to select them without showing up elsewhere in the app
 - Add text to empty state instructing the user to set a camera
 - Update tile preview images

* Fix logged out state on missing tile config

* Force tile update on login

* Scale bitmap to fit inside screen size

 - Scale the received image to a bitmap that does not exceed the screen size to ensure timely refreshes and prevent parcels that are too big
2023-09-17 16:57:33 -04:00
Joris Pelgröm 7f14582909
Add 'toggle' tap action to entity state widget (#3798)
* [WIP] Widget tap action: toggle entity

* Add feedback on press and failure

* Share code for pressing on entities

* Align cover press action

 - Toggle will stop if possible when opening/closing if supported so prefer toggle instead of open/close

* Toggle by default if supported

 - Set the default tap action for supported entities to toggle instead of refresh

* Update widget description
2023-08-19 19:24:44 +00:00
Sebastian Lövdahl 3db34ec408
Show measurement unit in Wear OS complication (#3703)
* Show measurement unit in Wear OS complication

* Extend existing `friendlyState` method

* Make showing unit configurable (defaulting to false)

* Feedback fixes
2023-07-25 14:37:31 -04:00
Joris Pelgröm d1b17aa606
Jetpack Compose icon dialog (#3631)
* Add icon dialog based on Jetpack Compose

TODO

* Migrate to new icon dialog

* Migrate old database

* Don't wrap with drawablecompat

* Rebase fixes and updates

 - Fix and update database migration
 - Fix dependencies
 - Fix shortcut icons
 - Fix ComposeView in AlertDialog not working by switching implementation to DialogFragment
 - Fix icons that no longer exist
 - ktlint

* Visual compatibility

 - Automotive asset
 - Handle icon ids in shortcuts to prevent users losing icons when updating shortcuts
 - Add padding, color filter to shortcut icons to keep icons consistent with older icons
 - Increase button widget icon padding to keep sizing consistent
 - Add tip to dialog about searching in non-English languages

* Fix line endings

---------

Co-authored-by: Tiger Oakes <contact@tigeroakes.com>
2023-07-04 13:25:32 -04:00
Joris Pelgröm 64ee62b8fa
Entity state complication improvements (more flexibility) (#3465)
* Add ComplicationType.LONG_TEXT support, friendly state

 - Makes it possible for watch faces to request a long text complication
 - Use the friendly state to support translated states and dates

* Add show title option

 - Allows hiding the title of a complication in case it doesn't look right

* Implement/fix reading state from database

 - When a entity ID is provided in the configuration request, load data for that complication from the database to allow easy reconfiguration
 - Provide more appropriate error messages when complication isn't configured / the entity doesn't exist

* ktlint
2023-04-08 16:33:16 -04:00
Joris Pelgröm 8d2c9f1cb4
Get user information and prevent using admin-only calls (#3417)
* Get and cache user information

 - Add function to get information about the current user
 - Cache user information alongside server in database

* Replace/prevent admin only calls
2023-03-16 07:10:27 +00:00
Joris Pelgröm f7cec0e5a2
Multiserver (#3332)
* Multiserver foundation

 - A foundation to build multiserver support on. Not ready for general use.

* Update new vehicle support

* Rebase fixes

* Multiserver settings

 - Show settings for the correct server when editing server settings from the settings

* Bind session to device/install

 - Save an install id with the app install to make sure that it isn't re-used on another device causing issues

* Add migration

 - Migrate server info from shared preferences to the database after database migration and clean up
 - Remove unused url shared preferences
 - Read/save server version from/to database

* Fix auth error when session is refreshed

* Show server name instead of URL

 - Read the server name when getting the config, and save it to the database
 - Allow the user to override the server name in the app's settings

* Multiserver notifications

 - Make notifications aware of which server sent the notification
 - Show server name in notification if more than 1 server is added to the app
 - Use the server-specific repositories when calling webhooks/authenticating/etc

* Handle multiserver in websocket worker

 - Copy the settings database row to the new server ID to allow for server-level settings (websocket) while keeping the original for app-level settings (sensor update frequency), and handle this in onboarding
 - Make the websocket worker check in on all servers and open/close connections where required
 - Add the webhook_id to websocket notifications to link them to servers
 - Update ServerManager servers to defaultServers because I'm using the same filter everywhere

* Migrate shared preferences

 - Move server-specific device name to Server and secret key to ServerConnectionInfo
 - Add a server ID key to the remaining shared preferences and migrate existing values

* Add option to delete server from settings

 - Allow deleting servers directly from the app's settings, because you might not be able to do so from the frontend.

* WebView switching and active server management

 - Allow switching which server is considered 'active' and used for the webview when loading
 - On auth errors remove the server instead of removing the URLs (?)
 - When getting external auth consider that the server might just have been removed (possible race condition from frontend which frequently causes 1 unauthorized connection when logging out)
 - Fetch config after adding a new server to fill in name and version before first use

* Sync registrations and blocking load

 - When starting the app, sync all registrations
 - Remove Wear state with server but new registration required
 - When receiving a new push token, update all registrations
 - Do a blocking load for getting the servers because otherwise the app might think it's not registered when running in the background

* Use StateFlow for the server list

 - Don't manually refresh but use a StateFlow to get updates pushed when the list of servers changes
 - Make settings use unique server keys to prevent constant remove/re-add

* Sensor updates and sync with multiple servers

 - Send sensor updates to all servers and sync changes to the app. Sensors are shared across all servers the app is connected to so changing enabled state on one server will update it for all servers.
 - Don't update sensor enabled state for location tracking directly from onboarding, this should be done in the result.
 - Remove unused SensorWithSettings class

* Send NFC tag scans to all servers

* QS tiles server selection

 - Listen to updates for a specific server
 - Allow selecting server if there is more than one

* Shortcuts server selection

 - Allow selecting server if there is more than one
 - Extract OutlinedButton with DropdownMenu for server selection to a standalone Composable
 - Update QS tiles to not automatically reset server ID when server no longer exists, align with shortcuts

* Fix revoked sessions + crashing app

 - When a session is revoked update the session object to reflect it
 - Fix app crashes on revoked sessions because of race conditions with the AlertDialog causing window active/inactive at the same time as finishing it

* Extra server onboarding tweaks

 - Skip welcome and location
 - Save/fix notification preference for minimal version

* Fix sensor state type conversion errors for new servers

 - If the state is removed but the type isn't, this can result in unwanted conversions throwing errors so remove the state type as well when copying a sensor

* Matter multiserver

 - Request specific server ID in Matter functions
 - Add server selection to shared Matter device flow

* Android Auto multiserver

 - Allow switching server in Android Auto. Defaults to active server, note that it doesn't change the default but only changes it in AA.

* Widgets server selection

 - Add server selection to all widgets and update handling to use the selected server

* Clean up TODOs out of scope

* Device controls multiserver

 - Subscribe to updates for each server that controls are added for
 - Allow managing lock screen enabled controls for each server

* Don't try to register sensors when finishing

 - Don't try to do a sensor update when finishing, as this may cause unintended use of resources we're trying to clean up (when deleting a server)

* Server-level zones and location tracking

 - Keep track of which server a zone belongs to for location tracking, and send updates only to that server
 - Add server name to zone selection setting

* Merge fix

* Show 'Activate Server' any time there are multiple servers

 - If the user is looking for the option to go to their server why hide it if it is already used, making them go back twice?

* More consistent strings

* Improve add server feedback in settings

 - Preserve the activate server before adding a new one to prevent unexpected active server changes
 - Show a Snackbar when another server is added indicating success with a button to activate it, or failure

* Remove unused ServerManager

* Fix tag import
2023-02-14 20:30:06 -05:00
Joost Lekkerkerker 59fa25ece0
Migrated all table and column names to lower snake case (#3195)
* Migrated all table names to lower snake case

* Migrated all table names to lower snake case

* Migrated all table names to lower snake case

* Migrated all column names to lower snake case

* Migrated all column names to lower snake case

* Merged the migrations to 1 migration

* Fixed feedback

* Update migration script
2023-01-24 22:30:36 -05:00
Joris Pelgröm efb2390597
Add option for unlocked only quick settings tiles (#3189)
- Add option to quick settings tile to only allow interacting with it when the device is unlocked, similar to device controls on Android 13 (but phrased differently to match the system default behavior)
2022-12-30 20:34:31 -05:00
Daniel Shokouhi e7c18b870c
Add new option to vibrate when quick settings tile is clicked (#3123)
* Add new option to vibrate when quick settings tile is clicked

* Use vibration effects if the device supports it

* Review comments

* Remove question mark

* Set switch color when unchecked
2022-12-16 09:55:59 -05:00
Mads Sørensen e01246ae28
Add caching of favorites in Wear OS, resulting in prettier loading (#2982)
* Add caching of favorites, results in prettier loading

* Update wear/src/main/java/io/homeassistant/companion/android/home/MainViewModel.kt

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>

* Implement a lot suggestions from @jpelgrom
Revert previous changes to database and implement properly

* Apply suggestions from code review

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>

* Implement suggestions from @jpelgrom

* Remove null assertions from icon function

* Update wear/src/main/java/io/homeassistant/companion/android/home/views/MainView.kt

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>

* Fallback to entity ID if friendly_name is missing when creating cache,
Remove wrapper function to delete cached items

* Remove "clear cache" button

* Implement changes by @jpelgrom

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
2022-11-09 16:06:38 -05:00
Joris Pelgröm bdc9094845
Improve adding quick settings tile (#2860)
* Improve adding quick settings tiles

 - Use the new option available on Android 13 to prompt the user to add a tile to the quick settings panel, if a tile wasn't already added
 - Switch Toast to Snackbar
 - Move some logic from the manage tiles view to viewmodel

* Only show subtitle field when supported

 - Setting a tile subtitle is only supported on Android Q+, so don't show the field on versions before that!

* Deeplink into app for tiles that aren't setup

 - Instead of disabling a tile if it isn't setup, if the user is logged in set it up as inactive with the default icon/label and deeplink into the app settings with a notice that it needs to be setup first. This provides a better first use experience, as the user can simply tap it to setup instead of requiring them to manually go to the settings.
2022-09-10 15:16:36 -04:00
andyboeh 6b06e0d8a8
Add authentication to widget buttons (#2798) 2022-09-05 09:50:53 -04:00
Márton Maráz 7f1677a2dd
Fix Last Notification sensor not updating when notification is repeated with the same content (#2734)
Make Sensor::lastSentState and lastSentIcon nullable, set them to null when forceUpdate = true, and make null their default value everywhere.
2022-08-03 17:58:23 -04:00
Márton Maráz 4bf88ac907
Show the charging state on the Battery Level sensor's icon (#2661)
* Show the charging state on the Battery Level sensor's icon.
A different icon will be shown for wired and wireless charging.
From now on, changing only the icon (but not the state) of a sensor will trigger sending an update to the server.
A new DB property called last_sent_icon is added, thus a DB migration is needed.

* Merge SensorDao.updateLastSendState(…) and updateLastSentIcon(…) methods to updateLastSentStateAndIcon(…)
2022-07-09 14:19:23 -04:00
leroyboerefijn 50d387a726
Entity state complication (#2574)
* Add entity state complication with hardcoded entity id

* Add config activity and save entity id in DB

* Update complications when entity state changes

* Allow all entity types for complication

* Update config layout

* remove unused file

* Upload database json

* Process review comments!

* Fix little bug

* Icon background and error catching

* Add automatic refresh and fix missed Dao inject

* Add icons for standard domains

91cd584b4b/src/common/const.ts (L66)

* Cleanup and further icon updates
2022-06-20 20:24:37 -04:00
Joris Pelgröm c98b291d30
Sync sensor enabled state with core 2022.6+ (#2547)
* Sync sensor enabled state from app to core

 - Change sensor 'registered' to indicate not registered, registered as disabled or registered as enabled
 - When a sensor is disabled, set it's status as such on core 2022.6 servers
 - In the sensor registration, use the basic sensor details in case there is no info in the database that can be used

* Clean up version check

 - Now that there is a standard function to get the version, re-use it

* Improve which sensors are synced to core

 - Update database migration to reset registration state on db upgrade to make sure the information is correct for all sensors
 - Only sync sensors that are actually available on the device
 - Fix registering all sensors on core <2022.6 on app/core version change
 - Fix unnecessary sensor updates due to location sensors which are never registered always triggering update on core >=2022.6

* Sync sensor enabled state from core to app

  - After pushing app enabled changes to core, if on core 2022.6 check if the enabled state for any of the sensors is different from what is registered in the app and try to update the sensors. This is done by reading the entire config, because otherwise we wouldn't know about sensors that have been enabled and the app already updates all sensors at the same time so no need for tracking individual updates in the sensor update response.
  - Restore getting config using webhooks, because only the webhook config contains information about entity enabled state
  - Add support for opening a specific sensor's settings page, used for the notification when trying to enable a sensor that requires granting (additional) permissions
2022-05-29 11:22:52 -04:00
Jannis Göing b9c1092302
Multiple media players per widget (#2534)
* Update Media Player Widget Preview

* Add support for multiple media players. optionally show media source label

* fix crop of media player widget preview image. avoid unnecessary api call's when finding active media player. add db migrations. add text color to media source label. set default value of showsource to false.

* remove placeholder source for source icon to fix widget preview
2022-05-29 08:57:52 -04:00
Joris Pelgröm 66c57d5768
Add theming to widgets: Dynamic color (Material You) and Transparent (#2496)
* Add transparent widgets

 - Add options to the service, entity and template widgets to have a transparent background
 - Register configuration change intent filter for widgets in order to be able to respond to day/night changes (no longer fully automatic due to setting color with int)

* Support Material You dynamic color in widgets

 - In widgets that support theming (day/night or transparent), add an option to use Material You dynamic colors
 - Dynamic colors is now the default widget style for new widgets on devices that support them

* Tweak dynamic color theming

 - Update dynamic color values to better match other themed widgets such as those from Google
 - Remove configuration changed intent receiver for widgets because it is no longer required to get colors

* Add dynamic color theming to media player widget

 - Make the media player widget themeable and add an option to use dynamic colors (transparent doesn't make sense for this layout)

* Fix camera widget background if data cannot be loaded

* Add text size option to template widgets

 - Added an option to set the text size to template widgets to better align with other widget options

* Additional Android 12 widget updates

 - When using the dynamic color theme, also use the new Android 12 widget corner radius
 - Update placeholder values in widgets to match images, and refer to dynamic color XML to provide a better preview on Android 12. Reset values when providing template to match existing behaviour when no widget is found in the database.
 - Update entity state and template widget target size to 2x1 to match preview image
 - Make sure media player album art doesn't extend past corner radius if possible

* Change theme selection to dropdown, text color alignment

 - Change theme selection to use a dropdown menu (Spinner) instead of right-aligned radio buttons on multiple lines
 - Change text color selection to left-align radio buttons
2022-05-08 13:10:58 -04:00
Joris Pelgröm ac83869cfa
Add AppDatabase v24 -> v25 auto migration (#2407)
* Add AppDatabase v24 -> v25 migration

* Export Room schema to use AutoMigration instead
2022-03-25 20:02:44 -04:00