Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected problems for app widget #59

Merged
merged 8 commits into from
Mar 31, 2024
Merged

Corrected problems for app widget #59

merged 8 commits into from
Mar 31, 2024

Conversation

tuuhin
Copy link
Contributor

@tuuhin tuuhin commented Mar 30, 2024

For issue #5

Changes

Corrected issues regarding updating the widget ,Now the widget updates

  • Periodic updates to sync with next day's data
  • On Any CRUD operation on the database
  • On widget interaction

Additional

These are some additional things that are added to the app

  • Added widget preview (preview when selecting the widget).
  • Configured hilt to work with workers

Please check the results and inform if any changes required

To inject dependencies into a Worker hilt work and hilt compiler dependencies are added.
In SnaptickApplication workerManager configuration is added as per hilt docs.
Created WidgetTaskModel this is a tree shaken variant of Task Model as widget don't required all the values this model will be used to store data in the GlanceStateDefinition
SnaptickWidgetState is an instance of GlanceStateDefination of List of WidgetTaskModel it provides a datastore which stores the state information, now we use TaskSerializer with the help of gson and LocalTimeGsonSerializer we serialize the List of WidgetTaskModel to keep it in a file and later deserialize it to show in our widgets.
WidgetTaskUpdateDataWorker is a CoroutineWorker that will update the SnaptickWidgetState and the widget with new values for the meantime the values are only updated on widget enabled.
The work is simple fetch the tasks and show the incomplete ones.
AppWidgetInteractor provides methods to start the worker and to cancel the worker
As SnaptickWidgetReceiver is also a BroadcastReceiver we inject it and enqueue the worker to set the state for the widget
Rather than putting the whole widget into single file its split into components and kept in components package.
A custom widget loading and widget preview is added
Update worker will periodically update the widget.
Added methods in AppWidgetInteractor for periodic work.
OnTaskClickedCallback added a custom entry point which will help to update the repository and again start the worker to update the widget
app_widget_preview.xml contains the widget preview
changed style of widget_loading.xml
AppModule::providesTaskRepository now takes dao and widgetInteract
In TaskRepository::getAllTasks on each emit of the flow start the worker to update the widget state.
Configured RepeatTaskWorker to use hilt
@tuuhin tuuhin changed the title Corrected App Widget problems for the App Corrected problems for app widget Mar 30, 2024
modifier = modifier
.padding(8.dp)
.background(taskBackground)
.clickable(onClick),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't make whole task clickable (User can click on it by mistake during scrolling)

Only make checkbox image clickable

this worker will be only used to update the widget data at midnight, removed setNextScheduleTime and used setInitialDelay,
SnaptickWidgetReceiver enqueued both one time-worker for current update and periodic worker for next day update.
Moved the clickable modifier to WidgetTaskComponent child
If in future much things need to saved in the state object thus rather than storing Only List of WidgetTaskModel we will store SnaptickWidgetState which for the meantime will only store widget tasks
Copy link
Owner

@vishal2376 vishal2376 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me.

@vishal2376 vishal2376 merged commit 89a38e5 into vishal2376:feat/widget Mar 31, 2024
@tuuhin tuuhin deleted the feat/widget branch March 31, 2024 17:21
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.

None yet

2 participants