Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09240fec authored by cketti's avatar cketti
Browse files

Implement `AccountRemoverWorker.getForegroundInfo()`

This is required to run expedited jobs on older Android versions.
parent d8e09b57
Loading
Loading
Loading
Loading
+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
}
+7 −0
Original line number Original line Diff line number Diff line
@@ -130,4 +130,11 @@ val coreNotificationModule = module {
            notificationConfigurationConverter = get(),
            notificationConfigurationConverter = get(),
        )
        )
    }
    }
    factory<BackgroundWorkNotificationController> {
        RealBackgroundWorkNotificationController(
            context = get(),
            resourceProvider = get(),
            notificationChannelManager = get(),
        )
    }
}
}
+17 −0
Original line number Original line Diff line number Diff line
@@ -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
@@ -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)
@@ -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
+2 −1
Original line number Original line Diff line number Diff line
@@ -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
+1 −0
Original line number Original line Diff line number Diff line
@@ -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