Skip to content

Allow choosing Live Activity progress bar fill direction - #5180

Merged
bgoncal merged 2 commits into
mainfrom
feature/live-activity-progress-bar-direction
Jul 20, 2026
Merged

Allow choosing Live Activity progress bar fill direction#5180
bgoncal merged 2 commits into
mainfrom
feature/live-activity-progress-bar-direction

Conversation

@bgoncal

@bgoncal bgoncal commented Jul 19, 2026

Copy link
Copy Markdown
Member

Summary

Adds an optional progress_bar_direction field (increasing / decreasing) to Live Activity notifications, alongside the existing progress_bar_color.

  • Static progress bars: decreasing renders the remaining portion (progress_max − progress), so the bar drains as progress advances. Percent labels keep showing the raw progress value.
  • Timer progress bars: the field overrides the built-in default (countdown drains, bounded count-up fills).
  • Unrecognised values decode leniently and fall back to the default direction, so a bad value never drops an update.
  • The field is carried on both delivery paths (APNs content state and the local-push parser promotion) and covered by contract, handler, and local-push tests.
  • Adds a "Battery · Decreasing Bar" sample with matching YAML output.

Screenshots

Not available.

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Omitting the field keeps existing behavior unchanged.

Adds an optional progress_bar_direction field (increasing / decreasing)
alongside progress_bar_color:

- Static progress bars: decreasing renders the remaining portion
  (progress_max - progress) so the bar drains as progress advances;
  percent labels keep showing the raw progress value.
- Timer progress bars: the field overrides the built-in default
  (countdown drains, bounded count-up fills).
- Unrecognised values decode leniently and fall back to the default
  direction instead of failing the strict OS-side content-state decode.
- Promoted through the local-push parser so both delivery flows carry it,
  and covered by contract, handler, and local-push promotion tests.
- New "Battery - Decreasing Bar" sample with matching YAML output.
Copilot AI review requested due to automatic review settings July 19, 2026 22:48
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

⚠️ Unused L10n strings detected

Found 6 unused localization strings in the codebase.

Click to see details
Parsing Strings.swift...
Found 2168 L10n strings

Reading all Swift source code...
Read 7452353 characters of Swift code

Checking for unused strings...
Checked 100/2168 strings...
Checked 200/2168 strings...
Checked 300/2168 strings...
Checked 400/2168 strings...
Checked 500/2168 strings...
Checked 600/2168 strings...
Checked 700/2168 strings...
Checked 800/2168 strings...
Checked 900/2168 strings...
Checked 1000/2168 strings...
Checked 1100/2168 strings...
Checked 1200/2168 strings...
Checked 1300/2168 strings...
Checked 1400/2168 strings...
Checked 1500/2168 strings...
Checked 1600/2168 strings...
Checked 1700/2168 strings...
Checked 1800/2168 strings...
Checked 1900/2168 strings...
Checked 2000/2168 strings...
Checked 2100/2168 strings...

================================================================================
UNUSED STRINGS REPORT
================================================================================

Found 6 unused strings:


ONBOARDING:
  - L10n.Onboarding.ServerImport.Reauthenticate.errorsMissingPresenter
    Key: onboarding.server_import.reauthenticate.errors_missing_presenter
    Line: 3506

WATCH:
  - L10n.Watch.Complications.Builder.previewFooter
    Key: watch.complications.builder.preview_footer
    Line: 5865
  - L10n.Watch.Complications.Builder.sourceCustom
    Key: watch.complications.builder.source_custom
    Line: 5895
  - L10n.Watch.Complications.Builder.templateColor
    Key: watch.complications.builder.template_color
    Line: 5907
  - L10n.Watch.Complications.Builder.textTemplate
    Key: watch.complications.builder.text_template
    Line: 5925

ROOT:
  - L10n.debugSectionLabel
    Key: debug_section_label
    Line: 26

================================================================================
Total unused: 6
================================================================================

