Rename NotificationFactory to NotificationCreator to fix the name clash.
This commit is contained in:
committed by
Benoit Marty
parent
08c62c191a
commit
3316f840f1
@@ -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
|
||||
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(),
|
||||
|
||||
@@ -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
|
||||
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(
|
||||
shouldBing = events.any { it.noisy }
|
||||
)
|
||||
return RoomNotification.Message(
|
||||
notificationFactory.createMessagesListNotification(
|
||||
notificationCreator.createMessagesListNotification(
|
||||
style,
|
||||
RoomEventGroupInfo(
|
||||
sessionId = currentUser.userId,
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
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(
|
||||
// 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(
|
||||
messageStr
|
||||
}
|
||||
}
|
||||
return notificationFactory.createSummaryListNotification(
|
||||
return notificationCreator.createSummaryListNotification(
|
||||
currentUser = currentUser,
|
||||
style = null,
|
||||
compatSummary = privacyTitle,
|
||||
|
||||
@@ -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,
|
||||
@@ -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>()
|
||||
|
||||
Reference in New Issue
Block a user