-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Refactor notifications #4883
base: develop
Are you sure you want to change the base?
Refactor notifications #4883
Conversation
// "Post failed" dialog should display in this activity | ||
draftsAlert.observeInContext(this@MainActivity, true) | ||
} | ||
|
||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { |
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 is the bug fix.
@@ -75,6 +75,7 @@ class TuskyApplication : Application(), Configuration.Provider { | |||
NEW_INSTALL_SCHEMA_VERSION | |||
) | |||
if (oldVersion != SCHEMA_VERSION) { | |||
// TODO SCHEMA_VERSION is outdated / not updated in code |
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.
Collateral find.
if (!NotificationHelper.areNotificationsEnabled(context, accountManager)) { | ||
NotificationHelper.disablePullNotifications(context) | ||
if (!notificationService.areNotificationsEnabled()) { | ||
// TODO this is working very wrong |
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.
That would then be a next step.
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 you give some more details what the problem is?
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.
Mostly with the "thinking" behind it (or lack thereof). Earlier I had "worded very wrong" there.
It's "if notifications are disabled then disable them"?
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.
Oh this is a very good idea, thank you!
I have mostly Kotlin style complaints, and I think NotificationHelper
can now be deleted?
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
Log.d(TAG, "Enabled pull checks with " + PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS + "ms interval.") | ||
} | ||
|
||
fun disablePullNotifications(context: Context) { |
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 need for the context
parameter, there is already a Context
injected
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.
That is a bit of a question still: Does it matter which context is used (somewhere)?
90% of locations in the old code worked directly or indirectly with application context. But some did and do not.
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.
It can matter, yes, for example when taking theme attributes from a context, then you need to use the Activity Context as each Activity can have a different theme. But here it shouldn't 🤔
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.
All removed.
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt
Outdated
Show resolved
Hide resolved
// "Post failed" dialog should display in this activity | ||
draftsAlert.observeInContext(this@MainActivity, true) | ||
} | ||
|
||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { |
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 use the newer ActivityResultContracts
api instead. See ViewMediaActivity
for an example.
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
899df36
to
1919543
Compare
1919543
to
dc16b04
Compare
Also fixes #4858.
But apart from that there should be no functional change.