fix(widget): scale the agenda widget with its size (#51) #88
Reference in New Issue
Block a user
Delete Branch "fix/agenda-widget-size-scaling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes Codeberg #51.
What
#51 asked for a widget font-size setting. It's a bug, not a missing
preference:
AgendaWidgetdeclared nosizeMode, so Glance usedSizeMode.Single— the widget was composed once at the provider minimum and thelauncher simply stretched the result. Type stayed small-widget-sized no matter
how large you made it. The reporter confirmed the default size looks fine and
it's only wrong when enlarged.
So there is no new setting. The widget follows the size you already chose.
How
AgendaWidgetdeclaresSizeMode.Exact(asMonthWidgetalready does), sothe composition sees the live size via
LocalSize.current.widget/WidgetScale.ktbuckets aDpSizeintoCOMPACT / REGULAR / LARGE / XLARGE. Width picks the tier — it governs howmuch of a title fits per row — and height only ever caps it, so a tall,
narrow widget shows more events rather than bigger text.
widget/agenda/AgendaScale.ktmaps each tier to anAgendaMetricstable(type sizes, stripe, icons, row padding). Both files are Glance-free, so the
bucketing and the metrics are covered by plain JVM tests.
COMPACTreproduces the widget's original constants verbatim, and a testpins that — a default-sized widget looks exactly as it did.
Type sizes are anchored to Material 3 type-scale roles; the two off-scale values
are marked and justified inline (notably COMPACT's 13sp day header, held off the
scale on purpose so the default stays unchanged).
Notes for review
Second commit is a review pass over the first. Two of its fixes are
load-bearing and worth a look:
before
LARGE, so widening a widget without also making it unusually tall —the exact resize #51 reports — stayed at
REGULAR. Caps now work on usableheight (gross minus header chrome), and a 378x270 widget reaches
LARGE.SizeMode.Exactstill emits one RemoteViews per host size (usuallyportrait + landscape) where
Singleemitted one, so the payload roughlydoubles. With the range reaching
AgendaRange.MAX_CUSTOM_DAYS(365) anuncapped list could pass the binder transaction limit and the host would show
"Problem loading widget". Rows are capped at 100, dropping a day header the
cut leaves stranded.
MonthWidgetkeeps its own type sizes for now — it can adoptWidgetScalelater; its type couples to the grid's lane height, which is a separate rework.
Testing
testDebugUnitTestandlintDebuggreen.AgendaScaleTest/WidgetScaleTestcover the tier bucketing (including monotonicity across both axes), the
"default unchanged" baseline, the derived text indent, and font-scale handling.
Installed on device; on-device review of the tiers is not yet signed off —
please don't merge to release before that.