Progress bar customization - #6527
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for Android 16+ “progress-centric” notification customization in the Android Companion App notification pipeline, enabling richer progress rendering (segments/points and custom icons) when notifications are received from Home Assistant.
Changes:
- Added parsing helper (
parseFlattenedList) to interpret flattened list payloads (e.g., from WebSocket-flattened notification data) - Added Android 16+
NotificationCompat.ProgressStylehandling for segments, points, and tracker/start/end icons - Introduced new notification data keys for progress customization (
progress_segments,progress_points,progress_*_icon,progress_*_color)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| common/src/main/kotlin/io/homeassistant/companion/android/common/notifications/NotificationFunctions.kt | Adds helper to parse flattened list strings into structured key/value maps for progress style inputs |
| app/src/main/kotlin/io/homeassistant/companion/android/notifications/MessagingManager.kt | Applies Android 16+ progress-centric ProgressStyle based on new notification payload keys |
You can also share your feedback on Copilot code review. Take the survey.
| sizeDp = 20 | ||
| colorFilter = PorterDuffColorFilter(progressTrackerColor, PorterDuff.Mode.SRC_IN) | ||
| backgroundColorRes = accentColor | ||
| roundedCornersDp = 10 | ||
| paddingDp = 4 | ||
| } |
There was a problem hiding this comment.
I would like some docs about the choice of these magic numbers.
| if (progressStartIcon.startsWith("mdi:") && progressStartIcon.substringAfter("mdi:").isNotBlank()) { | ||
| val iconName = progressStartIcon.split(":")[1] | ||
| val iconDrawable = IconicsDrawable(context, "cmd-$iconName").apply { | ||
| sizeDp = 20 |
| if (progressEndIcon.startsWith("mdi:") && progressEndIcon.substringAfter("mdi:").isNotBlank()) { | ||
| val iconName = progressEndIcon.split(":")[1] | ||
| val iconDrawable = IconicsDrawable(context, "cmd-$iconName").apply { | ||
| sizeDp = 20 |
| if (progressStartIcon.startsWith("mdi:") && progressStartIcon.substringAfter("mdi:").isNotBlank()) { | ||
| val iconName = progressStartIcon.split(":")[1] |
There was a problem hiding this comment.
same and could actually be wrap into a small helper
| if (progressEndIcon.startsWith("mdi:") && progressEndIcon.substringAfter("mdi:").isNotBlank()) { | ||
| val iconName = progressEndIcon.split(":")[1] |
There was a problem hiding this comment.
ktlint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
This also requires PR home-assistant/mobile-apps-fcm-push#317 to support objects in notification data |
| // Values for temporarily added keys | ||
| const val THIS_SERVER_ID = "server_id" | ||
|
|
||
| private val lenientJson = Json { isLenient = true } |
There was a problem hiding this comment.
It's a one time thing, we should not make this available too broadly because whenever we want to parse a JSON we should use our existing instance kotlinJsonMapper
| val segmentsData = data[PROGRESS_SEGMENTS] ?: "" | ||
| if (segmentsData.isNotBlank()) { | ||
| try { | ||
| val segments: List<Map<String, String>> = lenientJson.decodeFromString(segmentsData) |
There was a problem hiding this comment.
Did you try if it works with our current parser? I would really like to use it instead of this one. Where is the quote removed from the key that we have to do that? If it's from our code can we avoid this?
| if (segments.isNotEmpty()) { | ||
| return true | ||
| } | ||
| } catch (e: kotlinx.serialization.SerializationException) { |
There was a problem hiding this comment.
Make an import and update all try/catch in the file
| iconString: String, | ||
| iconColor: Int, | ||
| backgroundColor: Int? = null, | ||
| ): androidx.core.graphics.drawable.IconCompat? { |
Summary
This feature adds support for progress bar customization on Android 16.0+ devices, as shown here.
Checklist
Screenshots
Link to pull request in documentation repositories
User Documentation: home-assistant/companion.home-assistant#1297
Any other notes