Rename NotificationFactory to NotificationCreator to fix the name clash.
This commit is contained in:
parent
08c62c191a
commit
3316f840f1
5 changed files with 15 additions and 16 deletions
|
|
@ -19,7 +19,7 @@ package io.element.android.libraries.push.impl.notifications
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
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.FallbackNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
||||||
|
|
@ -28,9 +28,8 @@ import javax.inject.Inject
|
||||||
|
|
||||||
private typealias ProcessedMessageEvents = List<ProcessedEvent<NotifiableMessageEvent>>
|
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(
|
class NotificationFactory @Inject constructor(
|
||||||
private val notificationFactory: NotificationFactory,
|
private val notificationCreator: NotificationCreator,
|
||||||
private val roomGroupMessageCreator: RoomGroupMessageCreator,
|
private val roomGroupMessageCreator: RoomGroupMessageCreator,
|
||||||
private val summaryGroupMessageCreator: SummaryGroupMessageCreator
|
private val summaryGroupMessageCreator: SummaryGroupMessageCreator
|
||||||
) {
|
) {
|
||||||
|
|
@ -65,7 +64,7 @@ class NotificationFactory @Inject constructor(
|
||||||
when (processed) {
|
when (processed) {
|
||||||
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.roomId.value)
|
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.roomId.value)
|
||||||
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
|
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
|
||||||
notificationFactory.createRoomInvitationNotification(event),
|
notificationCreator.createRoomInvitationNotification(event),
|
||||||
OneShotNotification.Append.Meta(
|
OneShotNotification.Append.Meta(
|
||||||
key = event.roomId.value,
|
key = event.roomId.value,
|
||||||
summaryLine = event.description,
|
summaryLine = event.description,
|
||||||
|
|
@ -83,7 +82,7 @@ class NotificationFactory @Inject constructor(
|
||||||
when (processed) {
|
when (processed) {
|
||||||
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.eventId.value)
|
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.eventId.value)
|
||||||
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
|
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
|
||||||
notificationFactory.createSimpleEventNotification(event),
|
notificationCreator.createSimpleEventNotification(event),
|
||||||
OneShotNotification.Append.Meta(
|
OneShotNotification.Append.Meta(
|
||||||
key = event.eventId.value,
|
key = event.eventId.value,
|
||||||
summaryLine = event.description,
|
summaryLine = event.description,
|
||||||
|
|
@ -100,7 +99,7 @@ class NotificationFactory @Inject constructor(
|
||||||
when (processed) {
|
when (processed) {
|
||||||
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.eventId.value)
|
ProcessedEvent.Type.REMOVE -> OneShotNotification.Removed(key = event.eventId.value)
|
||||||
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
|
ProcessedEvent.Type.KEEP -> OneShotNotification.Append(
|
||||||
notificationFactory.createFallbackNotification(event),
|
notificationCreator.createFallbackNotification(event),
|
||||||
OneShotNotification.Append.Meta(
|
OneShotNotification.Append.Meta(
|
||||||
key = event.eventId.value,
|
key = event.eventId.value,
|
||||||
summaryLine = event.description.orEmpty(),
|
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.matrix.api.user.MatrixUser
|
||||||
import io.element.android.libraries.push.impl.R
|
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.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.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
||||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
@ -36,7 +36,7 @@ import javax.inject.Inject
|
||||||
class RoomGroupMessageCreator @Inject constructor(
|
class RoomGroupMessageCreator @Inject constructor(
|
||||||
private val bitmapLoader: NotificationBitmapLoader,
|
private val bitmapLoader: NotificationBitmapLoader,
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val notificationFactory: NotificationFactory
|
private val notificationCreator: NotificationCreator
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun createRoomMessage(
|
suspend fun createRoomMessage(
|
||||||
|
|
@ -78,7 +78,7 @@ class RoomGroupMessageCreator @Inject constructor(
|
||||||
shouldBing = events.any { it.noisy }
|
shouldBing = events.any { it.noisy }
|
||||||
)
|
)
|
||||||
return RoomNotification.Message(
|
return RoomNotification.Message(
|
||||||
notificationFactory.createMessagesListNotification(
|
notificationCreator.createMessagesListNotification(
|
||||||
style,
|
style,
|
||||||
RoomEventGroupInfo(
|
RoomEventGroupInfo(
|
||||||
sessionId = currentUser.userId,
|
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.matrix.api.user.MatrixUser
|
||||||
import io.element.android.libraries.push.impl.R
|
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.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 io.element.android.services.toolbox.api.strings.StringProvider
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
class SummaryGroupMessageCreator @Inject constructor(
|
class SummaryGroupMessageCreator @Inject constructor(
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val notificationFactory: NotificationFactory,
|
private val notificationCreator: NotificationCreator,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun createSummaryNotification(
|
fun createSummaryNotification(
|
||||||
|
|
@ -77,7 +77,7 @@ class SummaryGroupMessageCreator @Inject constructor(
|
||||||
// Use account name now, for multi-session
|
// Use account name now, for multi-session
|
||||||
.setSummaryText(currentUser.userId.value.annotateForDebug(44))
|
.setSummaryText(currentUser.userId.value.annotateForDebug(44))
|
||||||
return if (useCompleteNotificationFormat) {
|
return if (useCompleteNotificationFormat) {
|
||||||
notificationFactory.createSummaryListNotification(
|
notificationCreator.createSummaryListNotification(
|
||||||
currentUser,
|
currentUser,
|
||||||
summaryInboxStyle,
|
summaryInboxStyle,
|
||||||
sumTitle,
|
sumTitle,
|
||||||
|
|
@ -170,7 +170,7 @@ class SummaryGroupMessageCreator @Inject constructor(
|
||||||
messageStr
|
messageStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return notificationFactory.createSummaryListNotification(
|
return notificationCreator.createSummaryListNotification(
|
||||||
currentUser = currentUser,
|
currentUser = currentUser,
|
||||||
style = null,
|
style = null,
|
||||||
compatSummary = privacyTitle,
|
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 io.element.android.services.toolbox.api.strings.StringProvider
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class NotificationFactory @Inject constructor(
|
class NotificationCreator @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val notificationChannels: NotificationChannels,
|
private val notificationChannels: NotificationChannels,
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
|
|
@ -17,14 +17,14 @@
|
||||||
package io.element.android.libraries.push.impl.notifications.fake
|
package io.element.android.libraries.push.impl.notifications.fake
|
||||||
|
|
||||||
import android.app.Notification
|
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.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
|
||||||
class FakeAndroidNotificationFactory {
|
class FakeAndroidNotificationFactory {
|
||||||
val instance = mockk<NotificationFactory>()
|
val instance = mockk<NotificationCreator>()
|
||||||
|
|
||||||
fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification {
|
fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification {
|
||||||
val mockNotification = mockk<Notification>()
|
val mockNotification = mockk<Notification>()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue