From a94a1a0523340dc690ed8413509d94a95b7be757 Mon Sep 17 00:00:00 2001
From: Adam Brown <adampsbrown@gmail.com>
Date: Thu, 7 Oct 2021 16:32:00 +0100
Subject: [PATCH] formatting

---
 .../notifications/NotificationFactory.kt      | 13 +++++-----
 .../notifications/NotificationRenderer.kt     | 26 ++++++++++++-------
 .../SummaryGroupMessageCreator.kt             |  6 ++---
 .../notifications/NotificationRendererTest.kt |  1 -
 4 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationFactory.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationFactory.kt
index 0c3aab7bd3..d5de0221f6 100644
--- a/vector/src/main/java/im/vector/app/features/notifications/NotificationFactory.kt
+++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationFactory.kt
@@ -84,12 +84,13 @@ class NotificationFactory @Inject constructor(
         val simpleMeta = simpleNotifications.mapToMeta()
         return when {
             roomMeta.isEmpty() && invitationMeta.isEmpty() && simpleMeta.isEmpty() -> SummaryNotification.Removed
-            else                                                                   -> SummaryNotification.Update(summaryGroupMessageCreator.createSummaryNotification(
-                    roomNotifications = roomMeta,
-                    invitationNotifications = invitationMeta,
-                    simpleNotifications = simpleMeta,
-                    useCompleteNotificationFormat = useCompleteNotificationFormat
-            ))
+            else                                                                   -> SummaryNotification.Update(
+                    summaryGroupMessageCreator.createSummaryNotification(
+                            roomNotifications = roomMeta,
+                            invitationNotifications = invitationMeta,
+                            simpleNotifications = simpleMeta,
+                            useCompleteNotificationFormat = useCompleteNotificationFormat
+                    ))
         }
     }
 }
diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationRenderer.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationRenderer.kt
index 749e3c61b6..844ea46f93 100644
--- a/vector/src/main/java/im/vector/app/features/notifications/NotificationRenderer.kt
+++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationRenderer.kt
@@ -17,6 +17,10 @@ package im.vector.app.features.notifications
 
 import android.content.Context
 import androidx.annotation.WorkerThread
+import im.vector.app.features.notifications.NotificationDrawerManager.Companion.ROOM_EVENT_NOTIFICATION_ID
+import im.vector.app.features.notifications.NotificationDrawerManager.Companion.ROOM_INVITATION_NOTIFICATION_ID
+import im.vector.app.features.notifications.NotificationDrawerManager.Companion.ROOM_MESSAGES_NOTIFICATION_ID
+import im.vector.app.features.notifications.NotificationDrawerManager.Companion.SUMMARY_NOTIFICATION_ID
 import androidx.core.content.pm.ShortcutManagerCompat
 import timber.log.Timber
 import javax.inject.Inject
@@ -47,7 +51,11 @@ class NotificationRenderer @Inject constructor(private val notifiableEventProces
         }
     }
 
