Skip to content

Widget fixes#289

Open
EmmaTellblom wants to merge 16 commits intomainfrom
widget_fixes
Open

Widget fixes#289
EmmaTellblom wants to merge 16 commits intomainfrom
widget_fixes

Conversation

@EmmaTellblom
Copy link
Copy Markdown
Owner

@carstenhag I have tested this locally and it seems to be working. I also changed the texts for the widgets to make it clearer. Now the widget updates when calculations are changed and also after midnight.

Copilot AI and others added 9 commits February 13, 2026 06:39
- 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>
- 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 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>
- 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>
- 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>
- 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>
Fix widget auto-update: schedule midnight updates and refresh on app start
@EmmaTellblom EmmaTellblom requested a review from carstenhag March 5, 2026 20:08
@EmmaTellblom EmmaTellblom mentioned this pull request Mar 5, 2026
<!-- Widget Strings -->
<string name="widget_days_until_period_no_label">Days until period, without label</string>
<string name="widget_days_until_period_with_label">Days until period, with label</string>
<string name="widget_days_until_period_no_label_with_bg">Days until period, without label, with background</string>

Check warning

Code scanning / Android Lint

Incomplete translation Warning

"widget_days_until_period_no_label_with_bg" is not translated in "de" (German), "hi" (Hindi), "ru" (Russian), "sv" (Swedish), "pt" (Portuguese), "it" (Italian), "bn" (Bangla), "fr" (French), "ta" (Tamil), "es" (Spanish), "zh" (Chinese), "ar" (Arabic), "sl" (Slovenian), "fa" (Persian), "pl" (Polish), "ro" (Romanian), "tr" (Turkish)
<string name="widget_days_until_period_no_label">Days until period, without label</string>
<string name="widget_days_until_period_with_label">Days until period, with label</string>
<string name="widget_days_until_period_no_label_with_bg">Days until period, without label, with background</string>
<string name="widget_days_until_period_with_label_with_bg">Days until period, with label, with background</string>

Check warning

Code scanning / Android Lint

Incomplete translation Warning

"widget_days_until_period_with_label_with_bg" is not translated in "de" (German), "hi" (Hindi), "ru" (Russian), "sv" (Swedish), "pt" (Portuguese), "it" (Italian), "bn" (Bangla), "fr" (French), "ta" (Tamil), "es" (Spanish), "zh" (Chinese), "ar" (Arabic), "sl" (Slovenian), "fa" (Persian), "pl" (Polish), "ro" (Romanian), "tr" (Turkish)
<string name="widget_days_until_period_with_label">Days until period, with label</string>
<string name="widget_days_until_period_no_label_with_bg">Days until period, without label, with background</string>
<string name="widget_days_until_period_with_label_with_bg">Days until period, with label, with background</string>
<string name="widget_days_until_period_no_label_no_bg">Days until period, without label, without background</string>

Check warning

Code scanning / Android Lint

Incomplete translation Warning

"widget_days_until_period_no_label_no_bg" is not translated in "de" (German), "hi" (Hindi), "ru" (Russian), "sv" (Swedish), "pt" (Portuguese), "it" (Italian), "bn" (Bangla), "fr" (French), "ta" (Tamil), "es" (Spanish), "zh" (Chinese), "ar" (Arabic), "sl" (Slovenian), "fa" (Persian), "pl" (Polish), "ro" (Romanian), "tr" (Turkish)
<string name="widget_days_until_period_no_label_with_bg">Days until period, without label, with background</string>
<string name="widget_days_until_period_with_label_with_bg">Days until period, with label, with background</string>
<string name="widget_days_until_period_no_label_no_bg">Days until period, without label, without background</string>
<string name="widget_days_until_period_with_label_no_bg">Days until period, with label, without background</string>

Check warning

Code scanning / Android Lint

Incomplete translation Warning

"widget_days_until_period_with_label_no_bg" is not translated in "de" (German), "hi" (Hindi), "ru" (Russian), "sv" (Swedish), "pt" (Portuguese), "it" (Italian), "bn" (Bangla), "fr" (French), "ta" (Tamil), "es" (Spanish), "zh" (Chinese), "ar" (Arabic), "sl" (Slovenian), "fa" (Persian), "pl" (Polish), "ro" (Romanian), "tr" (Turkish)
Copilot AI added a commit to mrknutte26/Mensinator that referenced this pull request Mar 9, 2026
…getUpdater, version bump, DB v11, strings, widget providers

Co-authored-by: mrknutte26 <250676908+mrknutte26@users.noreply.github.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.

4 participants