================================================================================
Copy-paste these keys into the "Lokalise: Delete Keys" workflow (keys input):
================================================================================
debug_section_label,onboarding.server_import.reauthenticate.errors_missing_presenter,watch.complications.builder.preview_footer,watch.complications.builder.source_custom,watch.complications.builder.template_color,watch.complications.builder.text_template

To remove them, run the
Lokalise: Delete Keys
workflow — it deletes the keys from Lokalise and opens a PR removing them from
Localizable.strings and regenerating Strings.swift. Copy-paste these keys into the keys input:

debug_section_label,onboarding.server_import.reauthenticate.errors_missing_presenter,watch.complications.builder.preview_footer,watch.complications.builder.source_custom,watch.complications.builder.template_color,watch.complications.builder.text_template

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Live Activity notification payloads to support an optional progress_bar_direction field (increasing / decreasing), enabling progress bars to visually fill or drain while keeping existing behavior unchanged when the field is omitted. It carries the field through both APNs content-state and the local-push promotion path, updates widget rendering to honor the direction, and adds test coverage plus a new in-app sample.

Changes:

  • Add progress_bar_direction to HALiveActivityAttributes.ContentState with a case-insensitive resolver and a static-bar fill helper.
  • Update Live Activity UI (Lock Screen + Dynamic Island) to use direction-aware fill for static bars and to optionally override timer bar direction.
  • Propagate and validate the new field across handler/parsers and add contract/handler/local-push tests + a settings sample and localization.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/Shared/LocalPushManager.test.swift Extends local-push promotion expectation to include progress_bar_direction.
Tests/Shared/LiveActivity/LiveActivityContractTests.swift Adds contract coverage for encoding keys and lenient direction decoding + fill behavior.
Tests/Shared/LiveActivity/HandlerLiveActivityTests.swift Ensures handler parsing includes progress_bar_direction and remains nil when absent.
Sources/SharedPush/Sources/NotificationParserLegacy.swift Promotes progress_bar_direction from local-push data into homeassistant.
Sources/Shared/Resources/Swiftgen/Strings.swift Adds SwiftGen accessors for the new settings sample strings.
Sources/Shared/Notifications/NotificationCommands/HandlerLiveActivity.swift Parses and forwards progress_bar_direction into the Live Activity content state.
Sources/Shared/LiveActivity/HALiveActivityAttributes.swift Introduces progressBarDirection, resolver enum, and progressBarFillFraction; wires Codable keys.
Sources/Extensions/Widgets/LiveActivity/HALockScreenView.swift Uses direction-aware progressBarFillFraction and passes direction override to timer bar.
Sources/Extensions/Widgets/LiveActivity/HADynamicIslandView.swift Same as lock screen: direction-aware static bar and timer override.
Sources/Extensions/Widgets/LiveActivity/HAActivityTimerProgressBar.swift Adds optional direction override affecting ProgressView(timerInterval:) count direction.
Sources/App/Settings/LiveActivity/LiveActivitySettingsView.swift Adds a “Battery · Decreasing Bar” sample and emits progress_bar_direction in YAML output.
Sources/App/Resources/en.lproj/Localizable.strings Adds English strings for the new sample (title/summary/note).

Comment thread Sources/Extensions/Widgets/LiveActivity/HAActivityTimerProgressBar.swift Outdated
Comment thread Sources/App/Settings/LiveActivity/LiveActivitySettingsView.swift
jpelgrom pushed a commit to home-assistant/mobile-apps-fcm-push that referenced this pull request Jul 20, 2026
The iOS app (home-assistant/iOS#5180) adds an optional
progress_bar_direction field ("increasing"/"decreasing") to the Live
Activity content state. This server only forwards recognized
content-state keys, so pass the new field through from both the flat
data fields and the explicit content_state object.

Co-authored-by: Claude <noreply@anthropic.com>
@bgoncal
bgoncal merged commit 7f32c18 into main Jul 20, 2026
11 checks passed
@bgoncal
bgoncal deleted the feature/live-activity-progress-bar-direction branch July 20, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants