mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Display a notice in the timeline when a voice broadcast is stopped
This commit is contained in:
parent
aa5270760e
commit
7a1dfef6d5
4 changed files with 26 additions and 8 deletions
|
@ -135,6 +135,7 @@
|
|||
<string name="notice_crypto_error_unknown_inbound_session_id">The sender\'s device has not sent us the keys for this message.</string>
|
||||
|
||||
<string name="notice_voice_broadcast_ended">%1$s ended a voice broadcast.</string>
|
||||
<string name="notice_voice_broadcast_ended_by_you">You ended a voice broadcast.</string>
|
||||
|
||||
<!-- Messages -->
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue