mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Avoid showing debug notice format for event preview
This commit is contained in:
parent
c895f87e26
commit
a544ae264b
2 changed files with 44 additions and 6 deletions
|
@ -20,15 +20,17 @@ import im.vector.app.EmojiCompatWrapper
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageOptionsContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||
import org.matrix.android.sdk.api.session.room.model.message.OPTION_TYPE_BUTTONS
|
||||
import org.matrix.android.sdk.api.session.room.model.relation.ReactionContent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.getTextEditableContent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.isReply
|
||||
import me.gujun.android.span.span
|
||||
import javax.inject.Inject
|
||||
|
||||
class DisplayableEventFormatter @Inject constructor(
|
||||
|
@ -56,7 +58,7 @@ class DisplayableEventFormatter @Inject constructor(
|
|||
}
|
||||
EventType.REACTION -> {
|
||||
timelineEvent.root.getClearContent().toModel<ReactionContent>()?.relatesTo?.let {
|
||||
val emojiSpanned = emojiCompatWrapper.safeEmojiSpanify(it.key)
|
||||
val emojiSpanned = emojiCompatWrapper.safeEmojiSpanify(stringProvider.getString(R.string.sent_a_reaction, it.key))
|
||||
return simpleFormat(senderName, emojiSpanned, appendAuthor)
|
||||
}
|
||||
}
|
||||
|
@ -88,12 +90,44 @@ class DisplayableEventFormatter @Inject constructor(
|
|||
simpleFormat(senderName, messageContent.body, appendAuthor)
|
||||
}
|
||||
}
|
||||
MessageType.MSGTYPE_RESPONSE -> {
|
||||
// do not show that?
|
||||
return span { }
|
||||
}
|
||||
MessageType.MSGTYPE_OPTIONS -> {
|
||||
return when (messageContent) {
|
||||
is MessageOptionsContent -> {
|
||||
val previewText = if (messageContent.optionType == OPTION_TYPE_BUTTONS) {
|
||||
stringProvider.getString(R.string.sent_a_bot_buttons)
|
||||
} else {
|
||||
stringProvider.getString(R.string.sent_a_poll)
|
||||
}
|
||||
simpleFormat(senderName, previewText, appendAuthor)
|
||||
}
|
||||
else -> {
|
||||
span { }
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
return simpleFormat(senderName, messageContent.body, appendAuthor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EventType.KEY_VERIFICATION_CANCEL,
|
||||
EventType.KEY_VERIFICATION_DONE -> {
|
||||
// cancel and done can appear in timeline, so should have representation
|
||||
return simpleFormat(senderName, stringProvider.getString(R.string.sent_verification_conclusion), appendAuthor)
|
||||
}
|
||||
EventType.KEY_VERIFICATION_START,
|
||||
EventType.KEY_VERIFICATION_ACCEPT,
|
||||
EventType.KEY_VERIFICATION_MAC,
|
||||
EventType.KEY_VERIFICATION_KEY,
|
||||
EventType.KEY_VERIFICATION_READY,
|
||||
EventType.CALL_CANDIDATES -> {
|
||||
return span { }
|
||||
}
|
||||
else -> {
|
||||
return span {
|
||||
text = noticeEventFormatter.format(timelineEvent) ?: ""
|
||||
|
|
|
@ -2067,6 +2067,10 @@
|
|||
<string name="sent_an_audio_file">Audio</string>
|
||||
<string name="sent_a_file">File</string>
|
||||
<string name="send_a_sticker">Sticker</string>
|
||||
<string name="sent_a_poll">Poll</string>
|
||||
<string name="sent_a_bot_buttons">Bot Buttons</string>
|
||||
<string name="sent_a_reaction">Reacted with: %s</string>
|
||||
<string name="sent_verification_conclusion">Verification Conclusion</string>
|
||||
|
||||
<string name="verification_request_waiting">Waiting…</string>
|
||||
<string name="verification_request_other_cancelled">%s cancelled</string>
|
||||
|
|
Loading…
Reference in a new issue