mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-31 03:17:13 +01:00
Merge pull request #7283 from vector-im/feature/fre/aggregate_voice_broadcast_state_events
Aggregate voice broadcast state events
This commit is contained in:
commit
b9f474041f
1
changelog.d/7283.wip
Normal file
1
changelog.d/7283.wip
Normal file
@ -0,0 +1 @@
|
||||
[Voice Broadcast] Aggregate state events in the timeline
|
@ -43,7 +43,9 @@ import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStat
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.MessageInformationDataFactory
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.MessageItemAttributesFactory
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.TimelineEventsGroup
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.VoiceBroadcastEventsGroup
|
||||
import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem
|
||||
import im.vector.app.features.home.room.detail.timeline.item.MessageAudioItem
|
||||
import im.vector.app.features.home.room.detail.timeline.item.MessageAudioItem_
|
||||
@ -81,6 +83,7 @@ import im.vector.app.features.media.VideoContentRenderer
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.voice.AudioWaveformView
|
||||
import im.vector.app.features.voicebroadcast.model.MessageVoiceBroadcastInfoContent
|
||||
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
|
||||
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
|
||||
@ -200,7 +203,7 @@ class MessageItemFactory @Inject constructor(
|
||||
is MessagePollContent -> buildPollItem(messageContent, informationData, highlight, callback, attributes)
|
||||
is MessageLocationContent -> buildLocationItem(messageContent, informationData, highlight, attributes)
|
||||
is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(params.event, highlight, attributes)
|
||||
is MessageVoiceBroadcastInfoContent -> buildVoiceBroadcastItem(messageContent, highlight, callback, attributes)
|
||||
is MessageVoiceBroadcastInfoContent -> buildVoiceBroadcastItem(messageContent, params.eventsGroup, highlight, callback, attributes)
|
||||
else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes)
|
||||
}
|
||||
return messageItem?.apply {
|
||||
@ -712,14 +715,19 @@ class MessageItemFactory @Inject constructor(
|
||||
|
||||
private fun buildVoiceBroadcastItem(
|
||||
messageContent: MessageVoiceBroadcastInfoContent,
|
||||
eventsGroup: TimelineEventsGroup?,
|
||||
highlight: Boolean,
|
||||
callback: TimelineEventController.Callback?,
|
||||
attributes: AbsMessageItem.Attributes,
|
||||
): MessageVoiceBroadcastItem? {
|
||||
if (messageContent.voiceBroadcastState != VoiceBroadcastState.STARTED) return null
|
||||
val voiceBroadcastEventsGroup = eventsGroup?.let { VoiceBroadcastEventsGroup(it) } ?: return null
|
||||
val mostRecentEvent = voiceBroadcastEventsGroup.getLastEvent()
|
||||
val mostRecentMessageContent = (mostRecentEvent.getVectorLastMessageContent() as? MessageVoiceBroadcastInfoContent) ?: return null
|
||||
return MessageVoiceBroadcastItem_()
|
||||
.attributes(attributes)
|
||||
.highlighted(highlight)
|
||||
.voiceBroadcastState(messageContent.voiceBroadcastState)
|
||||
.voiceBroadcastState(mostRecentMessageContent.voiceBroadcastState)
|
||||
.leftGuideline(avatarSizeProvider.leftGuideline)
|
||||
.callback(callback)
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
package im.vector.app.features.home.room.detail.timeline.helper
|
||||
|
||||
import im.vector.app.core.utils.TextUtils
|
||||
import im.vector.app.features.voicebroadcast.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
|
||||
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
@ -54,12 +57,13 @@ class TimelineEventsGroups {
|
||||
private fun TimelineEvent.getGroupIdOrNull(): String? {
|
||||
val type = root.getClearType()
|
||||
val content = root.getClearContent()
|
||||
return if (EventType.isCallEvent(type)) {
|
||||
(content?.get("call_id") as? String)
|
||||
} else if (type == EventType.STATE_ROOM_WIDGET || type == EventType.STATE_ROOM_WIDGET_LEGACY) {
|
||||
root.stateKey
|
||||
} else {
|
||||
null
|
||||
return when {
|
||||
EventType.isCallEvent(type) -> (content?.get("call_id") as? String)
|
||||
type == STATE_ROOM_VOICE_BROADCAST_INFO -> root.asVoiceBroadcastEvent()?.reference?.eventId
|
||||
type == EventType.STATE_ROOM_WIDGET || type == EventType.STATE_ROOM_WIDGET_LEGACY -> root.stateKey
|
||||
else -> {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,3 +132,10 @@ class CallSignalingEventsGroup(private val group: TimelineEventsGroup) {
|
||||
return group.events.firstOrNull { it.root.getClearType() == EventType.CALL_REJECT }
|
||||
}
|
||||
}
|
||||
|
||||
class VoiceBroadcastEventsGroup(private val group: TimelineEventsGroup) {
|
||||
fun getLastEvent(): TimelineEvent {
|
||||
return group.events.find { it.root.asVoiceBroadcastEvent()?.content?.voiceBroadcastState == VoiceBroadcastState.STOPPED }
|
||||
?: group.events.maxBy { it.root.originServerTs ?: 0L }
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ abstract class MessageVoiceBroadcastItem : AbsMessageItem<MessageVoiceBroadcastI
|
||||
@EpoxyAttribute
|
||||
var voiceBroadcastState: VoiceBroadcastState? = null
|
||||
|
||||
override fun isCacheable(): Boolean = false
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
bindVoiceBroadcastItem(holder)
|
||||
|
Loading…
x
Reference in New Issue
Block a user