-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
fcab330
commit a8a7363
Showing
17 changed files
with
421 additions
and
100 deletions.
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
...src/main/java/io/homeassistant/companion/android/common/data/prefs/WearPrefsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
common/src/main/java/io/homeassistant/companion/android/common/util/JsonUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.homeassistant.companion.android.common.util | ||
|
||
import org.json.JSONArray | ||
|
||
fun JSONArray.toStringList(): List<String> = | ||
List(length()) { i -> | ||
getString(i) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.