mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-28 00:39:01 +03:00
Merge pull request #3786 from vector-im/feature/dla/fix_missing_notification_noise
Fix missing sounds on room notifications (messages, invitations, etc).
This commit is contained in:
commit
ee0b87bd82
3 changed files with 9 additions and 4 deletions
changelog.d
vector/src/main/java/im/vector/app/features/notifications
1
changelog.d/3243.bugfix
Normal file
1
changelog.d/3243.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Notifications - Fix missing sound on notifications.
|
|
@ -100,13 +100,14 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
if (existing.isPushGatewayEvent) {
|
if (existing.isPushGatewayEvent) {
|
||||||
// Use the event coming from the event stream as it may contains more info than
|
// Use the event coming from the event stream as it may contains more info than
|
||||||
// the fcm one (like type/content/clear text)
|
// the fcm one (like type/content/clear text) (e.g when an encrypted message from
|
||||||
|
// FCM should be update with clear text after a sync)
|
||||||
// In this case the message has already been notified, and might have done some noise
|
// In this case the message has already been notified, and might have done some noise
|
||||||
// So we want the notification to be updated even if it has already been displayed
|
// So we want the notification to be updated even if it has already been displayed
|
||||||
// But it should make no noise (e.g when an encrypted message from FCM should be
|
// Use setOnlyAlertOnce to ensure update notification does not interfere with sound
|
||||||
// update with clear text after a sync)
|
// from first notify invocation as outlined in:
|
||||||
|
// https://developer.android.com/training/notify-user/build-notification#Updating
|
||||||
notifiableEvent.hasBeenDisplayed = false
|
notifiableEvent.hasBeenDisplayed = false
|
||||||
notifiableEvent.noisy = false
|
|
||||||
eventList.remove(existing)
|
eventList.remove(existing)
|
||||||
eventList.add(notifiableEvent)
|
eventList.add(notifiableEvent)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -540,6 +540,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||||
|
|
||||||
val channelID = if (roomInfo.shouldBing) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID
|
val channelID = if (roomInfo.shouldBing) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID
|
||||||
return NotificationCompat.Builder(context, channelID)
|
return NotificationCompat.Builder(context, channelID)
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
.setWhen(lastMessageTimestamp)
|
.setWhen(lastMessageTimestamp)
|
||||||
// MESSAGING_STYLE sets title and content for API 16 and above devices.
|
// MESSAGING_STYLE sets title and content for API 16 and above devices.
|
||||||
.setStyle(messageStyle)
|
.setStyle(messageStyle)
|
||||||
|
@ -641,6 +642,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||||
val channelID = if (inviteNotifiableEvent.noisy) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID
|
val channelID = if (inviteNotifiableEvent.noisy) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID
|
||||||
|
|
||||||
return NotificationCompat.Builder(context, channelID)
|
return NotificationCompat.Builder(context, channelID)
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
.setContentTitle(stringProvider.getString(R.string.app_name))
|
.setContentTitle(stringProvider.getString(R.string.app_name))
|
||||||
.setContentText(inviteNotifiableEvent.description)
|
.setContentText(inviteNotifiableEvent.description)
|
||||||
.setGroup(stringProvider.getString(R.string.app_name))
|
.setGroup(stringProvider.getString(R.string.app_name))
|
||||||
|
@ -704,6 +706,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||||
val channelID = if (simpleNotifiableEvent.noisy) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID
|
val channelID = if (simpleNotifiableEvent.noisy) NOISY_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID
|
||||||
|
|
||||||
return NotificationCompat.Builder(context, channelID)
|
return NotificationCompat.Builder(context, channelID)
|
||||||
|
.setOnlyAlertOnce(true)
|
||||||
.setContentTitle(stringProvider.getString(R.string.app_name))
|
.setContentTitle(stringProvider.getString(R.string.app_name))
|
||||||
.setContentText(simpleNotifiableEvent.description)
|
.setContentText(simpleNotifiableEvent.description)
|
||||||
.setGroup(stringProvider.getString(R.string.app_name))
|
.setGroup(stringProvider.getString(R.string.app_name))
|
||||||
|
|
Loading…
Add table
Reference in a new issue