Skip to content

Widget: Add ANC control widget#528

Merged
d4rken merged 1 commit into
mainfrom
feat/anc-widget
Apr 17, 2026
Merged

Widget: Add ANC control widget#528
d4rken merged 1 commit into
mainfrom
feat/anc-widget

Conversation

@d4rken

@d4rken d4rken commented Apr 17, 2026

Copy link
Copy Markdown
Member

What changed

Added a new home-screen widget that lets you switch your AirPods' listening mode — Off, ANC, Transparency, or Adaptive — directly from the home screen without opening the app. The widget adapts its layout to the size you pick:

  • 1×1: four icons in the corners with a + divider
  • 2×1 / 1×2: compact icon strip or column with per-cell dividers
  • 2×2: grid with icon-only buttons
  • wide / tall with labels: labeled pills that share space evenly

The configuration screen now previews the actual widget layout you'll see (ANC or battery), shows a hint that the widget can be resized, and guards against confirming with a profile that no longer exists or no longer supports ANC.

Closes #518

Technical Context

  • The ANC widget ViewModel was consolidated into the existing WidgetConfigurationViewModel — widget type is detected at runtime via AppWidgetManager.getAppWidgetInfo(...) and exposed on the state so the single activity can drive both widgets. Profile list is filtered to ANC-capable devices when the widget type is ANC.
  • Active-button styling uses Material3 colorSecondaryContainer / colorOnSecondaryContainer resolved from the app's Material3 DynamicColors theme. This gives guaranteed contrast regardless of the user's chosen widget background, after earlier attempts with tertiary / primary tints were not visible enough against custom themes.
  • Icon drawables were aligned with the in-app AncModeSelector (DoNotDisturbOn, Headphones, Hearing, AutoAwesome) so the widget and the app show the same glyph for each mode.
  • The AapCommand.SetAncMode path is the same one the in-app UI already uses — the widget goes through AapConnectionManager.sendCommand(...), which is already debounced and queued by the session engine, so no additional rate-limiting is needed in the widget callback.
  • Widget picker has both a Glance providePreview() (for launchers that honor it, with localized mode labels) and a static anc_widget_preview_layout.xml fallback (for launchers that don't).
  • minWidth / minHeight are 40dp so the widget can be resized to single-cell dimensions; the layout picker uses getCellsForSize to switch between the six variants.

New home-screen widget that toggles AirPods ANC modes (Off / ANC / Transparency / Adaptive) directly, with six adaptive layouts that pick based on widget size (QUAD_CORNERS, ROW_ICONS, COLUMN_ICONS, GRID_2X2, ROW, COLUMN). Consolidated battery+ANC configuration into a single ViewModel that detects widget type from AppWidgetManager. ACTIVE state uses Material3 secondaryContainer/onSecondaryContainer for guaranteed contrast. Includes live config preview, preview subtitle, stale-selection guard, device-label toggle, and aligned icons with the app's AncModeSelector.
@d4rken d4rken added the enhancement Add a new feature of improve an existing feature label Apr 17, 2026
@d4rken d4rken merged commit 86b685f into main Apr 17, 2026
6 of 10 checks passed
@d4rken d4rken deleted the feat/anc-widget branch April 17, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Add a new feature of improve an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Widget support for ANC/Transparency

1 participant