making non overriden properties immutable by passing the values intro the constructor
This commit is contained in:
parent
51f7dee952
commit
81da185d8b
|
@ -18,16 +18,16 @@ package im.vector.app.features.notifications
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
|
||||||
data class InviteNotifiableEvent(
|
data class InviteNotifiableEvent(
|
||||||
var matrixID: String?,
|
val matrixID: String?,
|
||||||
override val eventId: String,
|
override val eventId: String,
|
||||||
override val editedEventId: String?,
|
override val editedEventId: String?,
|
||||||
var roomId: String,
|
val roomId: String,
|
||||||
override var noisy: Boolean,
|
override var noisy: Boolean,
|
||||||
val title: String,
|
val title: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
val type: String?,
|
val type: String?,
|
||||||
val timestamp: Long,
|
val timestamp: Long,
|
||||||
var soundName: String?,
|
val soundName: String?,
|
||||||
override var isPushGatewayEvent: Boolean = false) : NotifiableEvent {
|
override var isPushGatewayEvent: Boolean = false) : NotifiableEvent {
|
||||||
|
|
||||||
override var isRedacted: Boolean = false
|
override var isRedacted: Boolean = false
|
||||||
|
|
|
@ -142,7 +142,7 @@ class NotifiableEventResolver @Inject constructor(
|
||||||
val roomName = stringProvider.getString(R.string.notification_unknown_room_name)
|
val roomName = stringProvider.getString(R.string.notification_unknown_room_name)
|
||||||
val senderDisplayName = event.senderInfo.disambiguatedDisplayName
|
val senderDisplayName = event.senderInfo.disambiguatedDisplayName
|
||||||
|
|
||||||
val notifiableEvent = NotifiableMessageEvent(
|
return NotifiableMessageEvent(
|
||||||
eventId = event.root.eventId!!,
|
eventId = event.root.eventId!!,
|
||||||
editedEventId = event.getEditedEventId(),
|
editedEventId = event.getEditedEventId(),
|
||||||
timestamp = event.root.originServerTs ?: 0,
|
timestamp = event.root.originServerTs ?: 0,
|
||||||
|
@ -151,10 +151,9 @@ class NotifiableEventResolver @Inject constructor(
|
||||||
senderId = event.root.senderId,
|
senderId = event.root.senderId,
|
||||||
body = body.toString(),
|
body = body.toString(),
|
||||||
roomId = event.root.roomId!!,
|
roomId = event.root.roomId!!,
|
||||||
roomName = roomName)
|
roomName = roomName,
|
||||||
|
matrixID = session.myUserId
|
||||||
notifiableEvent.matrixID = session.myUserId
|
)
|
||||||
return notifiableEvent
|
|
||||||
} else {
|
} else {
|
||||||
if (event.root.isEncrypted() && event.root.mxDecryptionResult == null) {
|
if (event.root.isEncrypted() && event.root.mxDecryptionResult == null) {
|
||||||
// TODO use a global event decryptor? attache to session and that listen to new sessionId?
|
// TODO use a global event decryptor? attache to session and that listen to new sessionId?
|
||||||
|
@ -175,7 +174,7 @@ class NotifiableEventResolver @Inject constructor(
|
||||||
val roomName = room.roomSummary()?.displayName ?: ""
|
val roomName = room.roomSummary()?.displayName ?: ""
|
||||||
val senderDisplayName = event.senderInfo.disambiguatedDisplayName
|
val senderDisplayName = event.senderInfo.disambiguatedDisplayName
|
||||||
|
|
||||||
val notifiableEvent = NotifiableMessageEvent(
|
return NotifiableMessageEvent(
|
||||||
eventId = event.root.eventId!!,
|
eventId = event.root.eventId!!,
|
||||||
editedEventId = event.getEditedEventId(),
|
editedEventId = event.getEditedEventId(),
|
||||||
timestamp = event.root.originServerTs ?: 0,
|
timestamp = event.root.originServerTs ?: 0,
|
||||||
|
@ -185,25 +184,20 @@ class NotifiableEventResolver @Inject constructor(
|
||||||
body = body,
|
body = body,
|
||||||
roomId = event.root.roomId!!,
|
roomId = event.root.roomId!!,
|
||||||
roomName = roomName,
|
roomName = roomName,
|
||||||
roomIsDirect = room.roomSummary()?.isDirect ?: false)
|
roomIsDirect = room.roomSummary()?.isDirect ?: false,
|
||||||
|
roomAvatarPath = session.contentUrlResolver()
|
||||||
notifiableEvent.matrixID = session.myUserId
|
|
||||||
notifiableEvent.soundName = null
|
|
||||||
|
|
||||||
// Get the avatars URL
|
|
||||||
notifiableEvent.roomAvatarPath = session.contentUrlResolver()
|
|
||||||
.resolveThumbnail(room.roomSummary()?.avatarUrl,
|
.resolveThumbnail(room.roomSummary()?.avatarUrl,
|
||||||
250,
|
250,
|
||||||
250,
|
250,
|
||||||
ContentUrlResolver.ThumbnailMethod.SCALE)
|
ContentUrlResolver.ThumbnailMethod.SCALE),
|
||||||
|
senderAvatarPath = session.contentUrlResolver()
|
||||||
notifiableEvent.senderAvatarPath = session.contentUrlResolver()
|
|
||||||
.resolveThumbnail(event.senderInfo.avatarUrl,
|
.resolveThumbnail(event.senderInfo.avatarUrl,
|
||||||
250,
|
250,
|
||||||
250,
|
250,
|
||||||
ContentUrlResolver.ThumbnailMethod.SCALE)
|
ContentUrlResolver.ThumbnailMethod.SCALE),
|
||||||
|
matrixID = session.myUserId,
|
||||||
return notifiableEvent
|
soundName = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,33 +23,30 @@ data class NotifiableMessageEvent(
|
||||||
override val editedEventId: String?,
|
override val editedEventId: String?,
|
||||||
override var noisy: Boolean,
|
override var noisy: Boolean,
|
||||||
val timestamp: Long,
|
val timestamp: Long,
|
||||||
var senderName: String?,
|
val senderName: String?,
|
||||||
var senderId: String?,
|
val senderId: String?,
|
||||||
var body: String?,
|
val body: String?,
|
||||||
var roomId: String,
|
val roomId: String,
|
||||||
var roomName: String?,
|
val roomName: String?,
|
||||||
var roomIsDirect: Boolean = false
|
val roomIsDirect: Boolean = false,
|
||||||
|
val roomAvatarPath: String? = null,
|
||||||
|
val senderAvatarPath: String? = null,
|
||||||
|
|
||||||
|
val matrixID: String? = null,
|
||||||
|
val soundName: String? = null,
|
||||||
|
|
||||||
|
// This is used for >N notification, as the result of a smart reply
|
||||||
|
val outGoingMessage: Boolean = false,
|
||||||
|
val outGoingMessageFailed: Boolean = false
|
||||||
|
|
||||||
) : NotifiableEvent {
|
) : NotifiableEvent {
|
||||||
|
|
||||||
var matrixID: String? = null
|
|
||||||
var soundName: String? = null
|
|
||||||
override var lockScreenVisibility = NotificationCompat.VISIBILITY_PUBLIC
|
override var lockScreenVisibility = NotificationCompat.VISIBILITY_PUBLIC
|
||||||
override var hasBeenDisplayed: Boolean = false
|
override var hasBeenDisplayed: Boolean = false
|
||||||
override var isRedacted: Boolean = false
|
override var isRedacted: Boolean = false
|
||||||
|
|
||||||
var roomAvatarPath: String? = null
|
|
||||||
var senderAvatarPath: String? = null
|
|
||||||
|
|
||||||
override var isPushGatewayEvent: Boolean = false
|
override var isPushGatewayEvent: Boolean = false
|
||||||
|
|
||||||
val type: String = EventType.MESSAGE
|
val type: String = EventType.MESSAGE
|
||||||
|
val description: String = body ?: ""
|
||||||
val description: String
|
|
||||||
get() = body ?: ""
|
|
||||||
|
|
||||||
val title: String = senderName ?: ""
|
val title: String = senderName ?: ""
|
||||||
|
|
||||||
// This is used for >N notification, as the result of a smart reply
|
|
||||||
var outGoingMessage = false
|
|
||||||
var outGoingMessageFailed = false
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,19 +130,19 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
val notifiableMessageEvent = NotifiableMessageEvent(
|
val notifiableMessageEvent = NotifiableMessageEvent(
|
||||||
// Generate a Fake event id
|
// Generate a Fake event id
|
||||||
UUID.randomUUID().toString(),
|
eventId = UUID.randomUUID().toString(),
|
||||||
null,
|
editedEventId = null,
|
||||||
false,
|
noisy = false,
|
||||||
System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
session.getRoomMember(session.myUserId, room.roomId)?.displayName
|
senderName = session.getRoomMember(session.myUserId, room.roomId)?.displayName
|
||||||
?: context?.getString(R.string.notification_sender_me),
|
?: context?.getString(R.string.notification_sender_me),
|
||||||
session.myUserId,
|
senderId = session.myUserId,
|
||||||
message,
|
body = message,
|
||||||
room.roomId,
|
roomId = room.roomId,
|
||||||
room.roomSummary()?.displayName ?: room.roomId,
|
roomName = room.roomSummary()?.displayName ?: room.roomId,
|
||||||
room.roomSummary()?.isDirect == true
|
roomIsDirect = room.roomSummary()?.isDirect == true,
|
||||||
|
outGoingMessage = true
|
||||||
)
|
)
|
||||||
notifiableMessageEvent.outGoingMessage = true
|
|
||||||
|
|
||||||
notificationDrawerManager.onNotifiableEventReceived(notifiableMessageEvent)
|
notificationDrawerManager.onNotifiableEventReceived(notifiableMessageEvent)
|
||||||
notificationDrawerManager.refreshNotificationDrawer()
|
notificationDrawerManager.refreshNotificationDrawer()
|
||||||
|
|
|
@ -18,7 +18,7 @@ package im.vector.app.features.notifications
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
|
||||||
data class SimpleNotifiableEvent(
|
data class SimpleNotifiableEvent(
|
||||||
var matrixID: String?,
|
val matrixID: String?,
|
||||||
override val eventId: String,
|
override val eventId: String,
|
||||||
override val editedEventId: String?,
|
override val editedEventId: String?,
|
||||||
override var noisy: Boolean,
|
override var noisy: Boolean,
|
||||||
|
@ -26,7 +26,7 @@ data class SimpleNotifiableEvent(
|
||||||
val description: String,
|
val description: String,
|
||||||
val type: String?,
|
val type: String?,
|
||||||
val timestamp: Long,
|
val timestamp: Long,
|
||||||
var soundName: String?,
|
val soundName: String?,
|
||||||
override var isPushGatewayEvent: Boolean = false) : NotifiableEvent {
|
override var isPushGatewayEvent: Boolean = false) : NotifiableEvent {
|
||||||
|
|
||||||
override var hasBeenDisplayed: Boolean = false
|
override var hasBeenDisplayed: Boolean = false
|
||||||
|
|
Loading…
Reference in New Issue