small code cleanup

This commit is contained in:
Markus Doits 2022-12-06 22:09:04 +01:00
parent b95af94893
commit 209cf852bb
No known key found for this signature in database
GPG key ID: 4D406BBC615201D1

View file

@ -356,12 +356,13 @@ class NotificationService(val context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Note: To change a notification channel, you must delete the old one and create a new one! // Note: To change a notification channel, you must delete the old one and create a new one!
val channelId = toChannelId(scope, priority)
val pause = 300L val pause = 300L
val channel = when (priority) { val channel = when (priority) {
1 -> NotificationChannel(toChannelId(scope, priority), context.getString(R.string.channel_notifications_min_name), NotificationManager.IMPORTANCE_MIN) 1 -> NotificationChannel(channelId, context.getString(R.string.channel_notifications_min_name), NotificationManager.IMPORTANCE_MIN)
2 -> NotificationChannel(toChannelId(scope, priority), context.getString(R.string.channel_notifications_low_name), NotificationManager.IMPORTANCE_LOW) 2 -> NotificationChannel(channelId, context.getString(R.string.channel_notifications_low_name), NotificationManager.IMPORTANCE_LOW)
4 -> { 4 -> {
val channel = NotificationChannel(toChannelId(scope, priority), context.getString(R.string.channel_notifications_high_name), NotificationManager.IMPORTANCE_HIGH) val channel = NotificationChannel(channelId, context.getString(R.string.channel_notifications_high_name), NotificationManager.IMPORTANCE_HIGH)
channel.enableVibration(true) channel.enableVibration(true)
channel.vibrationPattern = longArrayOf( channel.vibrationPattern = longArrayOf(
pause, 100, pause, 100, pause, 100, pause, 100, pause, 100, pause, 100,
@ -370,7 +371,7 @@ class NotificationService(val context: Context) {
channel channel
} }
5 -> { 5 -> {
val channel = NotificationChannel(toChannelId(scope, priority), context.getString(R.string.channel_notifications_max_name), NotificationManager.IMPORTANCE_HIGH) // IMPORTANCE_MAX does not exist val channel = NotificationChannel(channelId, context.getString(R.string.channel_notifications_max_name), NotificationManager.IMPORTANCE_HIGH) // IMPORTANCE_MAX does not exist
channel.enableLights(true) channel.enableLights(true)
channel.enableVibration(true) channel.enableVibration(true)
channel.vibrationPattern = longArrayOf( channel.vibrationPattern = longArrayOf(
@ -383,7 +384,7 @@ class NotificationService(val context: Context) {
) )
channel channel
} }
else -> NotificationChannel(toChannelId(scope, priority), context.getString(R.string.channel_notifications_default_name), NotificationManager.IMPORTANCE_DEFAULT) else -> NotificationChannel(channelId, context.getString(R.string.channel_notifications_default_name), NotificationManager.IMPORTANCE_DEFAULT)
} }
if (groupId != null) { if (groupId != null) {