-    private fun processEvents(notificationEvents: ProcessedNotificationEvents, myUserId: String, myUserDisplayName: String, myUserAvatarUrl: String?, useCompleteNotificationFormat: Boolean) {
+    private fun processEvents(notificationEvents: ProcessedNotificationEvents,
+                              myUserId: String,
+                              myUserDisplayName: String,
+                              myUserAvatarUrl: String?,
+                              useCompleteNotificationFormat: Boolean) {
         val (roomEvents, simpleEvents, invitationEvents) = notificationEvents
         with(notificationFactory) {
             val roomNotifications = roomEvents.toNotifications(myUserDisplayName, myUserAvatarUrl)
@@ -62,33 +70,33 @@ class NotificationRenderer @Inject constructor(private val notifiableEventProces
 
             roomNotifications.forEach { wrapper ->
                 when (wrapper) {
-                    is RoomNotification.Removed -> notificationDisplayer.cancelNotificationMessage(wrapper.roomId, NotificationDrawerManager.ROOM_MESSAGES_NOTIFICATION_ID)
+                    is RoomNotification.Removed -> notificationDisplayer.cancelNotificationMessage(wrapper.roomId, ROOM_MESSAGES_NOTIFICATION_ID)
                     is RoomNotification.Message -> if (useCompleteNotificationFormat) {
                         Timber.d("Updating room messages notification ${wrapper.meta.roomId}")
                         wrapper.shortcutInfo?.let {
                             ShortcutManagerCompat.pushDynamicShortcut(appContext, it)
                         }
-                        notificationDisplayer.showNotificationMessage(wrapper.meta.roomId, NotificationDrawerManager.ROOM_MESSAGES_NOTIFICATION_ID, wrapper.notification)
+                        notificationDisplayer.showNotificationMessage(wrapper.meta.roomId, ROOM_MESSAGES_NOTIFICATION_ID, wrapper.notification)
                     }
                 }
             }
 
             invitationNotifications.forEach { wrapper ->
                 when (wrapper) {
-                    is OneShotNotification.Removed -> notificationDisplayer.cancelNotificationMessage(wrapper.key, NotificationDrawerManager.ROOM_INVITATION_NOTIFICATION_ID)
+                    is OneShotNotification.Removed -> notificationDisplayer.cancelNotificationMessage(wrapper.key, ROOM_INVITATION_NOTIFICATION_ID)
                     is OneShotNotification.Append  -> if (useCompleteNotificationFormat) {
                         Timber.d("Updating invitation notification ${wrapper.meta.key}")
-                        notificationDisplayer.showNotificationMessage(wrapper.meta.key, NotificationDrawerManager.ROOM_INVITATION_NOTIFICATION_ID, wrapper.notification)
+                        notificationDisplayer.showNotificationMessage(wrapper.meta.key, ROOM_INVITATION_NOTIFICATION_ID, wrapper.notification)
                     }
                 }
             }
 
             simpleNotifications.forEach { wrapper ->
                 when (wrapper) {
-                    is OneShotNotification.Removed -> notificationDisplayer.cancelNotificationMessage(wrapper.key, NotificationDrawerManager.ROOM_EVENT_NOTIFICATION_ID)
+                    is OneShotNotification.Removed -> notificationDisplayer.cancelNotificationMessage(wrapper.key, ROOM_EVENT_NOTIFICATION_ID)
                     is OneShotNotification.Append  -> if (useCompleteNotificationFormat) {
                         Timber.d("Updating simple notification ${wrapper.meta.key}")
-                        notificationDisplayer.showNotificationMessage(wrapper.meta.key, NotificationDrawerManager.ROOM_EVENT_NOTIFICATION_ID, wrapper.notification)
+                        notificationDisplayer.showNotificationMessage(wrapper.meta.key, ROOM_EVENT_NOTIFICATION_ID, wrapper.notification)
                     }
                 }
             }
@@ -96,11 +104,11 @@ class NotificationRenderer @Inject constructor(private val notifiableEventProces
             when (summaryNotification) {
                 SummaryNotification.Removed   -> {
                     Timber.d("Removing summary notification")
-                    notificationDisplayer.cancelNotificationMessage(null, NotificationDrawerManager.SUMMARY_NOTIFICATION_ID)
+                    notificationDisplayer.cancelNotificationMessage(null, SUMMARY_NOTIFICATION_ID)
                 }
                 is SummaryNotification.Update -> {
                     Timber.d("Updating summary notification")
-                    notificationDisplayer.showNotificationMessage(null, NotificationDrawerManager.SUMMARY_NOTIFICATION_ID, summaryNotification.notification)
+                    notificationDisplayer.showNotificationMessage(null, SUMMARY_NOTIFICATION_ID, summaryNotification.notification)
                 }
             }
         }
diff --git a/vector/src/main/java/im/vector/app/features/notifications/SummaryGroupMessageCreator.kt b/vector/src/main/java/im/vector/app/features/notifications/SummaryGroupMessageCreator.kt
index 821f24b436..ddef31a0f5 100644
--- a/vector/src/main/java/im/vector/app/features/notifications/SummaryGroupMessageCreator.kt
+++ b/vector/src/main/java/im/vector/app/features/notifications/SummaryGroupMessageCreator.kt
@@ -51,9 +51,9 @@ class SummaryGroupMessageCreator @Inject constructor(
             simpleNotifications.forEach { style.addLine(it.summaryLine) }
         }
 
-        val summaryIsNoisy = roomNotifications.any { it.shouldBing }
-                || invitationNotifications.any { it.isNoisy }
-                || simpleNotifications.any { it.isNoisy }
+        val summaryIsNoisy = roomNotifications.any { it.shouldBing } ||
+                invitationNotifications.any { it.isNoisy } ||
+                simpleNotifications.any { it.isNoisy }
 
         val messageCount = roomNotifications.fold(initial = 0) { acc, current -> acc + current.messageCount }
 
diff --git a/vector/src/test/java/im/vector/app/features/notifications/NotificationRendererTest.kt b/vector/src/test/java/im/vector/app/features/notifications/NotificationRendererTest.kt
index e3c97ad3cf..b0f1772fc7 100644
--- a/vector/src/test/java/im/vector/app/features/notifications/NotificationRendererTest.kt
+++ b/vector/src/test/java/im/vector/app/features/notifications/NotificationRendererTest.kt
@@ -20,7 +20,6 @@ import android.app.Notification
 import im.vector.app.test.fakes.FakeNotifiableEventProcessor
 import im.vector.app.test.fakes.FakeNotificationDisplayer
 import im.vector.app.test.fakes.FakeNotificationFactory
-import im.vector.app.test.fakes.FakeVectorPreferences
 import io.mockk.mockk
 import org.junit.Test