Loading app/core/src/main/java/com/fsck/k9/notification/BackgroundWorkNotificationController.kt 0 → 100644 +9 −0 Original line number Original line Diff line number Diff line package com.fsck.k9.notification import android.app.Notification interface BackgroundWorkNotificationController { val notificationId: Int fun createNotification(text: String): Notification } app/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -130,4 +130,11 @@ val coreNotificationModule = module { notificationConfigurationConverter = get(), notificationConfigurationConverter = get(), ) ) } } factory<BackgroundWorkNotificationController> { RealBackgroundWorkNotificationController( context = get(), resourceProvider = get(), notificationChannelManager = get(), ) } } } app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt +17 −0 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ class NotificationChannelManager( private val notificationLightDecoder: NotificationLightDecoder, private val notificationLightDecoder: NotificationLightDecoder, ) { ) { val pushChannelId = "push" val pushChannelId = "push" val miscellaneousChannelId = "misc" enum class ChannelType { enum class ChannelType { MESSAGES, MISCELLANEOUS MESSAGES, MISCELLANEOUS Loading Loading @@ -50,6 +51,7 @@ class NotificationChannelManager( @RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O) private fun addGeneralChannels() { private fun addGeneralChannels() { notificationManager.createNotificationChannel(getChannelPush()) notificationManager.createNotificationChannel(getChannelPush()) notificationManager.createNotificationChannel(getChannelMiscellaneous()) } } @RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O) Loading Loading @@ -101,6 +103,21 @@ class NotificationChannelManager( } } } } @RequiresApi(api = Build.VERSION_CODES.O) private fun getChannelMiscellaneous(): NotificationChannel { val channelName = resourceProvider.miscellaneousChannelName val channelDescription = resourceProvider.miscellaneousChannelDescription val importance = NotificationManager.IMPORTANCE_LOW return NotificationChannel(miscellaneousChannelId, channelName, importance).apply { description = channelDescription setShowBadge(false) enableLights(false) enableVibration(false) setSound(null, null) } } @RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O) private fun getChannelMessages(account: Account): NotificationChannel { private fun getChannelMessages(account: Account): NotificationChannel { val channelName = resourceProvider.messagesChannelName val channelName = resourceProvider.messagesChannelName Loading app/core/src/main/java/com/fsck/k9/notification/NotificationIds.kt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -4,8 +4,9 @@ import com.fsck.k9.Account internal object NotificationIds { internal object NotificationIds { const val PUSH_NOTIFICATION_ID = 1 const val PUSH_NOTIFICATION_ID = 1 const val BACKGROUND_WORK_NOTIFICATION_ID = 2 private const val NUMBER_OF_GENERAL_NOTIFICATIONS = 1 private const val NUMBER_OF_GENERAL_NOTIFICATIONS = 2 private const val OFFSET_SEND_FAILED_NOTIFICATION = 0 private const val OFFSET_SEND_FAILED_NOTIFICATION = 0 private const val OFFSET_CERTIFICATE_ERROR_INCOMING = 1 private const val OFFSET_CERTIFICATE_ERROR_INCOMING = 1 private const val OFFSET_CERTIFICATE_ERROR_OUTGOING = 2 private const val OFFSET_CERTIFICATE_ERROR_OUTGOING = 2 Loading app/core/src/main/java/com/fsck/k9/notification/NotificationResourceProvider.kt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -8,6 +8,7 @@ interface NotificationResourceProvider { val iconNewMail: Int val iconNewMail: Int val iconSendingMail: Int val iconSendingMail: Int val iconCheckingMail: Int val iconCheckingMail: Int val iconBackgroundWorkNotification: Int val wearIconMarkAsRead: Int val wearIconMarkAsRead: Int val wearIconDelete: Int val wearIconDelete: Int val wearIconArchive: Int val wearIconArchive: Int Loading Loading
app/core/src/main/java/com/fsck/k9/notification/BackgroundWorkNotificationController.kt 0 → 100644 +9 −0 Original line number Original line Diff line number Diff line package com.fsck.k9.notification import android.app.Notification interface BackgroundWorkNotificationController { val notificationId: Int fun createNotification(text: String): Notification }
app/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -130,4 +130,11 @@ val coreNotificationModule = module { notificationConfigurationConverter = get(), notificationConfigurationConverter = get(), ) ) } } factory<BackgroundWorkNotificationController> { RealBackgroundWorkNotificationController( context = get(), resourceProvider = get(), notificationChannelManager = get(), ) } } }
app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt +17 −0 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ class NotificationChannelManager( private val notificationLightDecoder: NotificationLightDecoder, private val notificationLightDecoder: NotificationLightDecoder, ) { ) { val pushChannelId = "push" val pushChannelId = "push" val miscellaneousChannelId = "misc" enum class ChannelType { enum class ChannelType { MESSAGES, MISCELLANEOUS MESSAGES, MISCELLANEOUS Loading Loading @@ -50,6 +51,7 @@ class NotificationChannelManager( @RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O) private fun addGeneralChannels() { private fun addGeneralChannels() { notificationManager.createNotificationChannel(getChannelPush()) notificationManager.createNotificationChannel(getChannelPush()) notificationManager.createNotificationChannel(getChannelMiscellaneous()) } } @RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O) Loading Loading @@ -101,6 +103,21 @@ class NotificationChannelManager( } } } } @RequiresApi(api = Build.VERSION_CODES.O) private fun getChannelMiscellaneous(): NotificationChannel { val channelName = resourceProvider.miscellaneousChannelName val channelDescription = resourceProvider.miscellaneousChannelDescription val importance = NotificationManager.IMPORTANCE_LOW return NotificationChannel(miscellaneousChannelId, channelName, importance).apply { description = channelDescription setShowBadge(false) enableLights(false) enableVibration(false) setSound(null, null) } } @RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O) private fun getChannelMessages(account: Account): NotificationChannel { private fun getChannelMessages(account: Account): NotificationChannel { val channelName = resourceProvider.messagesChannelName val channelName = resourceProvider.messagesChannelName Loading
app/core/src/main/java/com/fsck/k9/notification/NotificationIds.kt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -4,8 +4,9 @@ import com.fsck.k9.Account internal object NotificationIds { internal object NotificationIds { const val PUSH_NOTIFICATION_ID = 1 const val PUSH_NOTIFICATION_ID = 1 const val BACKGROUND_WORK_NOTIFICATION_ID = 2 private const val NUMBER_OF_GENERAL_NOTIFICATIONS = 1 private const val NUMBER_OF_GENERAL_NOTIFICATIONS = 2 private const val OFFSET_SEND_FAILED_NOTIFICATION = 0 private const val OFFSET_SEND_FAILED_NOTIFICATION = 0 private const val OFFSET_CERTIFICATE_ERROR_INCOMING = 1 private const val OFFSET_CERTIFICATE_ERROR_INCOMING = 1 private const val OFFSET_CERTIFICATE_ERROR_OUTGOING = 2 private const val OFFSET_CERTIFICATE_ERROR_OUTGOING = 2 Loading
app/core/src/main/java/com/fsck/k9/notification/NotificationResourceProvider.kt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -8,6 +8,7 @@ interface NotificationResourceProvider { val iconNewMail: Int val iconNewMail: Int val iconSendingMail: Int val iconSendingMail: Int val iconCheckingMail: Int val iconCheckingMail: Int val iconBackgroundWorkNotification: Int val wearIconMarkAsRead: Int val wearIconMarkAsRead: Int val wearIconDelete: Int val wearIconDelete: Int val wearIconArchive: Int val wearIconArchive: Int Loading