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

Commit bc7758b9 authored by cketti's avatar cketti
Browse files

Remove `notificationId` parameters from methods in `NotificationActionCreator`

parent 147945f7
Loading
Loading
Loading
Loading
+14 −33
Original line number Diff line number Diff line
@@ -5,54 +5,35 @@ import com.fsck.k9.Account
import com.fsck.k9.controller.MessageReference

interface NotificationActionCreator {
    fun createViewMessagePendingIntent(messageReference: MessageReference, notificationId: Int): PendingIntent
    fun createViewMessagePendingIntent(messageReference: MessageReference): PendingIntent

    fun createViewFolderPendingIntent(account: Account, folderId: Long, notificationId: Int): PendingIntent
    fun createViewFolderPendingIntent(account: Account, folderId: Long): PendingIntent

    fun createViewMessagesPendingIntent(
        account: Account,
        messageReferences: List<MessageReference>,
        notificationId: Int
    ): PendingIntent
    fun createViewMessagesPendingIntent(account: Account, messageReferences: List<MessageReference>): PendingIntent

    fun createViewFolderListPendingIntent(account: Account, notificationId: Int): PendingIntent
    fun createViewFolderListPendingIntent(account: Account): PendingIntent

    fun createDismissAllMessagesPendingIntent(account: Account, notificationId: Int): PendingIntent
    fun createDismissAllMessagesPendingIntent(account: Account): PendingIntent

    fun createDismissMessagePendingIntent(
        messageReference: MessageReference,
        notificationId: Int
    ): PendingIntent
    fun createDismissMessagePendingIntent(messageReference: MessageReference): PendingIntent

    fun createReplyPendingIntent(messageReference: MessageReference, notificationId: Int): PendingIntent
    fun createReplyPendingIntent(messageReference: MessageReference): PendingIntent

    fun createMarkMessageAsReadPendingIntent(messageReference: MessageReference, notificationId: Int): PendingIntent
    fun createMarkMessageAsReadPendingIntent(messageReference: MessageReference): PendingIntent

    fun createMarkAllAsReadPendingIntent(
        account: Account,
        messageReferences: List<MessageReference>,
        notificationId: Int
    ): PendingIntent
    fun createMarkAllAsReadPendingIntent(account: Account, messageReferences: List<MessageReference>): PendingIntent

    fun getEditIncomingServerSettingsIntent(account: Account): PendingIntent

    fun getEditOutgoingServerSettingsIntent(account: Account): PendingIntent

    fun createDeleteMessagePendingIntent(messageReference: MessageReference, notificationId: Int): PendingIntent
    fun createDeleteMessagePendingIntent(messageReference: MessageReference): PendingIntent

    fun createDeleteAllPendingIntent(
        account: Account,
        messageReferences: List<MessageReference>,
        notificationId: Int
    ): PendingIntent
    fun createDeleteAllPendingIntent(account: Account, messageReferences: List<MessageReference>): PendingIntent

    fun createArchiveMessagePendingIntent(messageReference: MessageReference, notificationId: Int): PendingIntent
    fun createArchiveMessagePendingIntent(messageReference: MessageReference): PendingIntent

    fun createArchiveAllPendingIntent(
        account: Account,
        messageReferences: List<MessageReference>,
        notificationId: Int
    ): PendingIntent
    fun createArchiveAllPendingIntent(account: Account, messageReferences: List<MessageReference>): PendingIntent

    fun createMarkMessageAsSpamPendingIntent(messageReference: MessageReference, notificationId: Int): PendingIntent
    fun createMarkMessageAsSpamPendingIntent(messageReference: MessageReference): PendingIntent
}
+2 −6
Original line number Diff line number Diff line
@@ -19,13 +19,9 @@ internal class SendFailedNotificationController(

        val pendingIntent = account.outboxFolderId.let { outboxFolderId ->
            if (outboxFolderId != null) {
                actionBuilder.createViewFolderPendingIntent(
                    account, outboxFolderId, notificationId
                )
                actionBuilder.createViewFolderPendingIntent(account, outboxFolderId)
            } else {
                actionBuilder.createViewFolderListPendingIntent(
                    account, notificationId
                )
                actionBuilder.createViewFolderListPendingIntent(account)
            }
        }

+10 −27
Original line number Diff line number Diff line
package com.fsck.k9.notification

import android.app.PendingIntent
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationCompat.WearableExtender
import com.fsck.k9.notification.NotificationChannelManager.ChannelType
@@ -35,8 +34,8 @@ internal class SingleMessageNotificationCreator(
            .setContentText(content.subject)
            .setSubText(baseNotificationData.accountName)
            .setBigText(content.preview)
            .setContentIntent(createViewIntent(content, notificationId))
            .setDeleteIntent(createDismissIntent(content, notificationId))
            .setContentIntent(actionCreator.createViewMessagePendingIntent(content.messageReference))
            .setDeleteIntent(actionCreator.createDismissMessagePendingIntent(content.messageReference))
            .setDeviceActions(singleNotificationData)
            .setWearActions(singleNotificationData)
            .setAppearance(singleNotificationData.isSilent, baseNotificationData.appearance)
@@ -57,14 +56,6 @@ internal class SingleMessageNotificationCreator(
        setStyle(NotificationCompat.BigTextStyle().bigText(text))
    }

    private fun createViewIntent(content: NotificationContent, notificationId: Int): PendingIntent {
        return actionCreator.createViewMessagePendingIntent(content.messageReference, notificationId)
    }

    private fun createDismissIntent(content: NotificationContent, notificationId: Int): PendingIntent {
        return actionCreator.createDismissMessagePendingIntent(content.messageReference, notificationId)
    }

    private fun NotificationBuilder.setDeviceActions(notificationData: SingleNotificationData) = apply {
        val actions = notificationData.actions
        for (action in actions) {
@@ -81,8 +72,7 @@ internal class SingleMessageNotificationCreator(
        val title = resourceProvider.actionReply()
        val content = notificationData.content
        val messageReference = content.messageReference
        val replyToMessagePendingIntent =
            actionCreator.createReplyPendingIntent(messageReference, notificationData.notificationId)
        val replyToMessagePendingIntent = actionCreator.createReplyPendingIntent(messageReference)

        addAction(icon, title, replyToMessagePendingIntent)
    }
@@ -91,9 +81,8 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.iconMarkAsRead
        val title = resourceProvider.actionMarkAsRead()
        val content = notificationData.content
        val notificationId = notificationData.notificationId
        val messageReference = content.messageReference
        val action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId)
        val action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference)

        addAction(icon, title, action)
    }
@@ -102,9 +91,8 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.iconDelete
        val title = resourceProvider.actionDelete()
        val content = notificationData.content
        val notificationId = notificationData.notificationId
        val messageReference = content.messageReference
        val action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId)
        val action = actionCreator.createDeleteMessagePendingIntent(messageReference)

        addAction(icon, title, action)
    }
@@ -129,8 +117,7 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.wearIconReplyAll
        val title = resourceProvider.actionReply()
        val messageReference = notificationData.content.messageReference
        val notificationId = notificationData.notificationId
        val action = actionCreator.createReplyPendingIntent(messageReference, notificationId)
        val action = actionCreator.createReplyPendingIntent(messageReference)
        val replyAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(replyAction)
@@ -140,8 +127,7 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.wearIconMarkAsRead
        val title = resourceProvider.actionMarkAsRead()
        val messageReference = notificationData.content.messageReference
        val notificationId = notificationData.notificationId
        val action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId)
        val action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference)
        val markAsReadAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(markAsReadAction)
@@ -151,8 +137,7 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.wearIconDelete
        val title = resourceProvider.actionDelete()
        val messageReference = notificationData.content.messageReference
        val notificationId = notificationData.notificationId
        val action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId)
        val action = actionCreator.createDeleteMessagePendingIntent(messageReference)
        val deleteAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(deleteAction)
@@ -162,8 +147,7 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.wearIconArchive
        val title = resourceProvider.actionArchive()
        val messageReference = notificationData.content.messageReference
        val notificationId = notificationData.notificationId
        val action = actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId)
        val action = actionCreator.createArchiveMessagePendingIntent(messageReference)
        val archiveAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(archiveAction)
@@ -173,8 +157,7 @@ internal class SingleMessageNotificationCreator(
        val icon = resourceProvider.wearIconMarkAsSpam
        val title = resourceProvider.actionMarkAsSpam()
        val messageReference = notificationData.content.messageReference
        val notificationId = notificationData.notificationId
        val action = actionCreator.createMarkMessageAsSpamPendingIntent(messageReference, notificationId)
        val action = actionCreator.createMarkMessageAsSpamPendingIntent(messageReference)
        val spamAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(spamAction)
+7 −22
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationCompat.WearableExtender
import com.fsck.k9.Account
import com.fsck.k9.notification.NotificationChannelManager.ChannelType
import com.fsck.k9.notification.NotificationIds.getNewMailSummaryNotificationId
import timber.log.Timber
import androidx.core.app.NotificationCompat.Builder as NotificationBuilder

@@ -65,7 +64,7 @@ internal class SummaryNotificationCreator(
            .setSubText(accountName)
            .setInboxStyle(title, summary, notificationData.content)
            .setContentIntent(createViewIntent(account, notificationData))
            .setDeleteIntent(createDismissIntent(account, notificationData.notificationId))
            .setDeleteIntent(actionCreator.createDismissAllMessagesPendingIntent(account))
            .setDeviceActions(account, notificationData)
            .setWearActions(account, notificationData)
            .setAppearance(notificationData.isSilent, baseNotificationData.appearance)
@@ -101,15 +100,7 @@ internal class SummaryNotificationCreator(
    }

    private fun createViewIntent(account: Account, notificationData: SummaryInboxNotificationData): PendingIntent {
        return actionCreator.createViewMessagesPendingIntent(
            account = account,
            messageReferences = notificationData.messageReferences,
            notificationId = notificationData.notificationId
        )
    }

    private fun createDismissIntent(account: Account, notificationId: Int): PendingIntent {
        return actionCreator.createDismissAllMessagesPendingIntent(account, notificationId)
        return actionCreator.createViewMessagesPendingIntent(account, notificationData.messageReferences)
    }

    private fun NotificationBuilder.setDeviceActions(
@@ -131,9 +122,7 @@ internal class SummaryNotificationCreator(
        val icon = resourceProvider.iconMarkAsRead
        val title = resourceProvider.actionMarkAsRead()
        val messageReferences = notificationData.messageReferences
        val notificationId = notificationData.notificationId
        val markAllAsReadPendingIntent =
            actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId)
        val markAllAsReadPendingIntent = actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences)

        addAction(icon, title, markAllAsReadPendingIntent)
    }
@@ -144,9 +133,8 @@ internal class SummaryNotificationCreator(
    ) {
        val icon = resourceProvider.iconDelete
        val title = resourceProvider.actionDelete()
        val notificationId = getNewMailSummaryNotificationId(account)
        val messageReferences = notificationData.messageReferences
        val action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId)
        val action = actionCreator.createDeleteAllPendingIntent(account, messageReferences)

        addAction(icon, title, action)
    }
@@ -175,8 +163,7 @@ internal class SummaryNotificationCreator(
        val icon = resourceProvider.wearIconMarkAsRead
        val title = resourceProvider.actionMarkAllAsRead()
        val messageReferences = notificationData.messageReferences
        val notificationId = getNewMailSummaryNotificationId(account)
        val action = actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId)
        val action = actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences)
        val markAsReadAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(markAsReadAction)
@@ -186,8 +173,7 @@ internal class SummaryNotificationCreator(
        val icon = resourceProvider.wearIconDelete
        val title = resourceProvider.actionDeleteAll()
        val messageReferences = notificationData.messageReferences
        val notificationId = getNewMailSummaryNotificationId(account)
        val action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId)
        val action = actionCreator.createDeleteAllPendingIntent(account, messageReferences)
        val deleteAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(deleteAction)
@@ -197,8 +183,7 @@ internal class SummaryNotificationCreator(
        val icon = resourceProvider.wearIconArchive
        val title = resourceProvider.actionArchiveAll()
        val messageReferences = notificationData.messageReferences
        val notificationId = getNewMailSummaryNotificationId(account)
        val action = actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId)
        val action = actionCreator.createArchiveAllPendingIntent(account, messageReferences)
        val archiveAction = NotificationCompat.Action.Builder(icon, title, action).build()

        addAction(archiveAction)
+2 −6
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@ internal class SyncNotificationController(

        val notificationId = NotificationIds.getFetchingMailNotificationId(account)
        val outboxFolderId = account.outboxFolderId ?: error("Outbox folder not configured")
        val showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent(
            account, outboxFolderId, notificationId
        )
        val showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent(account, outboxFolderId)

        val notificationBuilder = notificationHelper
            .createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS)
@@ -53,9 +51,7 @@ internal class SyncNotificationController(
        val text = accountName + resourceProvider.checkingMailSeparator() + folderName

        val notificationId = NotificationIds.getFetchingMailNotificationId(account)
        val showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent(
            account, folderId, notificationId
        )
        val showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent(account, folderId)

        val notificationBuilder = notificationHelper
            .createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS)
Loading