-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Disable local notifications with Notification Settings switch #17496
Conversation
# Conflicts: # build.gradle
Found 1 violations: The PR caused the following dependency changes:-+--- org.wordpress:fluxc:{strictly trunk-5a4f8132de39ae666f841edc4522f87b1b02a265} -> trunk-5a4f8132de39ae666f841edc4522f87b1b02a265
-| +--- org.wordpress:wellsql:1.7.0
-| | \--- org.wordpress.wellsql:wellsql-annotations:1.7.0
-| +--- org.wordpress.fluxc:fluxc-annotations:trunk-5a4f8132de39ae666f841edc4522f87b1b02a265
-| +--- org.greenrobot:eventbus:3.3.1 (*)
-| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.2 (*)
-| +--- com.android.volley:volley:1.1.1 -> 1.2.0
-| +--- androidx.paging:paging-runtime:2.1.2
-| | +--- androidx.paging:paging-common:2.1.2
-| | | +--- androidx.annotation:annotation:1.0.0 -> 1.2.0
-| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.4.1 (*)
-| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.4.1 (*)
-| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.1.0 (*)
-| +--- com.goterl:lazysodium-android:5.0.2
-| +--- net.java.dev.jna:jna:5.5.0
-| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 (*)
-| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10 (*)
-| +--- androidx.appcompat:appcompat:1.0.2 -> 1.3.1 (*)
-| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.1.0 (*)
-| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3 (*)
-| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0 -> 4.9.2
-| | +--- com.squareup.okhttp3:okhttp:4.9.2 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.6.10 (*)
-| +--- com.google.code.gson:gson:2.8.5
-| +--- org.apache.commons:commons-text:1.1 (*)
-| +--- androidx.room:room-runtime:2.4.2 (*)
-| +--- androidx.room:room-ktx:2.4.2
-| | +--- androidx.room:room-common:2.4.2 (*)
-| | +--- androidx.room:room-runtime:2.4.2 (*)
-| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 (*)
-| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2 (*)
-| +--- com.google.dagger:dagger:2.42 (*)
-| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.5.2 (*)
-| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.5.2 (*)
++--- org.wordpress:fluxc:{strictly trunk-7e1f7406753a72cbed61feab1204ca52ba7f0f77} -> trunk-7e1f7406753a72cbed61feab1204ca52ba7f0f77
+| +--- org.wordpress:wellsql:1.7.0
+| | \--- org.wordpress.wellsql:wellsql-annotations:1.7.0
+| +--- org.wordpress.fluxc:fluxc-annotations:trunk-7e1f7406753a72cbed61feab1204ca52ba7f0f77
+| +--- org.greenrobot:eventbus:3.3.1 (*)
+| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.2 (*)
+| +--- com.android.volley:volley:1.1.1 -> 1.2.0
+| +--- androidx.paging:paging-runtime:2.1.2
+| | +--- androidx.paging:paging-common:2.1.2
+| | | +--- androidx.annotation:annotation:1.0.0 -> 1.2.0
+| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.4.1 (*)
+| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.4.1 (*)
+| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.1.0 (*)
+| +--- com.goterl:lazysodium-android:5.0.2
+| +--- net.java.dev.jna:jna:5.5.0
+| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 (*)
+| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10 (*)
+| +--- androidx.appcompat:appcompat:1.0.2 -> 1.3.1 (*)
+| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.1.0 (*)
+| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3 (*)
+| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0 -> 4.9.2
+| | +--- com.squareup.okhttp3:okhttp:4.9.2 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.6.10 (*)
+| +--- com.google.code.gson:gson:2.8.5
+| +--- org.apache.commons:commons-text:1.1 (*)
+| +--- androidx.room:room-runtime:2.4.2 (*)
+| +--- androidx.room:room-ktx:2.4.2
+| | +--- androidx.room:room-common:2.4.2 (*)
+| | +--- androidx.room:room-runtime:2.4.2 (*)
+| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 (*)
+| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2 (*)
+| +--- com.google.dagger:dagger:2.42 (*)
+| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.5.2 (*)
+| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.5.2 (*)
\--- org.wordpress:login:1.0.0
- \--- org.wordpress:fluxc:2.0.0 -> trunk-5a4f8132de39ae666f841edc4522f87b1b02a265 (*)
+ \--- org.wordpress:fluxc:2.0.0 -> trunk-7e1f7406753a72cbed61feab1204ca52ba7f0f77 (*)
Please review and act accordingly
|
📲 You can test these changes on WordPress by downloading wordpress-installable-build-pr17496-7df6d32.apk
|
📲 You can test these changes on Jetpack by downloading jetpack-installable-build-pr17496-7df6d32.apk
|
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.
Nice work 👍
Feel free to merge it after resolving build issues
// Set up primary toolbar | ||
setUpToolbar() | ||
|
||
// Set up main switch |
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.
comment is redundant here
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.
I just copied Java while converting. But I agree. The code is already explaining itself.
Removed! 7df6d32
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this@NotificationsSettingsActivity) | ||
|
||
// Set up primary toolbar | ||
setUpToolbar() |
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.
Could be renamed to setupPrimaryToolbar()
and remove the comment
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.
Done! 7df6d32
fragmentContainer = findViewById(id.fragment_container) | ||
|
||
// Get shared preferences for main switch. | ||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this@NotificationsSettingsActivity) |
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.
Same here, renaming it to mainSwitchPrefs would remove the need for comment
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.
Actually, sharedPreferences
doesn't have to be a class variable. I moved it to the function. 7df6d32
@@ -2,6 +2,7 @@ | |||
|
|||
21.3 | |||
----- | |||
* [*] Disable local notifications with Notification Settings switch. [https://github.com/wordpress-mobile/WordPress-Android/pull/17496] |
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.
Should this be marked as [internal]
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.
I think an important issue was fixed. This is not only about Jetpack Focus. With this PR, the Notifications Settings switch will affect local notifications too. So, I think it should not be internal.
import javax.inject.Named | ||
|
||
@AndroidEntryPoint | ||
class NotificationsSettingsActivity : LocaleAwareActivity(), MainSwitchToolbarListener { |
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.
🎉 Kudos for converting it to Kotlin
hideDisabledView(isMainChecked) | ||
} | ||
|
||
override fun onMainSwitchCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) { |
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.
This was removed in a previous PR right?
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.
No, onMainSwitchCheckedChanged
was being called unnecessarily at launch. I fixed that in #17498. It didn't change this class.
Fixes #15816
This prevents local notifications when the Notification Settings switch is off. Prevented local notifications are
Blogging reminders popups are still active and can be displayed in some cases (eg. from Site Settings) even Notification Settings switch is off. If the user sets a new reminder from the popup, it will be scheduled even if the switch is off.
Merge requirements:
trunk
[Status] Not Ready for Merge
labelTo test:
You can wait for scheduled dates to test notifications. It would be the best method but testing all cases takes an unrealistic long time. Alternatively, you can check App Inspection > Background Task Inspector on Android Studio if these notifications are scheduled.
Weekly roundup notifications
WeeklyRoundupWorker
is canceled onApp Inspection > Background Task Inspector
.WeeklyRoundupWorker
is scheduled onApp Inspection > Background Task Inspector
.Blogging reminder notifications
My Site → MENU → Site Settings
.ReminderWorker
is scheduled onApp Inspection > Background Task Inspector
.ReminderWorker
is scheduled onApp Inspection > Background Task Inspector
.ReminderWorker
s are canceled onApp Inspection > Background Task Inspector
.ReminderWorker
s are scheduled onApp Inspection > Background Task Inspector
.Create site notifications
LocalNotificationWorker
is scheduled onApp Inspection > Background Task Inspector
.LocalNotificationWorker
is canceled onApp Inspection > Background Task Inspector
.NOTE: Create site notifications won't be rescheduled if you turn on the switch again. Two Create site notifications are scheduled when the app is installed the first time. One is for the next day after the install, another one is for 8 days after the first install. If the switch is turned off and turned on in 8 days, create site notifications won't display. I'll discuss this later and change it in a separate PR if necessary.
Regression Notes
Potential unintended areas of impact
Rescheduling blogging reminders after turning Notification Settings off and on again.
What I did to test those areas of impact (or what existing automated tests I relied on)
Tested manually.
What automated tests I added (or what prevented me from doing so)
Update
CreateSiteNotificationHandlerTest
.PR submission checklist:
RELEASE-NOTES.txt
if necessary.