diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt index da5e0dc785..f5f0ce5cca 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/channels/NotificationChannels.kt @@ -7,8 +7,12 @@ package io.element.android.libraries.push.impl.notifications.channels +import android.content.ContentResolver +import android.content.Context import android.media.AudioAttributes +import android.media.AudioAttributes.USAGE_NOTIFICATION import android.media.AudioManager +import android.net.Uri import android.os.Build import android.provider.Settings import androidx.annotation.ChecksSdkIntAtLeast @@ -19,6 +23,7 @@ import dev.zacsweers.metro.ContributesBinding import dev.zacsweers.metro.Inject import dev.zacsweers.metro.SingleIn import io.element.android.appconfig.NotificationConfig +import io.element.android.libraries.di.annotations.ApplicationContext import io.element.android.libraries.push.impl.R import io.element.android.services.toolbox.api.strings.StringProvider @@ -26,7 +31,7 @@ import io.element.android.services.toolbox.api.strings.StringProvider * IDs for channels * ========================================================================================== */ internal const val SILENT_NOTIFICATION_CHANNEL_ID = "DEFAULT_SILENT_NOTIFICATION_CHANNEL_ID_V2" -internal const val NOISY_NOTIFICATION_CHANNEL_ID = "DEFAULT_NOISY_NOTIFICATION_CHANNEL_ID" +internal const val NOISY_NOTIFICATION_CHANNEL_ID = "DEFAULT_NOISY_NOTIFICATION_CHANNEL_ID_V2" internal const val CALL_NOTIFICATION_CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL_ID_V3" internal const val RINGING_CALL_NOTIFICATION_CHANNEL_ID = "RINGING_CALL_NOTIFICATION_CHANNEL_ID" @@ -61,6 +66,8 @@ private fun supportNotificationChannels() = Build.VERSION.SDK_INT >= Build.VERSI class DefaultNotificationChannels( private val notificationManager: NotificationManagerCompat, private val stringProvider: StringProvider, + @ApplicationContext + private val context: Context, ) : NotificationChannels { init { createNotificationChannels() @@ -94,6 +101,7 @@ class DefaultNotificationChannels( // Migration - Remove deprecated channels for (channelId in listOf( "DEFAULT_SILENT_NOTIFICATION_CHANNEL_ID", + "DEFAULT_NOISY_NOTIFICATION_CHANNEL_ID", "CALL_NOTIFICATION_CHANNEL_ID", "CALL_NOTIFICATION_CHANNEL_ID_V2", "LISTEN_FOR_EVENTS_NOTIFICATION_CHANNEL_ID", @@ -112,6 +120,17 @@ class DefaultNotificationChannels( NOISY_NOTIFICATION_CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_DEFAULT ) + .setSound( + Uri.Builder() + .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) + // Strangely wwe have to provide a "//" before the package name + .path("//" + context.packageName + "/" + R.raw.message) + .build(), + AudioAttributes.Builder() + .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) + .setUsage(USAGE_NOTIFICATION) + .build(), + ) .setName(stringProvider.getString(R.string.notification_channel_noisy).ifEmpty { "Noisy notifications" }) .setDescription(stringProvider.getString(R.string.notification_channel_noisy)) .setVibrationEnabled(true) diff --git a/libraries/push/impl/src/main/res/raw/message.mp3 b/libraries/push/impl/src/main/res/raw/message.mp3 new file mode 100644 index 0000000000..5e9645adaf Binary files /dev/null and b/libraries/push/impl/src/main/res/raw/message.mp3 differ