Browse Source

Rename NotificationFactory to NotificationCreator to fix the name clash.

pull/1899/head
Benoit Marty 10 months ago committed by Benoit Marty
parent
commit
1fdf8dad1f
  1. 11
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationFactory.kt
  2. 6
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/RoomGroupMessageCreator.kt
  3. 8
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/SummaryGroupMessageCreator.kt
  4. 2
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/factories/NotificationCreator.kt
  5. 4
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeAndroidNotificationFactory.kt

11
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationFactory.kt

@ -19,7 +19,7 @@ package io.element.android.libraries.push.impl.notifications @@ -19,7 +19,7 @@ package io.element.android.libraries.push.impl.notifications
import android.app.Notification
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.user.MatrixUser
import io.element.android.libraries.push.impl.notifications.factories.NotificationFactory
import io.element.android.libraries.push.impl.notifications.factories.NotificationCreator
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
@ -28,9 +28,8 @@ import javax.inject.Inject @@ -28,9 +28,8 @@ import javax.inject.Inject
private typealias ProcessedMessageEvents = List<ProcessedEvent<NotifiableMessageEvent>>
// TODO Find a better name, it clashes with io.element.android.libraries.push.impl.notifications.factories.NotificationFactory
class NotificationFactory @Inject constructor(
private val notificationFactory: NotificationFactory,
private val notificationCreator: NotificationCreator,
private val roomGroupMessageCreator: RoomGroupMessageCreator,
private val summaryGroupMessageCreator: SummaryGroupMessageCreator
) {
@ -65,7 +64,7 @@ class NotificationFactory @Inject constructor( @@ -65,7 +64,7 @@ class NotificationFactory @Inject constructor(
when (processed) {
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.roomId.value)
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
notificationFactory.createRoomInvitationNotification(event),
notificationCreator.createRoomInvitationNotification(event),
OneShotNotification.Append.Meta(
key = event.roomId.value,
summaryLine = event.description,
@ -83,7 +82,7 @@ class NotificationFactory @Inject constructor( @@ -83,7 +82,7 @@ class NotificationFactory @Inject constructor(
when (processed) {
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.eventId.value)
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
notificationFactory.createSimpleEventNotification(event),
notificationCreator.createSimpleEventNotification(event),
OneShotNotification.Append.Meta(
key = event.eventId.value,
summaryLine = event.description,
@ -100,7 +99,7 @@ class NotificationFactory @Inject constructor( @@ -100,7 +99,7 @@ class NotificationFactory @Inject constructor(
when (processed) {
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.eventId.value)
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
notificationFactory.createFallbackNotification(event),
notificationCreator.createFallbackNotification(event),
OneShotNotification.Append.Meta(
key = event.eventId.value,
summaryLine = event.description.orEmpty(),

6
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/RoomGroupMessageCreator.kt

@ -27,7 +27,7 @@ import io.element.android.libraries.matrix.api.core.RoomId @@ -27,7 +27,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.user.MatrixUser
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.debug.annotateForDebug
import io.element.android.libraries.push.impl.notifications.factories.NotificationFactory
import io.element.android.libraries.push.impl.notifications.factories.NotificationCreator
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
import io.element.android.services.toolbox.api.strings.StringProvider
import timber.log.Timber
@ -36,7 +36,7 @@ import javax.inject.Inject @@ -36,7 +36,7 @@ import javax.inject.Inject
class RoomGroupMessageCreator @Inject constructor(
private val bitmapLoader: NotificationBitmapLoader,
private val stringProvider: StringProvider,
private val notificationFactory: NotificationFactory
private val notificationCreator: NotificationCreator
) {
suspend fun createRoomMessage(
@ -78,7 +78,7 @@ class RoomGroupMessageCreator @Inject constructor( @@ -78,7 +78,7 @@ class RoomGroupMessageCreator @Inject constructor(
shouldBing = events.any { it.noisy }
)
return RoomNotification.Message(
notificationFactory.createMessagesListNotification(
notificationCreator.createMessagesListNotification(
style,
RoomEventGroupInfo(
sessionId = currentUser.userId,

8
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/SummaryGroupMessageCreator.kt

@ -21,7 +21,7 @@ import androidx.core.app.NotificationCompat @@ -21,7 +21,7 @@ import androidx.core.app.NotificationCompat
import io.element.android.libraries.matrix.api.user.MatrixUser
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.debug.annotateForDebug
import io.element.android.libraries.push.impl.notifications.factories.NotificationFactory
import io.element.android.libraries.push.impl.notifications.factories.NotificationCreator
import io.element.android.services.toolbox.api.strings.StringProvider
import javax.inject.Inject
@ -41,7 +41,7 @@ import javax.inject.Inject @@ -41,7 +41,7 @@ import javax.inject.Inject
*/
class SummaryGroupMessageCreator @Inject constructor(
private val stringProvider: StringProvider,
private val notificationFactory: NotificationFactory,
private val notificationCreator: NotificationCreator,
) {
fun createSummaryNotification(
@ -77,7 +77,7 @@ class SummaryGroupMessageCreator @Inject constructor( @@ -77,7 +77,7 @@ class SummaryGroupMessageCreator @Inject constructor(
// Use account name now, for multi-session
.setSummaryText(currentUser.userId.value.annotateForDebug(44))
return if (useCompleteNotificationFormat) {
notificationFactory.createSummaryListNotification(
notificationCreator.createSummaryListNotification(
currentUser,
summaryInboxStyle,
sumTitle,
@ -170,7 +170,7 @@ class SummaryGroupMessageCreator @Inject constructor( @@ -170,7 +170,7 @@ class SummaryGroupMessageCreator @Inject constructor(
messageStr
}
}
return notificationFactory.createSummaryListNotification(
return notificationCreator.createSummaryListNotification(
currentUser = currentUser,
style = null,
compatSummary = privacyTitle,

2
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/factories/NotificationFactory.kt → libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/factories/NotificationCreator.kt

@ -41,7 +41,7 @@ import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiab @@ -41,7 +41,7 @@ import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiab
import io.element.android.services.toolbox.api.strings.StringProvider
import javax.inject.Inject
class NotificationFactory @Inject constructor(
class NotificationCreator @Inject constructor(
@ApplicationContext private val context: Context,
private val notificationChannels: NotificationChannels,
private val stringProvider: StringProvider,

4
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeAndroidNotificationFactory.kt

@ -17,14 +17,14 @@ @@ -17,14 +17,14 @@
package io.element.android.libraries.push.impl.notifications.fake
import android.app.Notification
import io.element.android.libraries.push.impl.notifications.factories.NotificationFactory
import io.element.android.libraries.push.impl.notifications.factories.NotificationCreator
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
import io.mockk.every
import io.mockk.mockk
class FakeAndroidNotificationFactory {
val instance = mockk<NotificationFactory>()
val instance = mockk<NotificationCreator>()
fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification {
val mockNotification = mockk<Notification>()

Loading…
Cancel
Save