Handle click on encryption message

This commit is contained in:
Benoit Marty 2019-06-18 12:56:08 +02:00
parent 5bfa67b442
commit 7fe662598b
3 changed files with 7 additions and 6 deletions

View File

@ -23,6 +23,7 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.matrix.android.internal.crypto.model.event.EncryptionEventContent
import im.vector.riotredesign.R
import im.vector.riotredesign.core.resources.StringProvider
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController
import im.vector.riotredesign.features.home.room.detail.timeline.helper.senderAvatar
import im.vector.riotredesign.features.home.room.detail.timeline.helper.senderName
import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageInformationData
@ -31,7 +32,8 @@ import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem
class EncryptionItemFactory(private val stringProvider: StringProvider) {
fun create(event: TimelineEvent): NoticeItem? {
fun create(event: TimelineEvent,
callback: TimelineEventController.BaseCallback?): NoticeItem? {
val text = buildNoticeText(event.root, event.senderName) ?: return null
val informationData = MessageInformationData(
eventId = event.root.eventId ?: "?",
@ -44,6 +46,7 @@ class EncryptionItemFactory(private val stringProvider: StringProvider) {
return NoticeItem_()
.noticeText(text)
.informationData(informationData)
.baseCallback(callback)
}
private fun buildNoticeText(event: Event, senderName: String?): CharSequence? {
@ -52,7 +55,7 @@ class EncryptionItemFactory(private val stringProvider: StringProvider) {
val content = event.content.toModel<EncryptionEventContent>() ?: return null
stringProvider.getString(R.string.notice_end_to_end, senderName, content.algorithm)
}
else -> null
else -> null
}
}

View File

@ -52,7 +52,7 @@ class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
EventType.CALL_ANSWER -> noticeItemFactory.create(event, callback)
// Crypto
EventType.ENCRYPTION -> encryptionItemFactory.create(event)
EventType.ENCRYPTION -> encryptionItemFactory.create(event, callback)
EventType.ENCRYPTED -> encryptedItemFactory.create(event, nextEvent, callback)
// Unhandled event types (yet)

View File

@ -38,11 +38,9 @@ abstract class NoticeItem : BaseEventItem<NoticeItem.Holder>() {
var baseCallback: TimelineEventController.BaseCallback? = null
private var longClickListener = View.OnLongClickListener {
baseCallback?.onEventLongClicked(informationData, null, it)
baseCallback != null
return@OnLongClickListener baseCallback?.onEventLongClicked(informationData, null, it) == true
}
override fun bind(holder: Holder) {
super.bind(holder)
holder.noticeTextView.text = noticeText