mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Display encrypted messages in thread summary and in thread list
This commit is contained in:
parent
1e2fb88783
commit
4560d748d3
7 changed files with 26 additions and 8 deletions
|
@ -197,8 +197,8 @@ data class Event(
|
|||
* It can be used especially for message summaries.
|
||||
* It will return a decrypted text message or an empty string otherwise.
|
||||
*/
|
||||
fun getDecryptedTextSummary(): String {
|
||||
val text = getDecryptedValue().orEmpty()
|
||||
fun getDecryptedTextSummary(): String? {
|
||||
val text = getDecryptedValue() ?: return null
|
||||
return when {
|
||||
isReply() || isQuote() -> ContentUtils.extractUsefulTextFromReply(text)
|
||||
isFileMessage() -> "sent a file."
|
||||
|
|
|
@ -113,7 +113,7 @@ internal object EventMapper {
|
|||
)
|
||||
},
|
||||
threadNotificationState = eventEntity.threadNotificationState,
|
||||
threadSummaryLatestTextMessage = eventEntity.threadSummaryLatestMessage?.root?.asDomain()?.getDecryptedTextSummary().orEmpty(),
|
||||
threadSummaryLatestTextMessage = eventEntity.threadSummaryLatestMessage?.root?.asDomain()?.getDecryptedTextSummary(),
|
||||
lastMessageTimestamp = eventEntity.threadSummaryLatestMessage?.root?.originServerTs
|
||||
|
||||
)
|
||||
|
|
|
@ -1902,7 +1902,11 @@ class TimelineFragment @Inject constructor(
|
|||
roomDetailViewModel.handle(action)
|
||||
}
|
||||
is EncryptedEventContent -> {
|
||||
roomDetailViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId))
|
||||
if(isRootThreadEvent){
|
||||
onThreadSummaryClicked(informationData.eventId, isRootThreadEvent)
|
||||
}else {
|
||||
roomDetailViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId))
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
onThreadSummaryClicked(informationData.eventId, isRootThreadEvent)
|
||||
|
|
|
@ -106,7 +106,12 @@ class EncryptedItemFactory @Inject constructor(private val messageInformationDat
|
|||
}
|
||||
|
||||
val informationData = messageInformationDataFactory.create(params)
|
||||
val attributes = attributesFactory.create(event.root.content.toModel<EncryptedEventContent>(), informationData, params.callback)
|
||||
val threadDetails = if (params.isFromThreadTimeline()) null else event.root.threadDetails
|
||||
val attributes = attributesFactory.create(
|
||||
messageContent = event.root.content.toModel<EncryptedEventContent>(),
|
||||
informationData = informationData,
|
||||
callback = params.callback,
|
||||
threadDetails = threadDetails)
|
||||
return MessageTextItem_()
|
||||
.leftGuideline(avatarSizeProvider.leftGuideline)
|
||||
.highlighted(params.isHighlighted)
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
package im.vector.app.features.home.room.detail.timeline.helper
|
||||
|
||||
import im.vector.app.EmojiCompatFontProvider
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||
|
@ -28,6 +30,7 @@ class MessageItemAttributesFactory @Inject constructor(
|
|||
private val avatarRenderer: AvatarRenderer,
|
||||
private val messageColorProvider: MessageColorProvider,
|
||||
private val avatarSizeProvider: AvatarSizeProvider,
|
||||
private val stringProvider: StringProvider,
|
||||
private val emojiCompatFontProvider: EmojiCompatFontProvider) {
|
||||
|
||||
fun create(messageContent: Any?,
|
||||
|
@ -53,6 +56,7 @@ class MessageItemAttributesFactory @Inject constructor(
|
|||
threadCallback = callback,
|
||||
readReceiptsCallback = callback,
|
||||
emojiTypeFace = emojiCompatFontProvider.typeface,
|
||||
decryptionErrorMessage = stringProvider.getString(R.string.encrypted_message),
|
||||
threadDetails = threadDetails
|
||||
)
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
attributes.threadDetails?.let { threadDetails ->
|
||||
holder.threadSummaryConstraintLayout.isVisible = threadDetails.isRootThread
|
||||
holder.threadSummaryCounterTextView.text = threadDetails.numberOfThreads.toString()
|
||||
holder.threadSummaryInfoTextView.text = threadDetails.threadSummaryLatestTextMessage
|
||||
holder.threadSummaryInfoTextView.text = threadDetails.threadSummaryLatestTextMessage ?: attributes.decryptionErrorMessage
|
||||
|
||||
val userId = threadDetails.threadSummarySenderInfo?.userId ?: return@let
|
||||
val displayName = threadDetails.threadSummarySenderInfo?.displayName
|
||||
|
@ -185,6 +185,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
val threadCallback: TimelineEventController.ThreadCallback? = null,
|
||||
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,
|
||||
val emojiTypeFace: Typeface? = null,
|
||||
val decryptionErrorMessage: String? = null,
|
||||
val threadDetails: ThreadDetails? = null
|
||||
) : AbsBaseMessageItem.Attributes {
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
package im.vector.app.features.home.room.threads.list.viewmodel
|
||||
|
||||
import com.airbnb.epoxy.EpoxyController
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.date.DateFormatKind
|
||||
import im.vector.app.core.date.VectorDateFormatter
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.threads.list.model.threadList
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
|
@ -28,6 +30,7 @@ import javax.inject.Inject
|
|||
|
||||
class ThreadListController @Inject constructor(
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val stringProvider: StringProvider,
|
||||
private val dateFormatter: VectorDateFormatter
|
||||
) : EpoxyController() {
|
||||
|
||||
|
@ -56,6 +59,7 @@ class ThreadListController @Inject constructor(
|
|||
}
|
||||
?.forEach { timelineEvent ->
|
||||
val date = dateFormatter.format(timelineEvent.root.threadDetails?.lastMessageTimestamp, DateFormatKind.ROOM_LIST)
|
||||
val decryptionErrorMessage = stringProvider.getString(R.string.encrypted_message)
|
||||
threadList {
|
||||
id(timelineEvent.eventId)
|
||||
avatarRenderer(host.avatarRenderer)
|
||||
|
@ -64,8 +68,8 @@ class ThreadListController @Inject constructor(
|
|||
date(date)
|
||||
rootMessageDeleted(timelineEvent.root.isRedacted())
|
||||
threadNotificationState(timelineEvent.root.threadDetails?.threadNotificationState ?: ThreadNotificationState.NO_NEW_MESSAGE)
|
||||
rootMessage(timelineEvent.root.getDecryptedTextSummary())
|
||||
lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage.orEmpty())
|
||||
rootMessage(timelineEvent.root.getDecryptedTextSummary() ?: decryptionErrorMessage)
|
||||
lastMessage(timelineEvent.root.threadDetails?.threadSummaryLatestTextMessage ?: decryptionErrorMessage)
|
||||
lastMessageCounter(timelineEvent.root.threadDetails?.numberOfThreads.toString())
|
||||
lastMessageMatrixItem(timelineEvent.root.threadDetails?.threadSummarySenderInfo?.toMatrixItem())
|
||||
itemClickListener {
|
||||
|
|
Loading…
Reference in a new issue