mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-23 07:40:20 +01:00
Voice Broadcast - Add voice message extensions
This commit is contained in:
parent
16c27ba174
commit
402224721b
@ -44,7 +44,6 @@ import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvid
|
||||
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.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_
|
||||
@ -79,6 +78,7 @@ import im.vector.app.features.media.ImageContentRenderer
|
||||
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.isVoiceBroadcast
|
||||
import im.vector.app.features.voicebroadcast.model.MessageVoiceBroadcastInfoContent
|
||||
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
||||
import me.gujun.android.span.span
|
||||
@ -103,6 +103,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.asMessageAudioEvent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getThumbnailUrl
|
||||
import org.matrix.android.sdk.api.settings.LightweightSettingsStorage
|
||||
@ -321,8 +322,8 @@ class MessageItemFactory @Inject constructor(
|
||||
highlight: Boolean,
|
||||
attributes: AbsMessageItem.Attributes
|
||||
): MessageVoiceItem? {
|
||||
val eventsGroup = params.eventsGroup?.let { VoiceBroadcastEventsGroup(it) }
|
||||
if (eventsGroup != null && eventsGroup.getLastDisplayableEvent().eventId != params.event.eventId) return null
|
||||
// Do not display voice broadcast messages
|
||||
if (params.event.root.asMessageAudioEvent().isVoiceBroadcast()) return null
|
||||
|
||||
val fileUrl = getAudioFileUrl(messageContent, informationData)
|
||||
val playbackControlButtonClickListener = createOnPlaybackButtonClickListener(messageContent, informationData, params)
|
||||
|
@ -18,15 +18,15 @@ package im.vector.app.features.home.room.detail.timeline.helper
|
||||
|
||||
import im.vector.app.core.utils.TextUtils
|
||||
import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
|
||||
import im.vector.app.features.voicebroadcast.getVoiceBroadcastEventId
|
||||
import im.vector.app.features.voicebroadcast.isVoiceBroadcast
|
||||
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.RelationType
|
||||
import org.matrix.android.sdk.api.session.events.model.getRelationContent
|
||||
import org.matrix.android.sdk.api.session.events.model.isVoiceMessage
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.call.CallInviteContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.asMessageAudioEvent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.api.session.widgets.model.WidgetContent
|
||||
import org.threeten.bp.Duration
|
||||
@ -64,9 +64,9 @@ class TimelineEventsGroups {
|
||||
EventType.isCallEvent(type) -> (content?.get("call_id") as? String)
|
||||
type == VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO -> root.asVoiceBroadcastEvent()?.reference?.eventId
|
||||
type == EventType.STATE_ROOM_WIDGET || type == EventType.STATE_ROOM_WIDGET_LEGACY -> root.stateKey
|
||||
type == EventType.MESSAGE && root.isVoiceMessage() -> {
|
||||
type == EventType.MESSAGE && root.asMessageAudioEvent().isVoiceBroadcast() -> {
|
||||
// Group voice messages with a reference to an eventId
|
||||
root.getRelationContent()?.takeIf { it.type == RelationType.REFERENCE }?.eventId
|
||||
root.asMessageAudioEvent()?.getVoiceBroadcastEventId()
|
||||
}
|
||||
else -> {
|
||||
null
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* 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 im.vector.app.features.voicebroadcast
|
||||
|
||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||
import org.matrix.android.sdk.api.session.events.model.getRelationContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioEvent
|
||||
|
||||
fun MessageAudioEvent?.isVoiceBroadcast() = this?.getVoiceBroadcastEventId() != null
|
||||
|
||||
fun MessageAudioEvent.getVoiceBroadcastEventId(): String? =
|
||||
// TODO Improve this condition by checking the referenced event type
|
||||
root.takeIf { content.voiceMessageIndicator != null }
|
||||
?.getRelationContent()?.takeIf { it.type == RelationType.REFERENCE }
|
||||
?.eventId
|
Loading…
Reference in New Issue
Block a user