Widget: Add ANC control widget#528
Merged
Merged
Conversation
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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
+dividerThe 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
WidgetConfigurationViewModel— widget type is detected at runtime viaAppWidgetManager.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.colorSecondaryContainer/colorOnSecondaryContainerresolved 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.AncModeSelector(DoNotDisturbOn,Headphones,Hearing,AutoAwesome) so the widget and the app show the same glyph for each mode.AapCommand.SetAncModepath is the same one the in-app UI already uses — the widget goes throughAapConnectionManager.sendCommand(...), which is already debounced and queued by the session engine, so no additional rate-limiting is needed in the widget callback.providePreview()(for launchers that honor it, with localized mode labels) and a staticanc_widget_preview_layout.xmlfallback (for launchers that don't).minWidth/minHeightare 40dp so the widget can be resized to single-cell dimensions; the layout picker usesgetCellsForSizeto switch between the six variants.