|
|
@ -162,7 +162,8 @@ class DefaultNotificationChannels @Inject constructor( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Register a channel for incoming call notifications which will ring the device when received |
|
|
|
// Register a channel for incoming call notifications which will ring the device when received |
|
|
|
val ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE) |
|
|
|
// TODO use a fallback ringtone if the default ringtone is not available |
|
|
|
|
|
|
|
val ringtoneUri = runCatching { RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE) }.getOrNull() |
|
|
|
notificationManager.createNotificationChannel( |
|
|
|
notificationManager.createNotificationChannel( |
|
|
|
NotificationChannelCompat.Builder( |
|
|
|
NotificationChannelCompat.Builder( |
|
|
|
RINGING_CALL_NOTIFICATION_CHANNEL_ID, |
|
|
|
RINGING_CALL_NOTIFICATION_CHANNEL_ID, |
|
|
@ -170,7 +171,9 @@ class DefaultNotificationChannels @Inject constructor( |
|
|
|
) |
|
|
|
) |
|
|
|
.setName(stringProvider.getString(R.string.notification_channel_ringing_calls).ifEmpty { "Ringing calls" }) |
|
|
|
.setName(stringProvider.getString(R.string.notification_channel_ringing_calls).ifEmpty { "Ringing calls" }) |
|
|
|
.setVibrationEnabled(true) |
|
|
|
.setVibrationEnabled(true) |
|
|
|
.setSound( |
|
|
|
.apply { |
|
|
|
|
|
|
|
if (ringtoneUri != null) { |
|
|
|
|
|
|
|
setSound( |
|
|
|
ringtoneUri, |
|
|
|
ringtoneUri, |
|
|
|
AudioAttributes.Builder() |
|
|
|
AudioAttributes.Builder() |
|
|
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
|
|
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
|
|
@ -178,6 +181,8 @@ class DefaultNotificationChannels @Inject constructor( |
|
|
|
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) |
|
|
|
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
.setDescription(stringProvider.getString(R.string.notification_channel_ringing_calls)) |
|
|
|
.setDescription(stringProvider.getString(R.string.notification_channel_ringing_calls)) |
|
|
|
.setLightsEnabled(true) |
|
|
|
.setLightsEnabled(true) |
|
|
|
.setLightColor(accentColor) |
|
|
|
.setLightColor(accentColor) |
|
|
|