fix(widget): match Activity view startOfDay and add open-app button - #198
Open
TimeToBuildBob wants to merge 2 commits into
Open
fix(widget): match Activity view startOfDay and add open-app button#198TimeToBuildBob wants to merge 2 commits into
TimeToBuildBob wants to merge 2 commits into
Conversation
Two fixes for ActivityWatch#197: 1. **startOfDay consistency**: Widget now reads `startOfDay` from the embedded AW server settings (GET /api/0/settings/startOfDay) before building the query timeperiod, so it uses the same day boundary as aw-webui's Activity view. Falls back to 4 AM (aw-webui default) if the server is unavailable or the setting is unset. Also applies the same pre-dawn logic as aw-webui: if the current hour is before startOfDay, the widget shows the previous calendar day's period. 2. **Open-app button**: Adds a small "open external" icon (widget_open_button) next to the "Screen time" header. Tapping it launches MainActivity. The main widget body keeps its existing tap-to-refresh behaviour.
Greptile SummaryThe PR aligns widget reporting with the configured start-of-day boundary and adds a dedicated button for opening the app.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains in the fix associated with the previous review thread. Important Files Changed
Reviews (2): Last reviewed commit: "fix(widget): preserve minutes in startOf..." | Re-trigger Greptile |
parseStartOfDayHour() took only split(":").firstOrNull() so "04:30"
became 4h00m, misaligning the widget with the Activity view for users
with a non-whole-hour boundary.
Refactored to parseStartOfDay() returning LocalTime (org.threeten.bp)
so both hour and minute are preserved. Updated fetchStartOfDay(),
getCategoryTimesToday(), and the day-boundary comparison accordingly.
Contributor
Author
|
@greptileai review |
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. |
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.
Fixes #197 (two issues from that report).
1. Widget time matches Activity view
Root cause: The widget queried from midnight (
today.atStartOfDay(zone)) while aw-webui's Activity view usesstartOfDay(default"04:00") as the day boundary.Fix:
getCategoryTimesTodaynow readsstartOfDayfrom the embedded server's settings API (GET /api/0/settings/startOfDay) before building the timeperiod — same source the RustandroidQueryalready uses for category classes. Falls back to4(aw-webui default) if the server is unavailable or the setting is unset. Also mirrors aw-webui's pre-dawn logic: if the current hour is beforestartOfDay, the widget shows the previous calendar day's period (e.g. at 3 AM withstartOfDay=4, "today" is yesterday 04:00–today 04:00).2. Widget tap opens the app
Fix: Adds a small "open external" icon (
widget_open_button) next to the "Screen time" header. Tapping it launchesMainActivity. The main widget body keeps its existing single-tap-to-refresh behaviour.Changes
CategoryTimeWidgetUpdater.kt:fetchStartOfDayHour()+parseStartOfDayHour()helpers; updatedgetCategoryTimesToday; launchPendingIntentwired towidget_open_buttonwidget_category_time.xml: header row wrapped in horizontalLinearLayoutwith newwidget_open_buttonImageViewdrawable/ic_open.xml: Material "open in new" vector icon (new file)