Go to file
Márton Maráz a8a7363317
Implement support for multiple Shortcut Tiles on Wear OS (#3697)
* Extract JSONArray -> List<String> conversion to extension fun

* Refactor navigation around Shortcuts Tile settings

* Add ShortcutsTileId enum class

* Introduce multiple ShortcutTile subclasses and modify settings UI and storage to support multiple Tiles

* Check if correct ShortcutsTileId is passed as parameter to BaseShortcutTile

* Update TileUpdateRequester usages to account for multiple Tiles

* Add entity count to Shortcut Tile list in Settings

* Fix ktlint errors

* Fix more ktlint errors

* Extract string resource

* Add MULTI_INSTANCES_SUPPORTED to ShortcutsTile to be able to use any number of Tiles

* Refresh the list of Shortcut Tiles in the Settings without needing to restart the app

* Remove test logs

* Update androidx.wear.tiles:tiles to the latest version which doesn't yet require API 34 compileSdk version

* Fix crash when the preference's value is "{}"

* Fix crash when key String is "null" and converting to Int

* Rename placeholder variable name

* Add a comment explaining why to save the tiles in a getter

* Return emptyList() directly for clarity

* Remove icons from "Shortcut tile #n" entries in Settings

* Pass emptyList instead of using the non-null assertion operator to prevent NPEs in edge cases

* Refactor getTileShortcuts and getAllTileShortcuts in WearPrefsRepositoryImpl.
Make the code more readable and understandable, and reduce code duplication.

* Make it explicit that intKey is only intended to be null if stringKey == "null"

* Rename getTileShortcuts to getTileShortcutsAndSaveTileId and make it save the tileId not only when there's a null key in the map, but also when the tileId is not yet in the map. This way, actual Tiles and the tileId keys will be more in sync.

* Handle adding Shortcuts Tile immediately after updating the app to a new version which introduces support for multiple Shortcuts Tiles.

* Show message in the Settings when there are no Shortcuts tiles added yet.

* Refine message in the Settings when there are no Shortcuts tiles added yet

* WIP: ConfigShortcutsTile action

* Update comments about Wear OS versions

* Finalize ConfigShortcutsTile feature by applying @jpelgrom's suggestion to OpenShortcutTileSettingsActivity

* Only wrap the code in runCatching which is expected to throw an Exception under normal circumstances, when the pref value needs to be migrated from the old format.

* Call getTileShortcutsAndSaveTileId in OpenShortcutTileSettingsActivity

* Remove unnecessary stuff
2023-07-31 15:14:01 -04:00
.github Fix version code for F-Droid builds (#3717) 2023-07-27 15:42:28 -04:00
app First Steps into making Gradle Catalogs (#3724) 2023-07-29 11:11:08 -04:00
automotive First Steps into making Gradle Catalogs (#3724) 2023-07-29 11:11:08 -04:00
common Implement support for multiple Shortcut Tiles on Wear OS (#3697) 2023-07-31 15:14:01 -04:00
gradle Implement support for multiple Shortcut Tiles on Wear OS (#3697) 2023-07-31 15:14:01 -04:00
wear Implement support for multiple Shortcut Tiles on Wear OS (#3697) 2023-07-31 15:14:01 -04:00
.gitignore Fix dirty SCM (#3624) 2023-06-30 21:09:13 +00:00
build.gradle.kts First Steps into making Gradle Catalogs (#3724) 2023-07-29 11:11:08 -04:00
CLA.md Add required documents 2019-04-01 22:52:24 -07:00
CODE_OF_CONDUCT.md Update Code of Conduct to 2.0 (#603) 2020-05-26 09:10:31 +02:00
gradle.properties Bump com.android.tools.build:gradle from 7.4.2 to 8.0.0 (#3474) 2023-04-24 21:05:20 -04:00
gradlew Update to Gradle 7.2 (#1726) 2021-09-30 20:37:51 -04:00
gradlew.bat Remove redundant buildscript declaration (#1029) 2020-10-11 13:38:46 -04:00
LICENSE.md Add required documents 2019-04-01 22:52:24 -07:00
README.md First attempt at a new release model. (#3597) 2023-06-26 09:05:17 -04:00
settings.gradle.kts First attempt at a new release model. (#3597) 2023-06-26 09:05:17 -04:00

📱 Home Assistant Companion for Android Beta Deploy

Documentation

If you are looking for documentation around the companion applications check out the Home Assistant Companion Documentation. This will provide you instructions on using the applications.

Setup App Development Environment

  1. Download and install Android Studio

  2. Download / clone this repository to a folder on your computer

  3. Create a Firebase project at Firebase Console

  4. Create four Android apps, with following package names

  • io.homeassistant.companion.android
  • io.homeassistant.companion.android.debug
  • io.homeassistant.companion.android.minimal
  • io.homeassistant.companion.android.minimal.debug
  1. Now download the google-services.json file and put it in the project's /app, /automotive and /wear folders. This file contains the configuration of the whole project (all four applications). (You can also use the mock services file instead of generating your own. The file should contain client IDs for all packages listed above for debugging to work properly. If you do not generate your own file FCM push notification will never work, only websocket notifications will)
  2. Start Android Studio, open your source code folder and check if the Gradle build will be successful using Build/Make Module "App". You might have to install the right Android SDK via Tools/SDK Manager first.
  3. Run gradlew assembleDebug to build all debug versions, this might take a while.
  4. If the build is successful, you can run the app by doing the following: click Run -> Run 'app'.
  5. Connect your phone or create a new virtual device following on screen instruction
  6. 🎉

If you get stuck while setting up your own environment, you can ask questions in the #devs_mobile_apps channel on Discord.

Push Notifications

If you want to work on push notifications or use a development build with push notifications, please go the server side code HERE and deploy it to your firebase project. Once you have your androidV1 URL to the deployed service, set it in to your ${GRADLE_USER_HOME}/gradle.properties file, e.g.:

homeAssistantAndroidPushUrl=https://mydomain.cloudfunctions.net/androidV1

You can also define the rate limit function URL, e.g.:

homeAssistantAndroidRateLimitUrl=https://mydomain.cloudfunctions.net/checkRateLimits

App Flavors

The Android app has both a full flavor that uses Google Play Services to offer features like location tracking and notifications. There is also a minimal flavor that does not require Google Play Services and can be found in the releases section. The minimal flavor does not have location tracking or notifications.

Building for publishing

To build the app for publishing, you will need to sign the app. To do this, do the following:

  1. Create keystore containing keypair for debug application signing. In Android Studio: Menu/Build/Generate signed APK, then use a button to create new keystore. Remember the passwords and key alias. Default, the keystore must be named release_keystore.keystore and should be placed in the home-assistant-Android/app and home-assistant-Android/wear folder.
  2. Set environmental variables used in app/build.gradle.kts:
  • KEYSTORE_PASSWORD
  • KEYSTORE_ALIAS
  • KEYSTORE_ALIAS_PASSWORD
  • KEYSTORE_PATH (if your keystore is located differently than stated above)
  1. Run gradlew build
  2. The signed APK is located in your build folder

Testing Dev Releases

We are using Github Actions to perform continuous integration both by unit testing, deploying dev releases to Play Store Beta and final releases to the Play Store when we release. To help test out a specific feature/fixes users can find the APK on the Actions page for each pull request, this debug APK can be installed side-by-side the production or beta builds.

Quality

We are using ktlint as our linter. You can run a check locally on your machine with:

./gradlew ktlintCheck

This commands runs on our CI to check if your PR passes all tests. So we strongly recommend running it before committing.

To run a check with an auto-format:

./gradlew ktlintFormat

Translating

The project currently uses lokalise to translate the application. If you are interested in helping translate go to the link and click start translating!

Generating a release to production

  • Go to the latest Pre-Release and edit it
  • Delete the body of the release, select the last full release tag and auto generate the release notes
  • Uncheck the Pre-Release box and click update release
  • This should cause the Play Publish Production Workflow to execute and should handle the rest