Skip to content

Widget: Allow placing the battery widget at 1x1#541

Merged
d4rken merged 1 commit into
mainfrom
feat/widget-1x1-support
Apr 23, 2026
Merged

Widget: Allow placing the battery widget at 1x1#541
d4rken merged 1 commit into
mainfrom
feat/widget-1x1-support

Conversation

@d4rken

@d4rken d4rken commented Apr 23, 2026

Copy link
Copy Markdown
Member

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

  • Introduces a BatteryLayout enum (TINY_COLUMN, NARROW, WIDE) selected from the width-cell count in BatteryGlanceWidget.provideGlance(); the previous isWide: Boolean flag is gone.
  • Drops minWidth from 80dp to 40dp in battery_widget_info.xml. targetCellWidth/Height stays 2×1 so the default placement is unchanged.
  • TINY_COLUMN renders 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.
  • An intermediate SHORT_ROW variant for 1-cell-tall placements was tried and removed. On-device testing showed that NARROW'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.
  • Also fixes a pre-existing off-by-one in 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.
  • Selector is extracted to a pure BatteryLayout.forCells(widthCells) companion function with unit tests covering 1/2/3/4/5/8/0 cells.

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.
@d4rken d4rken added the enhancement Add a new feature of improve an existing feature label Apr 23, 2026
@d4rken d4rken merged commit 118eaa8 into main Apr 23, 2026
10 checks passed
@d4rken d4rken deleted the feat/widget-1x1-support branch April 23, 2026 14:11
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.

1 participant