-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
This file contains 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
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
changed the title
Corrected App Widget problems for the App
Corrected problems for app widget
Mar 30, 2024
vishal2376
reviewed
Mar 30, 2024
modifier = modifier | ||
.padding(8.dp) | ||
.background(taskBackground) | ||
.clickable(onClick), |
There was a problem hiding this comment.
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
vishal2376
approved these changes
Mar 31, 2024
There was a problem hiding this 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.
app/src/main/java/com/vishal2376/snaptick/widget/components/WidgetTaskComponent.kt
Show resolved
Hide resolved
app/src/main/java/com/vishal2376/snaptick/widget/worker/WidgetTaskUpdateDataWorker.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/vishal2376/snaptick/widget/worker/WidgetTaskUpdateDataWorker.kt
Outdated
Show resolved
Hide resolved
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.
For issue #5
Changes
Corrected issues regarding updating the widget ,Now the widget updates
CRUD
operation on the databaseAdditional
These are some additional things that are added to the app
Please check the results and inform if any changes required