Skip to content

feat(widget): add picker preview and document NotifyWorker rollup - #234

Open
TimeToBuildBob wants to merge 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/widget-preview-and-notify-rollup
Open

feat(widget): add picker preview and document NotifyWorker rollup#234
TimeToBuildBob wants to merge 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/widget-preview-and-notify-rollup

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Two items scoped out of #231 / requested on #142.

1. Widget picker preview

The widget picker currently shows no preview. minSdk is 26, so previewLayout (API 31+) is not enough on its own.

  • android:previewLayout@layout/widget_category_time_preview (sample data: 4h 23m / Work / Media / Uncategorized)
  • android:previewImage → static PNG fallback for Android 8–11

previewLayout takes precedence on API 31+; previewImage is the documented fallback.

Picker preview (static image, used below API 31):

widget picker preview

Device/emulator picker verification is not in this PR — no attached device in this environment. The preview layout is the live widget layout with realistic placeholders, which is what the system picker inflates.

2. NotifyWorker top-level rollup is intentional

parseCategorySeconds() still groups by $category[0]. That is not a leftover of the widget grouping that #231 briefly changed to full-path.

Alert keys (CategoryAlert.category) are top-level names like "Work" / "YouTube" — the same shape as DEFAULT_ALERTS and as desktop aw-notify's AllLevels parent key. A "Work" alert means "notify me after 2h of Work", which must include Work > Coding, Work > Planning, etc.

Nested-path alerts ("Work > Programming") are not supported on Android; desktop AllLevels aggregation would be needed for that. Don't "fix" this to match #231.

Extracted as an internal function; four unit tests pin the rollup.

Tests

./gradlew :mobile:testDebugUnitTest --tests 'net.activitywatch.android.workers.NotifyWorkerTest' — 11/11 pass.

Related

The widget picker currently shows no preview. minSdk 26 cannot rely on
previewLayout (API 31+), so set both: a sample layout for modern pickers
and a static PNG fallback for Android 8–11.

See ActivityWatch#142.
parseCategorySeconds groups by $category[0] so a "Work" alert includes
every Work subcategory. That matches DEFAULT_ALERTS and desktop
aw-notify's AllLevels parent key; do not "fix" it to full-path like ActivityWatch#231.

Extracted as an internal function with tests covering the rollup.
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds launcher-picker previews for the category-time widget and documents the notification worker’s intentional top-level category rollup.

  • Adds an API 31+ preview layout and a static image fallback for Android 8–11.
  • Extracts the existing category-duration parser for direct unit testing without changing its production call path.
  • Adds tests confirming that nested categories roll up into their top-level alert category.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or non-blocking defects identified in the changed paths.

The widget metadata references valid preview resources supported by the configured SDK, the preview layout uses compatible standard views, and the parser extraction preserves the production call path and intended aggregation behavior.

Important Files Changed

Filename Overview
mobile/src/main/java/net/activitywatch/android/workers/NotifyWorker.kt Extracts the existing top-level category aggregation into an internal function while preserving the production caller and alert behavior.
mobile/src/test/java/net/activitywatch/android/workers/NotifyWorkerTest.kt Adds focused unit coverage for top-level category rollup, default alert keys, uncategorized entries, and empty results.
mobile/src/main/res/layout/widget_category_time_preview.xml Adds a RemoteViews-compatible static preview that closely mirrors the visible structure of the live widget.
mobile/src/main/res/xml/category_time_widget_info.xml Registers the API 31+ preview layout and the image fallback used by older supported Android versions.
mobile/src/main/res/drawable-nodpi/widget_category_time_preview.png Adds the density-independent static widget-picker preview used on Android 8–11.
mobile/src/main/res/drawable/widget_preview_bar.png Adds the static stacked-bar artwork used within the API 31+ preview layout.

Reviews (1): Last reviewed commit: "docs(notify): document intentional top-l..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

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