-
Notifications
You must be signed in to change notification settings - Fork 306
notif: Use Zulip's notification sound on Android #717
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
Conversation
lib/notifications/display.dart
Outdated
|
||
// Delete any older channels. | ||
var found = false; | ||
final channels = await androidPlugin.getNotificationChannels(); |
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.
Rather than add more parts of the package:flutter_local_notifications
API that we use, let's use Pigeon for this. That way in order to be confident of understanding what the code is doing, we only have to read our own code and the Android docs, and not also the flutter_local_notifications
code 🙂 (which often introduces a lot of logic of its own).
As a concrete strategy, let's put this issue after #351: so we convert the existing call sites first (the remaining ones, after #592 covered the most complex of them), and then we go on to add Pigeon bindings for more of the notifications API.
aafef49
to
0ffeefa
Compare
0ffeefa
to
eaf25e6
Compare
c82baa1
to
a018fe3
Compare
a018fe3
to
4020759
Compare
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.
Thanks @rajveermalviya for this. A few small nits below, otherwise LGTM! I have also tested it on my phone, and the notification sound works fine.
As this PR was opened during the official GSoC period, let's move on to the mentor review with @sumanthvrao.
* | ||
* The resource ID is retrieved using | ||
* `android.content.res.Resources.getIdentifier`, which is then used to | ||
* generate a `android.resource://` URI. This URI is then passed |
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.
* generate a `android.resource://` URI. This URI is then passed | |
* generate an `android.resource://` URI. This URI is then passed |
/// | ||
/// The resource ID is retrieved using | ||
/// `android.content.res.Resources.getIdentifier`, which is then used to | ||
/// generate a `android.resource://` URI. This URI is then passed |
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.
/// generate a `android.resource://` URI. This URI is then passed | |
/// generate an `android.resource://` URI. This URI is then passed |
pigeon/notifications.dart
Outdated
/// | ||
/// The resource ID is retrieved using | ||
/// `android.content.res.Resources.getIdentifier`, which is then used to | ||
/// generate a `android.resource://` URI. This URI is then passed |
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.
/// generate a `android.resource://` URI. This URI is then passed | |
/// generate an `android.resource://` URI. This URI is then passed |
c5d12fb
to
16b9f47
Compare
Thanks for the review @sm-sayedi, pushed a new revision. |
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.
Thanks for the PR! Tested manually and it works well for me. Left some comments.
static const kChannelId = 'messages-2'; | ||
|
||
@visibleForTesting | ||
static const kDefaultSoundResourceName = 'chime3'; // 'Zulip - Chime.m4a' |
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.
We should add a comment similar to the one in 785df22.
/// The resource ID is retrieved using | ||
/// `android.content.res.Resources.getIdentifier`, which is then used to | ||
/// generate an `android.resource://` URI. This URI is then passed | ||
/// to the `NotificationChannelCompat` builder. |
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.
We could rephrase this to something similar to
zulip-flutter/pigeon/notifications.dart
Lines 172 to 175 in cdbe141
/// The `smallIconResourceName` is passed to `android.content.res.Resources.getIdentifier` | |
/// to get a resource ID to pass to `Builder.setSmallIcon`. | |
/// Whatever name is passed there must appear in keep.xml too: | |
/// see https://github.com/zulip/zulip-flutter/issues/528 . |
soundResourceName
is expected to be known in keep.xml.
} | ||
|
||
// The channel doesn't exist. Create it. | ||
|
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.
nit: remove empty line
var found = false; | ||
final channels = await _androidHost.getNotificationChannels(); | ||
for (final channel in channels) { | ||
assert(channel != null); // TODO(flutter#97848) |
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.
nit: we can refer to #942 here
16b9f47
to
ca1eefd
Compare
I've split this PR into separate ones: #981 for the notification migration and #982 to support custom notification sounds. The reason for this is that unlike the current PR, #982 fully resolves issue #340 by allowing users to select multiple notification sounds from the settings. Because the full implementation commits became substantial, it seemed like it need to be split in separate PRs. |
Updates: #340
For now, only includes the default sound, i.e. it doesn't show multiple sound options in notification settings - this will be done in later PRs.