Skip to content

Setup for local push notifications#14691

Merged
planarvoid merged 8 commits intodevelopfrom
feature/14639-push-notification-workmanager
May 26, 2021
Merged

Setup for local push notifications#14691
planarvoid merged 8 commits intodevelopfrom
feature/14639-push-notification-workmanager

Conversation

@ravishanker
Copy link
Copy Markdown
Contributor

@ravishanker ravishanker commented May 21, 2021

This PR teases apart WorkManager related code from this draft PR to cater for various types of reminders.

WorkManager is part of the Android Jetpack. It is a library for scheduling deferrable background tasks (work). WorkManager helps you to schedule some work. This work can be one-time, or it can be repeating work. Scheduled work is then stored in an internally managed SQLite database, and WorkManager takes care of ensuring that work persists and is rescheduled across device reboots.

It will be enhanced progressively, while implementing various types of local notifications to schedule notifications.

To test:

Regression Notes

  1. Potential unintended areas of impact
    NA

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    NA

  3. What automated tests I added (or what prevented me from doing so)
    NA

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Add WorkManager setup for handling local push notification like blogging reminders
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented May 21, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented May 21, 2021

You can test the changes on this Pull Request by downloading the APK here.

@ravishanker ravishanker added this to the 17.6 milestone May 21, 2021
fix for detekt issues
Copy link
Copy Markdown
Contributor

@renanferrari renanferrari left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

Before we merge this, I just want to suggest a minor (and potentially nitpicky) change:

I believe we should probably avoid calling this a "local push". As far I as understand, a push notification can't be local by definition, so I'd say we should probably rename all "local push" references to just "local notification". What do you think?

(cc @planarvoid as I know most of these changes were made by you)

Rename and replace all instances of Push with Notification word for clarity
@ravishanker
Copy link
Copy Markdown
Contributor Author

Thanks for taking care of this!

Before we merge this, I just want to suggest a minor (and potentially nitpicky) change:

I believe we should probably avoid calling this a "local push". As far I as understand, a push notification can't be local by definition, so I'd say we should probably rename all "local push" references to just "local notification". What do you think?

(cc @planarvoid as I know most of these changes were made by you)

Makes sense. Renamed all instances of "Push" to "Notification"

Replaced some more instance of Push with Notification naming convention
.addAction(R.drawable.ic_story_icon_24dp, context.getString(R.string.cancel),
pendingIntent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_REMINDER)
Copy link
Copy Markdown
Contributor

@planarvoid planarvoid May 24, 2021

Choose a reason for hiding this comment

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

In the following PR we should reconsider if we need these flags. I've originally introduced them only because I was trying what I can set for the design purposes. The same goes to the addAction where the icon and the text should probably be part of the inputData. We should also remove the setLargeIcon which should probably be done in this PR as it doesn't make sense here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've moved icon and title to inputData and removed setLargeIcon. Left the priority and category for now, we can remove them if not required when testing the reminders. Thanks

Copy link
Copy Markdown
Contributor

@planarvoid planarvoid left a comment

Choose a reason for hiding this comment

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

Thanks for pulling out this PR. I think it can potentially affect the UploadWorker because we're touching the code around its initialization. Could you please check where it's used and try to test if it works as expected? Other than that it's looking good. I have few minor comments.

private val accountStore: AccountStore,
private val siteStore: SiteStore
) : LocalNotificationHandler {
override fun shouldShowNotification(): Boolean {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd maybe add a unit test for this method.

) {
fun buildLocalNotificationHandler(type: Type): LocalNotificationHandler {
return when (type) {
CREATE_SITE -> createSiteNotificationHandler
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe also add a unit test for this factory 👍

Removed unnecessary params like large icon and parameterised action icon and title
Copy link
Copy Markdown
Contributor

@planarvoid planarvoid left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! it's looking good 👍

@planarvoid planarvoid merged commit 148df85 into develop May 26, 2021
@planarvoid planarvoid deleted the feature/14639-push-notification-workmanager branch May 26, 2021 12:08
@renanferrari renanferrari mentioned this pull request Jul 23, 2021
3 tasks
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