Commit graph

519 commits

Author SHA1 Message Date
Joris Pelgröm 62673fc7a3
Quick fix minor warnings from Android Studio (#4406)
- 'getter for isSpeakerphoneOn: Boolean' is deprecated. Deprecated in Java
 - Unnecessary safe call on a non-null receiver of type Intent
 - The corresponding parameter in the supertype 'BaseWidgetConfigureActivity' is named 'savedInstanceState'. This may cause problems when calling this function with named arguments.
2024-05-15 14:30:54 -07:00
Daniel Shokouhi 6e496c9720
Use device class for binary sensor friendly state to match frontend and core (#4395)
* Use device class for binary sensor friendly state to match frontend and core

* Update common/src/main/java/io/homeassistant/companion/android/common/data/integration/Entity.kt

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

---------

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
2024-05-14 06:51:31 +02:00
Daniel Shokouhi d640b9d974
Use device class enum where possible and supply possible states for those sensors (#4394)
* Use device class enum where possible and supply possible states for those sensors

* Add some missing sensors

* Review comments and suppress lint

* Add media session sensor to enum device class
2024-05-13 12:41:18 -07:00
Joris Pelgröm 395b553772
Prevent race creating + clean up sensor entries for old/deleted servers (#4386)
- Prevent a race on logout from the frontend between updating the sensors and deleting the server data, causing stale sensor entries
 - During periodic sensor updates, clean up any orphaned sensor entries there might be (because of this bug or other race conditions we're unaware of)
2024-05-06 08:15:29 -07:00
Daniel Shokouhi 38e5da167e
Add a remaining charge time sensor for supported devices (#4346)
* Add a remaining charge time sensor for supported devices

* Send unavailable and convert to minutes

* Use correct unit of measurement

* Fix ms to min conversion and update title to match other sensor casing

* Round down instead of up
2024-05-03 07:12:17 -07:00
Joris Pelgröm 674f5d4c5f
Add QR code scanner for frontend (#4303)
* Basic barcode scanner functionality

* Add overlay with cutout and toggle flashlight

 - Add a overlay with cutout in the middle / on the side, matching design and Google's barcode scanner
 - Working button for toggling the flashlight on and off

* Fix background camera use, complete more UI

 - Fix camera remaining active when the activity is paused (for example, by going to another app)
 - Set the app's theme
 - Add more UI parts: title, subtitle, optional action button

* Complete scanner UI

 - Request permission when launched, and add snackbar when permission is denied
 - Add flashlight button and position it to line up with the frame
 - Make title/subtitle/action dynamic
 - Fix double scrim for system bars on older API levels

* Add dependency to automotive as we can't exclude features

* More automotive dependencies

* Return information about barcode format

* Implement external bus for scanner

* Fix external bus type

 - The type for external bus messages should be command, with the bar_code/* in the key command
 - Send aborted when closing the scanner using back

* Improve feature availability check

 - Make sure the device actually has a camera and is not automotive
2024-05-02 17:55:22 -07:00
Daniel Shokouhi 4d9498c02b
Add some missing states for audio sensor and correct mic muted intent condition (#4350)
* Add some missing states for audio sensor

* Correct improper SDK check for mic muted intent action

* Update wear intent receivers

* Correct mic muted sensor update type
2024-04-20 15:44:04 +02:00
Joris Pelgröm b0dd673cb9
Request audio focus for Assist voice input + output (#4308)
* Request audio focus for Assist voice input + output

 - Request exclusive focus for Assist voice input (no other applications allowed to playback)
 - Request focus with ducking allowed for Assist voice output

* Remove useless @Inject
2024-04-05 17:57:18 -04:00
Joris Pelgröm 314a60bd2e
Downgrade Retrofit to 2.9.0 (#4325)
- Downgrade as the Retrofit update unintentionally bumps Jackson which in turn results in the minimum SDK level required being 26
2024-04-05 17:55:47 -04:00
dependabot[bot] f016fd57c1
Bump Retrofit from 2.9.0 to 2.10.0 (#4293)
* Bump com.squareup.retrofit2:converter-jackson from 2.9.0 to 2.10.0

Bumps [com.squareup.retrofit2:converter-jackson](https://github.com/square/retrofit) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/square/retrofit/releases)
- [Changelog](https://github.com/square/retrofit/blob/trunk/CHANGELOG.md)
- [Commits](https://github.com/square/retrofit/compare/2.9.0...2.10.0)

---
updated-dependencies:
- dependency-name: com.squareup.retrofit2:converter-jackson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Use Retrofit BOM

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joris Pelgröm <joris.pelgrom@gmail.com>
2024-03-27 06:58:24 -04:00
Joris Pelgröm 7ee922af87
Add battery voltage divisor setting (#4299) 2024-03-26 16:09:35 -07:00
leccelecce b23b1838d0
Add option to transmit BLE on Home SSID only (#4277)
* Add option to transmit BLE on Home SSID only

* Check against all servers, not just the active one

* Fix missing parentheses

* Use single expression function

* Updated sensor description/setting title
2024-03-22 07:37:34 -07:00
Zee Aslam f006127b01
add new sensor for ip6 addresses (#4202)
* add new sensor (draft 1)

* run ktlintcheck

* add docs link and update sensor params

* fix loose ends

* fix toString not nested correctly

* fix unit of measurement

* fix not adding to list

* fix typo that allowed ipv4 addresses to slip in
2024-02-22 17:02:13 -05:00
adam5532 ea79b6ae1f
Fixed spelling of compound verbs "set up", "log in", and "log out". Fixed "comma splice". Fixed double space. (#4196) 2024-02-11 08:28:43 -05:00
dependabot[bot] 15b1518a44
Bump org.jlleitschuh.gradle.ktlint from 11.6.1 to 12.1.0 (#4125)
* Bump org.jlleitschuh.gradle.ktlint from 11.6.1 to 12.1.0

Bumps org.jlleitschuh.gradle.ktlint from 11.6.1 to 12.1.0.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle.ktlint
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add .editorconfig

* ktlintFormat

* Fix comment in a 'value_argument_list' is only allowed when placed on a separate line

* Restore AssistShortcutView

* Fix comment in a 'value_argument_list' is only allowed when placed on a separate line

* Fix no comment expected at this location

* Fix property name should start with a lowercase letter and use camel case

* Fix parameter comments

* Fix comment in a 'value_argument_list' is only allowed when placed on a separate line, again

* Fix property name should use the screaming snake case notation when the value can not be changed

* Fix final comment in argument list

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joris Pelgröm <joris.pelgrom@gmail.com>
2024-02-06 21:02:39 -05:00
Joris Pelgröm 98f3d7abd2
Add option to update camera & template tile when 'in view' (#4185)
* Add option to update camera & template tile 'on view'

 - Use the tile enter callback to request an update to the tile once it enters the view. Considering that this callback exists it's probably safe to assume an update that is requested in this callback won't be throttled (at least it appears to work during testing).
 - Minor edit to the refresh interval picker to ensure strings that are more than one line look a bit nicer.

* on view -> in view
2024-02-02 16:44:22 -05:00
Joris Pelgröm 09ca68e061
Fix lint warning for database/db function parameter name (#4178)
- Fixes the following warning x23: /home-assistant-android/common/src/main/java/io/homeassistant/companion/android/database/AppDatabase.kt:838:34 The corresponding parameter in the supertype 'Migration' is named 'db'. This may cause problems when calling this function with named arguments.
2024-02-02 15:28:12 -05:00
Márton Maráz c185b871fd
Make volume sensors update instantly by subscribing to a broadcast (#4162)
* Make volume sensors update instantly by subscribing to a broadcast

* Change skippableActions to a 1-to-many map and the list of all volume sensors to the corresponding Intent action key
2024-02-02 15:25:55 -05:00
Joris Pelgröm c6ddca8fdc
Support image entity in camera widget (now renamed picture widget) (#4159)
- Allow selecting image entities in the camera widget
 - Rename camera widget to picture widget to better reflect camera + image entity support
2024-01-25 17:02:51 -05:00
Sebastian Lövdahl 5d52735e36
Support multiple Template tiles on Wear OS (#3783)
* Support multiple Template tiles on Wear OS

* Add `TemplateTileConfig` data class

* Fix migration

* `Pair` -> `TemplateTileConfig` fixes

* Fix `getAllTemplateTiles` implementation

* Initial work on companion <-> wearable device communication

* More work on phone <-> wear device communication

* Save updated template in phone app

* Get the template to render using the right method

* Fix CI complaints

* Work on Wear UI for multiple template tiles

* Update wear manifest

* Wear migration and navigation fixes

* Fix Template tile IDs in mobile app

* Make adding a new Template tile on Wear device work

* Small cleanups and TODO fixes

* Try to fix template config refresh in settings

* Fix after rebase

* Adopt blocking approach for reacting to tile events, inspired by #3974

* Use `OpenTileSettingsActivity` for template tile

* Adopt Material 3 and other UI-related changes

* Show help text in phone app if no template tiles have been added yet

* Reference the view model variable inside the function

By having the view model variable outside the block, the updated template tile
might not be propagated to the template settings view.

* Reload template tiles when opening the template tiles from settings

* Replace null key with -1 for old template tile

* Lint complaints fixes

* remove TODO

* Store error

* Scrollable list of template tiles

* Move "Configure template tile" to header

* Replace with methods with copy

* Show template as secondary text

* Fix scrolling

* Update app/src/full/java/io/homeassistant/companion/android/settings/wear/views/SettingsWearTemplateTileList.kt

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

* Remove unused field

* Move padding to "no tiles" text

* Add deep link

---------

Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
2024-01-24 10:56:39 -05:00
Joris Pelgröm a5efe6a9ab
Support for Thread "import credentials" from frontend (#4128)
* Support for Thread "import credentials" frontend action

 - Add support for the frontend action to import Thread credentials, or better said export Thread credentials from the device. This is essentially a very basic sync.

* Rename/reorder reused Matter code

 - Change names and order of reused Matter code for Thread importing to prevent potential confusion

* Update minimal implementation
2024-01-12 09:20:57 -05:00
Joris Pelgröm f1fcabb0c9
Send IP address of Matter device for on network commissioning (#4069)
* [WIP] Send IP of device during commissioning

* Add version check for IP address in commission_on_network

* Update minimal
2024-01-04 14:29:19 -05:00
Joris Pelgröm 62414e4cd5
Migrate BuildConfig to Gradle Build Files (#4049)
- Addresses the following warning: The option setting 'android.defaults.buildfeatures.buildconfig=true' is deprecated. Each module uses the BuildConfig class so it's added everywhere.
2023-12-15 12:46:48 -05:00
Steffen Klee e0731c9c79
Add Wear OS TLS client certificate authentication (TLS CCA) support (#3924)
* Add Wear OS TLS client certificate authentication (TLS CCA) support

Wear OS does not currently allow the user to install certificates to the
system-wide KeyChain for TLS CCA support. This commit adds support for
using certificates from the app-specific Android KeyStore with UI for
setting up a certificate during the Wear OS onboarding process.
The manual step in the onboarding process is required since we cannot
transmit certificates of the Android KeyChain because they are not
extractable.

In particular, this commit adds the following changes:
* KeyStoreImpl as an additional KeyChainRepository interface
  implementation for loading and storing keys to the application's
  KeyStore. TLSHelper uses KeyStoreImpl as a fallback key manager.
* UI for selecting a certificate file with GET_CONTENT intent during
  Wear OS onboarding in OnboardingActivity if it is detected that the
  Home Assistant may require TLS CCA. The UI includes a password check
  for the PKCS12 container.
* During onboarding the app sends the raw PKCS12 data to Wear OS
  together with the container password. The connection is assumed to be
  encrypted and trusted so that no additional encryption is necessary.

* Move PKCS12 password check to lifecycle scope

* Remove redundant try-catch when loading PKCS12

* Simplify MobileAppIntegrationView layout code
2023-12-13 15:19:54 -05:00
Joseph Abbey 6b56bc579a
mobile_app_notification_cleared for wearos (#4035)
* mobile_app_notification_cleared for wearos

* Fix imports

* Remove database id extra

* Fix whitespace

* Reformatted imports and added the receiver to the manifest

* Move `handleDeleteIntent` to common
2023-12-13 14:45:46 -05:00
Kostas Chatzikokolakis 52b0f4a6d7
Set the default BLE transmitter minor value to 40004 (#4027)
This value is whitelisted by the ibeacon integration to ensure the beacon
is processed even without a name.
2023-11-25 12:14:17 -05:00
Yuri Schimke da43981208
Better Wear Check (#4024) 2023-11-25 12:12:21 -05:00
Ruben van Dijk f5886dce1a
Added a sensor to detect if the hotspot is enabled. (#4012)
* Added a sensor to detect if the hotspot is enabled.

* Validate if we aren't running a watch before showing hotspot sensor.

* Fixed code style issues with the linter.

* Fix instant update for hotspot-sensor.

* Update hotspot icon to access-point instead of wifi.
2023-11-22 12:54:06 -05:00
Joris Pelgröm ac7ba33ae7
Show server name in "Unable to connect to Home Assistant" dialog (#3995)
- Shows the server name instead of a generic "Home Assistant" to prevent confusion when the app cannot connect in the WebViewActivity, when using multiserver.
2023-11-04 14:59:15 -04:00
Joris Pelgröm 2da1a36c55
Websocket onMessage: prevent out of order delivery due to launch (#3990)
Websocket onMessage: prevent out of order delivery due to launch
2023-11-01 19:01:20 -04:00
Joris Pelgröm e8815f12e5
Always send sensor registration device class + entity category to prevent errors due to old registration (#3977)
* Always send device class during registration

 - Always send the device class for a sensor during registration to overwrite any existing invalid values

* Only send sensor registrations with null properties to core 2023.2+
2023-10-28 11:18:03 -04:00
Joris Pelgröm 7d76bb4b51
Update tiles logged out state to prevent cut off overflow, shortcuts tile label (#3975)
Update tiles logged out state to prevent cut off overflow

 - Limit length of logged out state string to prevent text cut off and shorten strings to help with translations
 - Fix inconsistent shortcuts tile name
2023-10-28 11:15:22 -04:00
Daniel Shokouhi a596a1183d
Use deprecated wifi method in case WifiInfo is null (#3970)
* Use deprecated wifi method in case WifiInfo is null

* Add comment about why we are reusing the deprecated method
2023-10-25 23:24:27 -04:00
Joris Pelgröm 5314e4b08b
Update Jetpack/Google dependencies (Oct 2023) (#3966) 2023-10-22 12:19:47 -04:00
Joris Pelgröm cda25479d6
Add clear_notification support to Wear OS (#3956)
- Move the clear_notification command to common extensions and add support in the Wear OS app
2023-10-20 17:45:48 -04:00
Daniel Shokouhi 709ca07e8c
Shorten some settings strings (#3921)
* Shorten some settings strings

* Remove unused string
2023-10-06 16:51:32 +00:00
Márton Maráz 2641422e50
Add NFC state sensor (#3905)
* Add first draft for NFC sensor

* Rename NfcSensorManager.nfcSensor to nfcStateSensor

* Move NfcSensorManager to the common module

* Add BroadcastReceiver subscription to NfcAdapter.ACTION_ADAPTER_STATE_CHANGED in both the app and wear modules

* Remove TODO comments

* Change updateType to INTENT

* Convert simple methods to expression body

* Change mdi:nfc to mdi:nfc-variant

* Fix docs URL

* Reword NFC sensor manager according to the PR suggestions
2023-10-05 09:57:33 -04:00
Joris Pelgröm 4a4cc31b97
Update icon (#3888)
* Update icon

 - Replace old icon with the new icon
 - Update app primary color to new blue tint
 - Deduplicate resources

* Update feature graphic

* Decouple app icon color from main color
2023-09-28 17:38:48 -04:00
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
Lev Aronsky a31cd2fdaa
Fix isActive for locks (#3862)
* Fix isActive for locks

Lock entity should be active when locked, inactive otherwise

* Added a comment to explain the change
2023-09-19 15:40:07 -04:00
Joris Pelgröm 3915ec6d8f
Automatically fix broken registrations/webhooks (#3875) 2023-09-19 15:38:50 -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 4163e1465e
Add Android 14 device controls panel (#3855)
* Prepare controls panel activity for Android 14

* Allow controls panel to work while locked

* UI to enable/disable controls panel

 - Disable panel by default
 - Add area to controls settings on Android 14 to enable/disable panel

* Panel server/path settings

 - Add setting to choose which server and path to use for the panel

* Remove transition animation for panel

* experience -> mode
2023-09-12 21:47:57 -04:00
Guillermo Orellana 6c54aa84b7
Fix crash on empty URL strings (#3846)
defensive url parsing
2023-09-06 08:32:45 -04:00
Joris Pelgröm b6687dc762
Shortcut path input improvements (#3831) 2023-08-31 19:53:32 -04:00
Daniel Shokouhi 3cc7bdca08
Fix last update sensor intent not retrieving value (#3825)
* Fix last update sensor intent not retrieving value

* Suppress deprecation

* Move suppression
2023-08-28 17:44:10 -04:00
Daniel Shokouhi bb58a578dd
Use unavailable and unknown states consistently when dealing with sensors and entities (#3821)
* Use unavailable and unknown states consistently when dealing with sensors and entities

* Update more sensors

* Remove unused import
2023-08-28 17:43:25 -04:00
Joris Pelgröm 6d4fa06545
Thread updates: add border agent ID, multiserver improvements (#3820)
* Add/update/delete Thread credentials by border agent ID

* Multiserver: only keep one HA credential, handle credentials for deleted servers

 - Make sure the app only stores one HA credential that matches the preferred credential for the server executing the sync.
 - Create an 'orphaned Thread credentials' system to be able to delete credentials for servers that have been previously deleted.

* Fix minimal
2023-08-26 16:54:40 -04:00
Daniel Shokouhi 6c2e555e57
Various changes to entity usage (#3816)
* Various changes to entity usage

* Remove unneeded code

* String fixes

* Remove redundant string
2023-08-26 16:53:31 -04:00
Joris Pelgröm fb71b9c788
Update to Kotlin 1.9/Compose 1.5/Compose Wear 1.2/AGP 8.1.1 (#3814)
- Update to Kotlin 1.9
 - Update to Compose 1.5 and Compose Wear 1.2, both depend on and are required for Kotlin 1.9. Compose Wear includes lazy classes moving to a different package so updated imports.
 - Update to AGP 8.1.1 to remove compatibility warning
 - Update Navigation Compose to 2.7.1 as it uses Compose 1.5 internally
 - Update Accompanist to 0.32 as it uses Compose 1.5 internally
 - Switch Room to KSP instead of kapt because this (latest stable) release doesn't work with Kotlin 1.9 otherwise. As a result, we no longer need to specifically enable incremental compilation.
2023-08-24 14:51:29 -04:00