diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml
index 2d289150c6..127d63f74c 100644
--- a/library/ui-strings/src/main/res/values/strings.xml
+++ b/library/ui-strings/src/main/res/values/strings.xml
@@ -135,6 +135,7 @@
The sender\'s device has not sent us the keys for this message.
%1$s ended a voice broadcast.
+ You ended a voice broadcast.
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt
index c8af85db4f..5fa9576dd4 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt
@@ -20,13 +20,13 @@ import dagger.Lazy
import im.vector.app.EmojiSpanify
import im.vector.app.R
import im.vector.app.core.extensions.getVectorLastMessageContent
+import im.vector.app.core.extensions.orEmpty
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.DrawableProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.html.EventHtmlRenderer
import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
import im.vector.app.features.voicebroadcast.isLive
-import im.vector.app.features.voicebroadcast.model.VoiceBroadcastEvent
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
import me.gujun.android.span.image
import me.gujun.android.span.span
@@ -143,7 +143,7 @@ class DisplayableEventFormatter @Inject constructor(
simpleFormat(senderName, stringProvider.getString(R.string.sent_live_location), appendAuthor)
}
VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO -> {
- formatVoiceBroadcastEvent(timelineEvent.root.asVoiceBroadcastEvent(), senderName)
+ formatVoiceBroadcastEvent(timelineEvent.root, isDm, senderName)
}
else -> {
span {
@@ -263,8 +263,8 @@ class DisplayableEventFormatter @Inject constructor(
}
}
- private fun formatVoiceBroadcastEvent(voiceBroadcastEvent: VoiceBroadcastEvent?, senderName: String): CharSequence {
- return if (voiceBroadcastEvent?.isLive == true) {
+ private fun formatVoiceBroadcastEvent(event: Event, isDm: Boolean, senderName: String): CharSequence {
+ return if (event.asVoiceBroadcastEvent()?.isLive == true) {
span {
drawableProvider.getDrawable(R.drawable.ic_voice_broadcast, colorProvider.getColor(R.color.palette_vermilion))?.let {
image(it)
@@ -275,7 +275,7 @@ class DisplayableEventFormatter @Inject constructor(
}
}
} else {
- stringProvider.getString(R.string.notice_voice_broadcast_ended, senderName)
+ noticeEventFormatter.format(event, senderName, isDm).orEmpty()
}
}
}
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
index 3f702ed72d..b02e515774 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt
@@ -22,6 +22,8 @@ import im.vector.app.core.resources.StringProvider
import im.vector.app.features.roomprofile.permissions.RoleFormatter
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
+import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
+import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import org.matrix.android.sdk.api.extensions.appendNl
import org.matrix.android.sdk.api.extensions.orFalse
@@ -91,6 +93,9 @@ class NoticeEventFormatter @Inject constructor(
EventType.CALL_HANGUP,
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
+ VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO -> {
+ formatVoiceBroadcastEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName)
+ }
EventType.CALL_NEGOTIATE,
EventType.CALL_SELECT_ANSWER,
EventType.CALL_REPLACES,
@@ -109,8 +114,7 @@ class NoticeEventFormatter @Inject constructor(
EventType.STICKER,
in EventType.POLL_RESPONSE.values,
in EventType.POLL_END.values,
- in EventType.BEACON_LOCATION_DATA.values,
- VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO -> formatDebug(timelineEvent.root)
+ in EventType.BEACON_LOCATION_DATA.values -> formatDebug(timelineEvent.root)
else -> {
Timber.v("Type $type not handled by this formatter")
null
@@ -191,6 +195,7 @@ class NoticeEventFormatter @Inject constructor(
EventType.CALL_REJECT,
EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName)
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, isDm)
+ VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO -> formatVoiceBroadcastEvent(event, senderName)
else -> {
Timber.v("Type $type not handled by this formatter")
null
@@ -894,4 +899,16 @@ class NoticeEventFormatter @Inject constructor(
}
}
}
+
+ private fun formatVoiceBroadcastEvent(event: Event, senderName: String?): CharSequence {
+ return if (event.asVoiceBroadcastEvent()?.content?.voiceBroadcastState == VoiceBroadcastState.STOPPED) {
+ if (event.isSentByCurrentUser()) {
+ sp.getString(R.string.notice_voice_broadcast_ended_by_you)
+ } else {
+ sp.getString(R.string.notice_voice_broadcast_ended, senderName)
+ }
+ } else {
+ formatDebug(event)
+ }
+ }
}
diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineEventVisibilityHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineEventVisibilityHelper.kt
index 382f1c2301..703a5cb911 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineEventVisibilityHelper.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineEventVisibilityHelper.kt
@@ -252,7 +252,7 @@ class TimelineEventVisibilityHelper @Inject constructor(
}
if (root.getClearType() == VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO &&
- root.asVoiceBroadcastEvent()?.content?.voiceBroadcastState != VoiceBroadcastState.STARTED) {
+ root.asVoiceBroadcastEvent()?.content?.voiceBroadcastState !in arrayOf(VoiceBroadcastState.STARTED, VoiceBroadcastState.STOPPED)) {
return true
}