Add Timber tags.
This commit is contained in:
parent
f0bb391519
commit
f2900de7af
3 changed files with 23 additions and 15 deletions
|
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
package io.element.android.libraries.push.impl.notifications
|
package io.element.android.libraries.push.impl.notifications
|
||||||
|
|
||||||
|
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||||
|
import io.element.android.libraries.push.impl.log.notificationLoggerTag
|
||||||
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.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
|
|
@ -29,6 +31,8 @@ import javax.inject.Inject
|
||||||
|
|
||||||
private typealias ProcessedEvents = List<ProcessedEvent<NotifiableEvent>>
|
private typealias ProcessedEvents = List<ProcessedEvent<NotifiableEvent>>
|
||||||
|
|
||||||
|
private val loggerTag = LoggerTag("NotifiableEventProcessor", notificationLoggerTag)
|
||||||
|
|
||||||
class NotifiableEventProcessor @Inject constructor(
|
class NotifiableEventProcessor @Inject constructor(
|
||||||
private val outdatedDetector: OutdatedEventDetector,
|
private val outdatedDetector: OutdatedEventDetector,
|
||||||
private val appNavigationStateService: AppNavigationStateService,
|
private val appNavigationStateService: AppNavigationStateService,
|
||||||
|
|
@ -45,10 +49,10 @@ class NotifiableEventProcessor @Inject constructor(
|
||||||
is NotifiableMessageEvent -> when {
|
is NotifiableMessageEvent -> when {
|
||||||
it.shouldIgnoreEventInRoom(appState) -> {
|
it.shouldIgnoreEventInRoom(appState) -> {
|
||||||
ProcessedEvent.Type.REMOVE
|
ProcessedEvent.Type.REMOVE
|
||||||
.also { Timber.d("notification message removed due to currently viewing the same room or thread") }
|
.also { Timber.tag(loggerTag.value).d("notification message removed due to currently viewing the same room or thread") }
|
||||||
}
|
}
|
||||||
outdatedDetector.isMessageOutdated(it) -> ProcessedEvent.Type.REMOVE
|
outdatedDetector.isMessageOutdated(it) -> ProcessedEvent.Type.REMOVE
|
||||||
.also { Timber.d("notification message removed due to being read") }
|
.also { Timber.tag(loggerTag.value).d("notification message removed due to being read") }
|
||||||
else -> ProcessedEvent.Type.KEEP
|
else -> ProcessedEvent.Type.KEEP
|
||||||
}
|
}
|
||||||
is SimpleNotifiableEvent -> when (it.type) {
|
is SimpleNotifiableEvent -> when (it.type) {
|
||||||
|
|
@ -58,7 +62,7 @@ class NotifiableEventProcessor @Inject constructor(
|
||||||
is FallbackNotifiableEvent -> when {
|
is FallbackNotifiableEvent -> when {
|
||||||
it.shouldIgnoreEventInRoom(appState) -> {
|
it.shouldIgnoreEventInRoom(appState) -> {
|
||||||
ProcessedEvent.Type.REMOVE
|
ProcessedEvent.Type.REMOVE
|
||||||
.also { Timber.d("notification fallback removed due to currently viewing the same room or thread") }
|
.also { Timber.tag(loggerTag.value).d("notification fallback removed due to currently viewing the same room or thread") }
|
||||||
}
|
}
|
||||||
else -> ProcessedEvent.Type.KEEP
|
else -> ProcessedEvent.Type.KEEP
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import io.element.android.libraries.matrix.api.timeline.item.event.TextMessageTy
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.UnknownMessageType
|
import io.element.android.libraries.matrix.api.timeline.item.event.UnknownMessageType
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.VideoMessageType
|
import io.element.android.libraries.matrix.api.timeline.item.event.VideoMessageType
|
||||||
import io.element.android.libraries.push.impl.R
|
import io.element.android.libraries.push.impl.R
|
||||||
import io.element.android.libraries.push.impl.log.pushLoggerTag
|
import io.element.android.libraries.push.impl.log.notificationLoggerTag
|
||||||
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.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
|
|
@ -47,7 +47,7 @@ import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
private val loggerTag = LoggerTag("NotifiableEventResolver", pushLoggerTag)
|
private val loggerTag = LoggerTag("NotifiableEventResolver", notificationLoggerTag)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The notifiable event resolver is able to create a NotifiableEvent (view model for notifications) from an sdk Event.
|
* The notifiable event resolver is able to create a NotifiableEvent (view model for notifications) from an sdk Event.
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@
|
||||||
|
|
||||||
package io.element.android.libraries.push.impl.notifications
|
package io.element.android.libraries.push.impl.notifications
|
||||||
|
|
||||||
|
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||||
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.log.notificationLoggerTag
|
||||||
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.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
|
|
@ -26,6 +28,8 @@ import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiab
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
private val loggerTag = LoggerTag("NotificationRenderer", notificationLoggerTag)
|
||||||
|
|
||||||
class NotificationRenderer @Inject constructor(
|
class NotificationRenderer @Inject constructor(
|
||||||
private val notificationIdProvider: NotificationIdProvider,
|
private val notificationIdProvider: NotificationIdProvider,
|
||||||
private val notificationDisplayer: NotificationDisplayer,
|
private val notificationDisplayer: NotificationDisplayer,
|
||||||
|
|
@ -54,7 +58,7 @@ class NotificationRenderer @Inject constructor(
|
||||||
|
|
||||||
// Remove summary first to avoid briefly displaying it after dismissing the last notification
|
// Remove summary first to avoid briefly displaying it after dismissing the last notification
|
||||||
if (summaryNotification == SummaryNotification.Removed) {
|
if (summaryNotification == SummaryNotification.Removed) {
|
||||||
Timber.d("Removing summary notification")
|
Timber.tag(loggerTag.value).d("Removing summary notification")
|
||||||
notificationDisplayer.cancelNotificationMessage(
|
notificationDisplayer.cancelNotificationMessage(
|
||||||
tag = null,
|
tag = null,
|
||||||
id = notificationIdProvider.getSummaryNotificationId(currentUser.userId)
|
id = notificationIdProvider.getSummaryNotificationId(currentUser.userId)
|
||||||
|
|
@ -64,14 +68,14 @@ class NotificationRenderer @Inject constructor(
|
||||||
roomNotifications.forEach { wrapper ->
|
roomNotifications.forEach { wrapper ->
|
||||||
when (wrapper) {
|
when (wrapper) {
|
||||||
is RoomNotification.Removed -> {
|
is RoomNotification.Removed -> {
|
||||||
Timber.d("Removing room messages notification ${wrapper.roomId}")
|
Timber.tag(loggerTag.value).d("Removing room messages notification ${wrapper.roomId}")
|
||||||
notificationDisplayer.cancelNotificationMessage(
|
notificationDisplayer.cancelNotificationMessage(
|
||||||
tag = wrapper.roomId.value,
|
tag = wrapper.roomId.value,
|
||||||
id = notificationIdProvider.getRoomMessagesNotificationId(currentUser.userId)
|
id = notificationIdProvider.getRoomMessagesNotificationId(currentUser.userId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is RoomNotification.Message -> if (useCompleteNotificationFormat) {
|
is RoomNotification.Message -> if (useCompleteNotificationFormat) {
|
||||||
Timber.d("Updating room messages notification ${wrapper.meta.roomId}")
|
Timber.tag(loggerTag.value).d("Updating room messages notification ${wrapper.meta.roomId}")
|
||||||
notificationDisplayer.showNotificationMessage(
|
notificationDisplayer.showNotificationMessage(
|
||||||
tag = wrapper.meta.roomId.value,
|
tag = wrapper.meta.roomId.value,
|
||||||
id = notificationIdProvider.getRoomMessagesNotificationId(currentUser.userId),
|
id = notificationIdProvider.getRoomMessagesNotificationId(currentUser.userId),
|
||||||
|
|
@ -84,14 +88,14 @@ class NotificationRenderer @Inject constructor(
|
||||||
invitationNotifications.forEach { wrapper ->
|
invitationNotifications.forEach { wrapper ->
|
||||||
when (wrapper) {
|
when (wrapper) {
|
||||||
is OneShotNotification.Removed -> {
|
is OneShotNotification.Removed -> {
|
||||||
Timber.d("Removing invitation notification ${wrapper.key}")
|
Timber.tag(loggerTag.value).d("Removing invitation notification ${wrapper.key}")
|
||||||
notificationDisplayer.cancelNotificationMessage(
|
notificationDisplayer.cancelNotificationMessage(
|
||||||
tag = wrapper.key,
|
tag = wrapper.key,
|
||||||
id = notificationIdProvider.getRoomInvitationNotificationId(currentUser.userId)
|
id = notificationIdProvider.getRoomInvitationNotificationId(currentUser.userId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
|
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
|
||||||
Timber.d("Updating invitation notification ${wrapper.meta.key}")
|
Timber.tag(loggerTag.value).d("Updating invitation notification ${wrapper.meta.key}")
|
||||||
notificationDisplayer.showNotificationMessage(
|
notificationDisplayer.showNotificationMessage(
|
||||||
tag = wrapper.meta.key,
|
tag = wrapper.meta.key,
|
||||||
id = notificationIdProvider.getRoomInvitationNotificationId(currentUser.userId),
|
id = notificationIdProvider.getRoomInvitationNotificationId(currentUser.userId),
|
||||||
|
|
@ -104,14 +108,14 @@ class NotificationRenderer @Inject constructor(
|
||||||
simpleNotifications.forEach { wrapper ->
|
simpleNotifications.forEach { wrapper ->
|
||||||
when (wrapper) {
|
when (wrapper) {
|
||||||
is OneShotNotification.Removed -> {
|
is OneShotNotification.Removed -> {
|
||||||
Timber.d("Removing simple notification ${wrapper.key}")
|
Timber.tag(loggerTag.value).d("Removing simple notification ${wrapper.key}")
|
||||||
notificationDisplayer.cancelNotificationMessage(
|
notificationDisplayer.cancelNotificationMessage(
|
||||||
tag = wrapper.key,
|
tag = wrapper.key,
|
||||||
id = notificationIdProvider.getRoomEventNotificationId(currentUser.userId)
|
id = notificationIdProvider.getRoomEventNotificationId(currentUser.userId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
|
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
|
||||||
Timber.d("Updating simple notification ${wrapper.meta.key}")
|
Timber.tag(loggerTag.value).d("Updating simple notification ${wrapper.meta.key}")
|
||||||
notificationDisplayer.showNotificationMessage(
|
notificationDisplayer.showNotificationMessage(
|
||||||
tag = wrapper.meta.key,
|
tag = wrapper.meta.key,
|
||||||
id = notificationIdProvider.getRoomEventNotificationId(currentUser.userId),
|
id = notificationIdProvider.getRoomEventNotificationId(currentUser.userId),
|
||||||
|
|
@ -124,14 +128,14 @@ class NotificationRenderer @Inject constructor(
|
||||||
fallbackNotifications.forEach { wrapper ->
|
fallbackNotifications.forEach { wrapper ->
|
||||||
when (wrapper) {
|
when (wrapper) {
|
||||||
is OneShotNotification.Removed -> {
|
is OneShotNotification.Removed -> {
|
||||||
Timber.d("Removing fallback notification ${wrapper.key}")
|
Timber.tag(loggerTag.value).d("Removing fallback notification ${wrapper.key}")
|
||||||
notificationDisplayer.cancelNotificationMessage(
|
notificationDisplayer.cancelNotificationMessage(
|
||||||
tag = wrapper.key,
|
tag = wrapper.key,
|
||||||
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId)
|
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
|
is OneShotNotification.Append -> if (useCompleteNotificationFormat) {
|
||||||
Timber.d("Updating fallback notification ${wrapper.meta.key}")
|
Timber.tag(loggerTag.value).d("Updating fallback notification ${wrapper.meta.key}")
|
||||||
notificationDisplayer.showNotificationMessage(
|
notificationDisplayer.showNotificationMessage(
|
||||||
tag = wrapper.meta.key,
|
tag = wrapper.meta.key,
|
||||||
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId),
|
id = notificationIdProvider.getFallbackNotificationId(currentUser.userId),
|
||||||
|
|
@ -143,7 +147,7 @@ class NotificationRenderer @Inject constructor(
|
||||||
|
|
||||||
// Update summary last to avoid briefly displaying it before other notifications
|
// Update summary last to avoid briefly displaying it before other notifications
|
||||||
if (summaryNotification is SummaryNotification.Update) {
|
if (summaryNotification is SummaryNotification.Update) {
|
||||||
Timber.d("Updating summary notification")
|
Timber.tag(loggerTag.value).d("Updating summary notification")
|
||||||
notificationDisplayer.showNotificationMessage(
|
notificationDisplayer.showNotificationMessage(
|
||||||
tag = null,
|
tag = null,
|
||||||
id = notificationIdProvider.getSummaryNotificationId(currentUser.userId),
|
id = notificationIdProvider.getSummaryNotificationId(currentUser.userId),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue