Skip to content

Fix widget auto-update and boot receiver reliability#296

Merged
EmmaTellblom merged 2 commits into
EmmaTellblom:widget_fixesfrom
mtellblom:widget_fixes
May 17, 2026
Merged

Fix widget auto-update and boot receiver reliability#296
EmmaTellblom merged 2 commits into
EmmaTellblom:widget_fixesfrom
mtellblom:widget_fixes

Conversation

@mtellblom

Copy link
Copy Markdown
Contributor

Summary

  • Implement widget auto-update functionality with proper coroutine scope lifecycle in BootReceiver
  • Add MidnightWorker and PeriodCalculationWidgetUpdater for scheduled widget refresh
  • Fix threading and update reliability in BaseWidget and WidgetInstances
  • Fix deprecated usage in ExportImportDialog
  • Remove obsolete HTC-specific boot broadcast action from AndroidManifest.xml
  • Bump version to 2.1

Test plan

  • Install on a fresh device, reboot, and verify widgets update correctly after boot
  • Add a widget and confirm it refreshes at midnight without manual interaction
  • Verify period day calculations display correctly in all four widget variants
  • Confirm no regressions in the main calendar and symptom screens

🤖 Generated with Claude Code

- Add QUICKBOOT_POWERON to manifest so widgets refresh on quick reboot
- Update BootReceiver to trigger widget refresh and midnight scheduler on boot
- Wrap MidnightWorker work in try/finally so midnight is always rescheduled even on failure
- Remove HTC-specific boot broadcast action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mtellblom mtellblom changed the base branch from main to widget_fixes May 16, 2026 08:03
The default locale renamed these keys to add _with_bg/_no_bg suffixes,
leaving the old keys as ExtraTranslation lint errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EmmaTellblom EmmaTellblom merged commit 88c20ef into EmmaTellblom:widget_fixes May 17, 2026
EmmaTellblom added a commit that referenced this pull request Jun 14, 2026
* Initial plan

* Implement widget auto-update functionality

- Add onUpdate() override in all widget receivers to schedule MidnightWorker
- Create BootReceiver to reschedule MidnightWorker after device reboot
- Add RECEIVE_BOOT_COMPLETED permission to AndroidManifest
- Add widget update trigger in MainActivity.onCreate() to refresh on app start
- Emit to MidnightTrigger and call updateAll() on app start

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>

* Address code review feedback

- Use lifecycleScope instead of custom activityScope for better lifecycle management
- Create BaseWidgetReceiver to eliminate code duplication across widget receivers
- Set BootReceiver as exported=true to receive system broadcasts
- Remove unnecessary onDestroy() override

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>

* Add error handling and improve BroadcastReceiver reliability

- Add try-catch block in updateWidgetsOnAppStart() to handle potential exceptions
- Use goAsync() in BootReceiver to ensure work completes before receiver is killed
- Add error logging for widget update failures

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>

* Improve code organization and widget update performance

- Organize imports in conventional order
- Update widgets concurrently using async/await for better startup performance
- Reduce widget update time on app start by parallelizing operations

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>

* Optimize threading for widget updates and boot receiver

- Use Dispatchers.IO in MainActivity for widget updates to avoid blocking UI thread
- Use coroutine scope with Dispatchers.IO in BootReceiver to prevent ANR
- Add comment explaining WorkManager's REPLACE policy prevents duplicate scheduling
- Improve app startup performance by offloading widget updates to IO dispatcher

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>

* Fix BootReceiver coroutine scope lifecycle

- Use standalone coroutine scope for one-time operation instead of instance variable
- Prevent resource leak by not storing coroutine scope in short-lived BroadcastReceiver
- Ensure proper cleanup after boot completion handler finishes

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>

* fixed widget update issue

* added dbversion 11, missing...

* Increased versionnumber and version name

* Fixed version name, should still be 2.1

* Fixes for midnightworker

* Fixed importExport dialog deprecated stuff

* More changes for fixing widget

* delay for 1 sec

* Fix widget auto-update and boot receiver reliability (#296)

* Fix widget boot reliability and midnight worker error handling

- Add QUICKBOOT_POWERON to manifest so widgets refresh on quick reboot
- Update BootReceiver to trigger widget refresh and midnight scheduler on boot
- Wrap MidnightWorker work in try/finally so midnight is always rescheduled even on failure
- Remove HTC-specific boot broadcast action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove orphaned widget string keys from ur and ml translations

The default locale renamed these keys to add _with_bg/_no_bg suffixes,
leaving the old keys as ExtraTranslation lint errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix for ml and ur

* fix translations

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.com>
Co-authored-by: mrknutte26 <knut.tellblom@gmail.com>
Co-authored-by: Magnus Tellblom <blytorsk@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants