From 6e86f3c2f2418dc2f3ad1378ee97efa4c4db774e Mon Sep 17 00:00:00 2001 From: Fabian DEVEL Date: Wed, 26 Feb 2025 10:41:38 +0100 Subject: [PATCH] chore(ExpeditedNotifWorker): Apply suggestions --- .../infomaniak/mail/utils/NotificationUtils.kt | 16 +++++++++------- .../mail/workers/DraftsActionsWorker.kt | 4 ++-- .../ProcessMessageNotificationsWorker.kt | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/infomaniak/mail/utils/NotificationUtils.kt b/app/src/main/java/com/infomaniak/mail/utils/NotificationUtils.kt index ff55438f2d..9cb2cc0f40 100644 --- a/app/src/main/java/com/infomaniak/mail/utils/NotificationUtils.kt +++ b/app/src/main/java/com/infomaniak/mail/utils/NotificationUtils.kt @@ -123,18 +123,18 @@ class NotificationUtils @Inject constructor( ) } - fun buildDraftActionsNotification(): NotificationCompat.Builder { - return appContext.buildUndeterminedProgressMessageNotification( + fun buildDraftActionsNotification(): Notification { + return appContext.undeterminedProgressMessageNotificationBuilder( channelIdRes = R.string.notification_channel_id_draft_service, titleRes = R.string.notificationSyncDraftChannelName, - ) + ).build() } - fun buildSyncMessagesServiceNotification(): NotificationCompat.Builder { - return appContext.buildUndeterminedProgressMessageNotification( + fun buildSyncMessagesServiceNotification(): Notification { + return appContext.undeterminedProgressMessageNotificationBuilder( channelIdRes = R.string.notification_channel_id_sync_messages_service, titleRes = R.string.notificationSyncMessagesChannelName, - ) + ).build() } fun buildDraftErrorNotification( @@ -207,13 +207,15 @@ class NotificationUtils @Inject constructor( ).setCategory(Notification.CATEGORY_EMAIL) } - private fun Context.buildUndeterminedProgressMessageNotification( + private fun Context.undeterminedProgressMessageNotificationBuilder( @StringRes channelIdRes: Int, @StringRes titleRes: Int, + priority: Int = NotificationCompat.PRIORITY_MIN, ) = NotificationCompat.Builder(this, getString(channelIdRes)) .setContentTitle(getString(titleRes)) .setSmallIcon(defaultSmallIcon) .setProgress(100, 0, true) + .setPriority(priority) private fun initMessageNotificationContent( mailbox: Mailbox, diff --git a/app/src/main/java/com/infomaniak/mail/workers/DraftsActionsWorker.kt b/app/src/main/java/com/infomaniak/mail/workers/DraftsActionsWorker.kt index a360c78b36..39f215e3f8 100644 --- a/app/src/main/java/com/infomaniak/mail/workers/DraftsActionsWorker.kt +++ b/app/src/main/java/com/infomaniak/mail/workers/DraftsActionsWorker.kt @@ -111,8 +111,8 @@ class DraftsActionsWorker @AssistedInject constructor( } override suspend fun getForegroundInfo(): ForegroundInfo { - val builder = notificationUtils.buildDraftActionsNotification() - return ForegroundInfo(NotificationUtils.DRAFT_ACTIONS_ID, builder.build()) + val notification = notificationUtils.buildDraftActionsNotification() + return ForegroundInfo(NotificationUtils.DRAFT_ACTIONS_ID, notification) } private suspend fun handleDraftsActions(): Result { diff --git a/app/src/standard/java/com/infomaniak/mail/firebase/ProcessMessageNotificationsWorker.kt b/app/src/standard/java/com/infomaniak/mail/firebase/ProcessMessageNotificationsWorker.kt index 45dc98d9c2..2ea47acfe4 100644 --- a/app/src/standard/java/com/infomaniak/mail/firebase/ProcessMessageNotificationsWorker.kt +++ b/app/src/standard/java/com/infomaniak/mail/firebase/ProcessMessageNotificationsWorker.kt @@ -101,8 +101,8 @@ class ProcessMessageNotificationsWorker @AssistedInject constructor( } override suspend fun getForegroundInfo(): ForegroundInfo { - val builder = notificationUtils.buildSyncMessagesServiceNotification() - return ForegroundInfo(NotificationUtils.SYNC_MESSAGES_ID, builder.build()) + val notification = notificationUtils.buildSyncMessagesServiceNotification() + return ForegroundInfo(NotificationUtils.SYNC_MESSAGES_ID, notification) } @Singleton