Skip to content

Add battery indicator to widget - #1

Merged
shining-cat merged 17 commits into
mainfrom
feature/battery-indicator
Aug 1, 2026
Merged

Add battery indicator to widget#1
shining-cat merged 17 commits into
mainfrom
feature/battery-indicator

Conversation

@shining-cat

Copy link
Copy Markdown
Owner

Summary

Replaces the optional hairline separator between the minutes and day rows with an always-on battery indicator: a proportional level gauge (columns 1–5) plus a mutually-exclusive state glyph (column 6).

  • Gauge — solid fill grows left→right by battery fraction; the empty track is a fill-based capsule annulus (ic_gauge_track) with a genuinely transparent centre, so it shows the wallpaper through on translucent-background widgets. Tinted in the icon tone, sized to the visible dot (dot/2) with the rim matched to the off-dot ring weight (dot/16). Battery band is one full cell, so the grid reads as five even rows.
  • Glyph — mutually exclusive warning semantics: charging bolt (wins over all), filled triangle (≤10%), outline triangle (≤20%), empty otherwise.
  • Battery read on the existing widget tick from the sticky ACTION_BATTERY_CHANGED broadcast — no new scheduling.
  • Removes the now-unused hairline separator setting.

Test Plan

  • ./gradlew testDebugUnitTest — green (mapper boundary tests, resolver battery mapping, charging-glyph, over-100% clamp)
  • Manual on-device, Material You + static colours: partial fill, transparent hollow over wallpaper, rim matches off-dots, glyph balance
  • CI passes → merge

shining-cat and others added 17 commits July 31, 2026 18:53
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The hairline separator slot is now the always-on battery indicator,
rendered unconditionally in DotGrid. Removes the dead hairline field,
its DataStore key, view-model handler, settings-screen toggle, and the
tests that covered them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The gauge filled its row from the edge, so its left side jutted out past
the leftmost dot toward the widget border. Inset it by (cell-dot)/2 so the
left edge lines up with the dots. Height now scales with the icon (0.6*dot)
and the track+fill are pill-rounded (cornerRadius = height/2) instead of a
thin square bar.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Gauge height 0.6->0.4*dot (the 0.6 read as too heavy); battery-section
icon 0.8*dot, smaller than the grid icons since it's secondary info.
Rounded corners kept (API 31+; square fallback below is accepted).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Battery row height was dictated by the glyph slot (height=dot), letting the
thin gauge float in a band wider than the dot-row gaps. Pin it to
gaugeHeight + (cell - dot) so its content carries the same (cell-dot)/2 of
air as the dots, making all inter-component gaps equal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…being squeezed

cell = minOf(w/6, h/4) budgeted height for four rows, but the face now
renders five components (four dot rows + the battery band). The band
overflowed the widget height and the launcher squeezed the bottom date
rows, making day-month tighter than hours-minutes. Reserve the band's
fraction in the divisor and name the layout fractions so the budget and
BatteryIndicatorRow stay in sync.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The solid gauge bar drew too much attention for secondary info. Spacing
stays uniform automatically — GAUGE_DOT_FRACTION feeds both the band
height and the height budget.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The gauge is secondary info that groups with the battery glyph, so it now
shares the icon tone rather than the dot tone. The empty track is rendered
as an outline (nested background-tone pill inside a gauge-tone pill, since
Glance has no border modifier) instead of a low-alpha fill, echoing the
grid's ring-vs-filled-dot language for a two-region partial-charge look.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rebuild the empty-track outline as a fill-based capsule annulus
(ic_gauge_track) tinted like the dots, replacing the nested-opaque-box
hole which could not render a truly transparent centre. The hollow now
shows the wallpaper through on translucent-background widgets.

Size to the visible dot: gaugeHeight = dot/2 (the dot circle is radius 6
of a 24 viewport, filling half its box), with the outline rim baked at
1/8 of the vector height so it lands the off-dot ring's dot/16 weight.
Band is one full cell, so the grid reads as five even rows.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shining-cat
shining-cat merged commit dd9bd7e into main Aug 1, 2026
4 checks passed
@shining-cat
shining-cat deleted the feature/battery-indicator branch August 1, 2026 10:25
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.

1 participant