Disabled settings_labs_enable_jitsi_call_notifications_default by default. Changed detection for group calls more accurate. Added tracking visibility status for jitsi notifications
This commit is contained in:
parent
9fa60139c2
commit
b63af09368
|
@ -23,7 +23,9 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
|
|||
import org.matrix.android.sdk.api.failure.MatrixError
|
||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||
import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType.IS_JITSI_CALL
|
||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||
import org.matrix.android.sdk.api.session.room.model.JitsiEventContent
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||
|
@ -498,7 +500,7 @@ fun Event.getPollContent(): MessagePollContent? {
|
|||
return getClearContent().toModel<MessagePollContent>()
|
||||
}
|
||||
|
||||
fun Event.isJitsiEvent() = this.getClearType() == EventType.STATE_ROOM_WIDGET_LEGACY
|
||||
fun Event.isJitsiEvent() = content?.toModel<JitsiEventContent>()?.type == IS_JITSI_CALL && content.toModel<JitsiEventContent>()?.name == IS_JITSI_CALL
|
||||
|
||||
fun Event.supportsNotification() =
|
||||
this.getClearType() in EventType.MESSAGE + EventType.POLL_START.values + EventType.POLL_END.values + EventType.STATE_ROOM_BEACON_INFO.values
|
||||
|
|
|
@ -108,6 +108,9 @@ object EventType {
|
|||
// Relation Events
|
||||
const val REACTION = "m.reaction"
|
||||
|
||||
// Jitsi call
|
||||
const val IS_JITSI_CALL = "jitsi"
|
||||
|
||||
// Poll
|
||||
val POLL_START = StableUnstableId(stable = "m.poll.start", unstable = "org.matrix.msc3381.poll.start")
|
||||
val POLL_RESPONSE = StableUnstableId(stable = "m.poll.response", unstable = "org.matrix.msc3381.poll.response")
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.api.session.room.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
/**
|
||||
* Class representing the Jitsi call state event.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class JitsiEventContent(
|
||||
@Json(name = "type") val type: String? = null,
|
||||
@Json(name = "name") val name: String? = null,
|
||||
)
|
|
@ -51,7 +51,7 @@
|
|||
<bool name="settings_labs_rich_text_editor_default">false</bool>
|
||||
<bool name="settings_labs_enable_voice_broadcast_visible">true</bool>
|
||||
<bool name="settings_labs_enable_voice_broadcast_default">false</bool>
|
||||
<bool name="settings_labs_enable_jitsi_call_notifications_default">true</bool>
|
||||
<bool name="settings_labs_enable_jitsi_call_notifications_default">false</bool>
|
||||
<!-- Level 1: Advanced settings -->
|
||||
|
||||
<!-- Level 1: Help and about -->
|
||||
|
|
|
@ -41,18 +41,29 @@ class NotifiableEventProcessor @Inject constructor(
|
|||
.also { Timber.d("notification message removed due to being read") }
|
||||
else -> KEEP
|
||||
}
|
||||
is NotifiableJitsiEvent -> KEEP
|
||||
is NotifiableJitsiEvent -> {
|
||||
if (it.isReceived != true) {
|
||||
KEEP
|
||||
} else {
|
||||
REMOVE
|
||||
}
|
||||
}
|
||||
is SimpleNotifiableEvent -> when (it.type) {
|
||||
EventType.REDACTION -> REMOVE
|
||||
else -> KEEP
|
||||
}
|
||||
}
|
||||
ProcessedEvent(type, it)
|
||||
|
||||
val updatedEvent = if (it is NotifiableJitsiEvent) it.updateReceivedStatus() else it
|
||||
ProcessedEvent(type, updatedEvent)
|
||||
}
|
||||
|
||||
val removedEventsDiff = renderedEvents.filter { renderedEvent ->
|
||||
queuedEvents.none { it.eventId == renderedEvent.event.eventId }
|
||||
}.map { ProcessedEvent(REMOVE, it.event) }
|
||||
}.map {
|
||||
val updatedEvent = if (it.event is NotifiableJitsiEvent) it.event.updateReceivedStatus() else it.event
|
||||
ProcessedEvent(REMOVE, updatedEvent)
|
||||
}
|
||||
|
||||
return removedEventsDiff + processedEvents
|
||||
}
|
||||
|
|
|
@ -174,7 +174,8 @@ class NotifiableEventResolver @Inject constructor(
|
|||
ContentUrlResolver.ThumbnailMethod.SCALE
|
||||
),
|
||||
matrixID = session.myUserId,
|
||||
soundName = null
|
||||
soundName = null,
|
||||
isReceived = null,
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
|
@ -37,6 +37,7 @@ data class NotifiableJitsiEvent(
|
|||
// This is used for >N notification, as the result of a smart reply
|
||||
val outGoingMessage: Boolean = false,
|
||||
val outGoingMessageFailed: Boolean = false,
|
||||
var isReceived: Boolean? = null,
|
||||
override val isRedacted: Boolean = false,
|
||||
override val isUpdated: Boolean = false
|
||||
) : NotifiableEvent {
|
||||
|
@ -44,4 +45,12 @@ data class NotifiableJitsiEvent(
|
|||
val type: String = EventType.MESSAGE
|
||||
val description: String = body ?: ""
|
||||
val title: String = senderName ?: ""
|
||||
|
||||
fun updateReceivedStatus() = this.copy(
|
||||
isReceived = when (isReceived) {
|
||||
null -> false
|
||||
false -> true
|
||||
true -> true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -30,14 +30,20 @@ class NotificationFactory @Inject constructor(
|
|||
|
||||
fun Map<String, ProcessedJitsiEvents>.toNotifications(): List<JitsiNotification> {
|
||||
return map { (roomId, events) ->
|
||||
if (events.all { it.event.isReceived == true }) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val eventToShow = events.first { it.event.isReceived == false }
|
||||
|
||||
JitsiNotification.IncomingCall(
|
||||
roomId = roomId,
|
||||
eventId = events.firstOrNull()?.event?.eventId.orEmpty(),
|
||||
roomName = events.firstOrNull()?.event?.roomName.orEmpty(),
|
||||
eventId = eventToShow.event.eventId,
|
||||
roomName = eventToShow.event.roomName.orEmpty(),
|
||||
notification = notificationUtils.buildIncomingJitsiCallNotification(
|
||||
callId = events.firstOrNull()?.event?.eventId.orEmpty().ifEmpty { roomId },
|
||||
callId = eventToShow.event.eventId.ifEmpty { roomId },
|
||||
signalingRoomId = roomId,
|
||||
title = events.firstOrNull()?.event?.roomName.orEmpty(),
|
||||
title = eventToShow.event.roomName.orEmpty(),
|
||||
fromBg = true,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -76,7 +76,7 @@ class NotificationRenderer @Inject constructor(
|
|||
jitsiNotifications.forEach { wrapper ->
|
||||
when (wrapper) {
|
||||
is JitsiNotification.IncomingCall -> {
|
||||
Timber.d("Updating jitsi call notification ${wrapper.roomId} for room ${wrapper.roomName}")
|
||||
Timber.d("Updating jitsi call notification ${wrapper.eventId} for room ${wrapper.roomName}")
|
||||
if (wrapper.eventId.isNotEmpty() || wrapper.roomId.isNotEmpty()) {
|
||||
val tag = wrapper.eventId.ifEmpty { wrapper.roomId }
|
||||
notificationDisplayer.showNotificationMessage(tag, JITSI_CALL_NOTIFICATION_ID, wrapper.notification)
|
||||
|
@ -135,11 +135,8 @@ private fun List<ProcessedEvent<NotifiableEvent>>.groupByType(): GroupedNotifica
|
|||
}
|
||||
is NotifiableJitsiEvent -> {
|
||||
val jitsiEvents = roomIdToJitsiEventMap.getOrPut(event.roomId) { ArrayList() }
|
||||
val diffInMillis = System.currentTimeMillis() - (it.event as NotifiableJitsiEvent).timestamp
|
||||
if (diffInMillis < 10000) {
|
||||
jitsiEvents.add(it.castedToEventType())
|
||||
}
|
||||
}
|
||||
is SimpleNotifiableEvent -> simpleEvents.add(it.castedToEventType())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue