Widget: Allow placing the battery widget at 1x1#541
Merged
Conversation
Introduce BatteryLayout enum with size-driven dispatch. Drops minWidth from 80dp to 40dp so the battery widget can be placed at one cell. At 1-cell-wide placements render a compact icon+percent stack; wider sizes keep the current NARROW/WIDE layouts.
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
The battery home-screen widget can now be placed at 1 cell × 1 cell (previously the minimum was 2 cells wide). At that size the widget shows a compact vertical stack of left/right/case icons with their percentages — no labels or charging/in-ear badges. Wider placements render exactly as they did before, so existing widgets are visually unchanged.
Technical Context
BatteryLayoutenum (TINY_COLUMN,NARROW,WIDE) selected from the width-cell count inBatteryGlanceWidget.provideGlance(); the previousisWide: Booleanflag is gone.minWidthfrom 80dp to 40dp inbattery_widget_info.xml.targetCellWidth/Heightstays 2×1 so the default placement is unchanged.TINY_COLUMNrenders three stacked[14dp icon + 12sp percent]rows, vertically centred, with no device label or charging/in-ear badges — there's no room in a 1-cell-wide box.SHORT_ROWvariant for 1-cell-tall placements was tried and removed. On-device testing showed thatNARROW's stacked layout packs more information into a wide-but-short widget than a horizontal compact row, and matches the pre-change behaviour users expect at the default 2×1 size.getCellsForSize()(<→<=) in both the battery and ANC widgets. At the exact 2-cell boundary (110dp) it previously under-counted, which became consequential with the new width-based dispatch.BatteryLayout.forCells(widthCells)companion function with unit tests covering 1/2/3/4/5/8/0 cells.