Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#241 Group call notifications #250

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion changelog.d/7761.feature

This file was deleted.

2 changes: 0 additions & 2 deletions library/external/textdrawable/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
apply plugin: 'com.android.library'

apply plugin: 'com.android.library'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this change relate to the PR?
(I see the line is duplicated, but fixing upstream code style is not really something we want to do here)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to build properly and launch an app, with this duplicated line and after removing it, building was success. I am not sure how it affects and can't remember exact error, unfortunately. Do you think we should return back this duplicated line ?


android {
namespace "com.amulyakhare.textdrawable"

Expand Down
4 changes: 1 addition & 3 deletions library/ui-strings/src/main/res/values-ru/strings_sc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,4 @@
<string name="settings_clear_highlight_on_scroll">Очистить выделение при прокрутке</string>
<string name="settings_call_ringtone_use_default_stun_title">Разрешить резервный сервер звонков</string>
<string name="settings_integrations_scalar_warning">⚠️ Эта настройка по умолчанию (если не изменена конфигурацией Вашего домашнего сервера) включает доступ к \"Scalar\", менеджеру интеграций от Element. К сожалению, он является проприетарным, т.е. его исходый код не открытый и не может быть проверен пользователями или разработчиками SchildiChat.</string>
<string name="call_notification_open_app_action">Открыть приложение</string>
<string name="labs_enable_group_call_notifications_summary">Включить уведомление для групповых звонков</string>
</resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
)
2 changes: 1 addition & 1 deletion vector-config/src/main/res/values/config-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class NotifiableEventResolver @Inject constructor(
ContentUrlResolver.ThumbnailMethod.SCALE
),
matrixID = session.myUserId,
soundName = null
soundName = null,
isReceived = null,
)
} else {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@ 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 {

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
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -135,10 +135,7 @@ 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())
}
jitsiEvents.add(it.castedToEventType())
}
is SimpleNotifiableEvent -> simpleEvents.add(it.castedToEventType())
}
Expand Down