Loading app/core/src/main/java/com/fsck/k9/notification/AuthenticationErrorNotificationController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -30,15 +30,7 @@ internal open class AuthenticationErrorNotificationController( .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPublicVersion(createLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_ERROR) notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) .setErrorAppearance() notificationManager.notify(notificationId, notificationBuilder.build()) } Loading app/core/src/main/java/com/fsck/k9/notification/CertificateErrorNotificationController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -30,15 +30,7 @@ internal open class CertificateErrorNotificationController( .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPublicVersion(createLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_ERROR) notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) .setErrorAppearance() notificationManager.notify(notificationId, notificationBuilder.build()) } Loading app/core/src/main/java/com/fsck/k9/notification/NotificationHelper.kt +15 −47 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ package com.fsck.k9.notification import android.content.Context import android.net.Uri import android.os.Build import android.text.TextUtils import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import com.fsck.k9.Account Loading @@ -14,47 +13,6 @@ class NotificationHelper( private val notificationManager: NotificationManagerCompat, private val channelUtils: NotificationChannelManager ) { fun configureNotification( builder: NotificationCompat.Builder, ringtone: String?, vibrationPattern: LongArray?, ledColor: Int?, ledSpeed: Int, ringAndVibrate: Boolean ) { if (K9.isQuietTime) { builder.setNotificationSilent() return } if (ringAndVibrate) { if (ringtone != null && !TextUtils.isEmpty(ringtone)) { builder.setSound(Uri.parse(ringtone)) } if (vibrationPattern != null) { builder.setVibrate(vibrationPattern) } } else { builder.setNotificationSilent() } if (ledColor != null) { val ledOnMS: Int val ledOffMS: Int if (ledSpeed == NOTIFICATION_LED_BLINK_SLOW) { ledOnMS = NOTIFICATION_LED_ON_TIME ledOffMS = NOTIFICATION_LED_OFF_TIME } else { ledOnMS = NOTIFICATION_LED_FAST_ON_TIME ledOffMS = NOTIFICATION_LED_FAST_OFF_TIME } builder.setLights(ledColor, ledOnMS, ledOffMS) } } fun getContext(): Context { return context } Loading @@ -76,12 +34,22 @@ class NotificationHelper( companion object { internal const val NOTIFICATION_LED_ON_TIME = 500 internal const val NOTIFICATION_LED_OFF_TIME = 2000 private const val NOTIFICATION_LED_FAST_ON_TIME = 100 private const val NOTIFICATION_LED_FAST_OFF_TIME = 100 internal const val NOTIFICATION_LED_FAST_ON_TIME = 100 internal const val NOTIFICATION_LED_FAST_OFF_TIME = 100 internal const val NOTIFICATION_LED_FAILURE_COLOR = 0xFFFF0000L.toInt() } } internal fun NotificationCompat.Builder.setErrorAppearance(): NotificationCompat.Builder = apply { setSilent(true) internal const val NOTIFICATION_LED_BLINK_SLOW = 0 internal const val NOTIFICATION_LED_BLINK_FAST = 1 internal const val NOTIFICATION_LED_FAILURE_COLOR = -0x10000 if (!K9.isQuietTime) { setLights( NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, NotificationHelper.NOTIFICATION_LED_FAST_ON_TIME, NotificationHelper.NOTIFICATION_LED_FAST_OFF_TIME ) } } Loading app/core/src/main/java/com/fsck/k9/notification/SendFailedNotificationController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -42,15 +42,7 @@ internal class SendFailedNotificationController( .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPublicVersion(createLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_ERROR) notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) .setErrorAppearance() notificationManager.notify(notificationId, notificationBuilder.build()) } Loading app/core/src/main/java/com/fsck/k9/notification/SyncNotificationController.kt +0 −35 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ import androidx.core.app.NotificationManagerCompat import com.fsck.k9.Account import com.fsck.k9.mailstore.LocalFolder private const val NOTIFICATION_LED_WHILE_SYNCING = false internal class SyncNotificationController( private val notificationHelper: NotificationHelper, private val actionBuilder: NotificationActionCreator, Loading Loading @@ -36,17 +34,6 @@ internal class SyncNotificationController( .setContentIntent(showMessageListPendingIntent) .setPublicVersion(createSendingLockScreenNotification(account)) if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = account.notificationSettings.light.toColor(account), ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) } notificationManager.notify(notificationId, notificationBuilder.build()) } Loading Loading @@ -83,17 +70,6 @@ internal class SyncNotificationController( .setPublicVersion(createFetchingMailLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_SERVICE) if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = account.notificationSettings.light.toColor(account), ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) } notificationManager.notify(notificationId, notificationBuilder.build()) } Loading @@ -113,17 +89,6 @@ internal class SyncNotificationController( .setPublicVersion(createFetchingMailLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_SERVICE) if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = account.notificationSettings.light.toColor(account), ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) } notificationManager.notify(notificationId, notificationBuilder.build()) } Loading Loading
app/core/src/main/java/com/fsck/k9/notification/AuthenticationErrorNotificationController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -30,15 +30,7 @@ internal open class AuthenticationErrorNotificationController( .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPublicVersion(createLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_ERROR) notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) .setErrorAppearance() notificationManager.notify(notificationId, notificationBuilder.build()) } Loading
app/core/src/main/java/com/fsck/k9/notification/CertificateErrorNotificationController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -30,15 +30,7 @@ internal open class CertificateErrorNotificationController( .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPublicVersion(createLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_ERROR) notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) .setErrorAppearance() notificationManager.notify(notificationId, notificationBuilder.build()) } Loading
app/core/src/main/java/com/fsck/k9/notification/NotificationHelper.kt +15 −47 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ package com.fsck.k9.notification import android.content.Context import android.net.Uri import android.os.Build import android.text.TextUtils import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import com.fsck.k9.Account Loading @@ -14,47 +13,6 @@ class NotificationHelper( private val notificationManager: NotificationManagerCompat, private val channelUtils: NotificationChannelManager ) { fun configureNotification( builder: NotificationCompat.Builder, ringtone: String?, vibrationPattern: LongArray?, ledColor: Int?, ledSpeed: Int, ringAndVibrate: Boolean ) { if (K9.isQuietTime) { builder.setNotificationSilent() return } if (ringAndVibrate) { if (ringtone != null && !TextUtils.isEmpty(ringtone)) { builder.setSound(Uri.parse(ringtone)) } if (vibrationPattern != null) { builder.setVibrate(vibrationPattern) } } else { builder.setNotificationSilent() } if (ledColor != null) { val ledOnMS: Int val ledOffMS: Int if (ledSpeed == NOTIFICATION_LED_BLINK_SLOW) { ledOnMS = NOTIFICATION_LED_ON_TIME ledOffMS = NOTIFICATION_LED_OFF_TIME } else { ledOnMS = NOTIFICATION_LED_FAST_ON_TIME ledOffMS = NOTIFICATION_LED_FAST_OFF_TIME } builder.setLights(ledColor, ledOnMS, ledOffMS) } } fun getContext(): Context { return context } Loading @@ -76,12 +34,22 @@ class NotificationHelper( companion object { internal const val NOTIFICATION_LED_ON_TIME = 500 internal const val NOTIFICATION_LED_OFF_TIME = 2000 private const val NOTIFICATION_LED_FAST_ON_TIME = 100 private const val NOTIFICATION_LED_FAST_OFF_TIME = 100 internal const val NOTIFICATION_LED_FAST_ON_TIME = 100 internal const val NOTIFICATION_LED_FAST_OFF_TIME = 100 internal const val NOTIFICATION_LED_FAILURE_COLOR = 0xFFFF0000L.toInt() } } internal fun NotificationCompat.Builder.setErrorAppearance(): NotificationCompat.Builder = apply { setSilent(true) internal const val NOTIFICATION_LED_BLINK_SLOW = 0 internal const val NOTIFICATION_LED_BLINK_FAST = 1 internal const val NOTIFICATION_LED_FAILURE_COLOR = -0x10000 if (!K9.isQuietTime) { setLights( NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, NotificationHelper.NOTIFICATION_LED_FAST_ON_TIME, NotificationHelper.NOTIFICATION_LED_FAST_OFF_TIME ) } } Loading
app/core/src/main/java/com/fsck/k9/notification/SendFailedNotificationController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -42,15 +42,7 @@ internal class SendFailedNotificationController( .setStyle(NotificationCompat.BigTextStyle().bigText(text)) .setPublicVersion(createLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_ERROR) notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = NotificationHelper.NOTIFICATION_LED_FAILURE_COLOR, ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) .setErrorAppearance() notificationManager.notify(notificationId, notificationBuilder.build()) } Loading
app/core/src/main/java/com/fsck/k9/notification/SyncNotificationController.kt +0 −35 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ import androidx.core.app.NotificationManagerCompat import com.fsck.k9.Account import com.fsck.k9.mailstore.LocalFolder private const val NOTIFICATION_LED_WHILE_SYNCING = false internal class SyncNotificationController( private val notificationHelper: NotificationHelper, private val actionBuilder: NotificationActionCreator, Loading Loading @@ -36,17 +34,6 @@ internal class SyncNotificationController( .setContentIntent(showMessageListPendingIntent) .setPublicVersion(createSendingLockScreenNotification(account)) if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = account.notificationSettings.light.toColor(account), ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) } notificationManager.notify(notificationId, notificationBuilder.build()) } Loading Loading @@ -83,17 +70,6 @@ internal class SyncNotificationController( .setPublicVersion(createFetchingMailLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_SERVICE) if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = account.notificationSettings.light.toColor(account), ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) } notificationManager.notify(notificationId, notificationBuilder.build()) } Loading @@ -113,17 +89,6 @@ internal class SyncNotificationController( .setPublicVersion(createFetchingMailLockScreenNotification(account)) .setCategory(NotificationCompat.CATEGORY_SERVICE) if (NOTIFICATION_LED_WHILE_SYNCING) { notificationHelper.configureNotification( builder = notificationBuilder, ringtone = null, vibrationPattern = null, ledColor = account.notificationSettings.light.toColor(account), ledSpeed = NotificationHelper.NOTIFICATION_LED_BLINK_FAST, ringAndVibrate = true ) } notificationManager.notify(notificationId, notificationBuilder.build()) } Loading