mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Merge branch 'feature/emote' into develop
This commit is contained in:
commit
f36bec7176
2 changed files with 25 additions and 8 deletions
|
@ -23,6 +23,7 @@ import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
|
||||||
import im.vector.matrix.android.api.session.events.model.EventType
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.android.api.session.events.model.toModel
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageContent
|
||||||
|
import im.vector.matrix.android.api.session.room.model.message.MessageEmoteContent
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
|
@ -67,6 +68,7 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
|
||||||
return when (messageContent) {
|
return when (messageContent) {
|
||||||
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
|
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
|
||||||
is MessageImageContent -> buildImageMessageItem(messageContent, informationData)
|
is MessageImageContent -> buildImageMessageItem(messageContent, informationData)
|
||||||
|
is MessageEmoteContent -> buildEmoteMessageItem(messageContent, informationData, callback)
|
||||||
else -> buildNotHandledMessageItem(messageContent)
|
else -> buildNotHandledMessageItem(messageContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,20 +100,34 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
callback: TimelineEventController.Callback?): MessageTextItem? {
|
callback: TimelineEventController.Callback?): MessageTextItem? {
|
||||||
|
|
||||||
val message = messageContent.body.let {
|
val message = linkifyBody(messageContent.body, callback)
|
||||||
val spannable = SpannableStringBuilder(it)
|
return MessageTextItem_()
|
||||||
MatrixLinkify.addLinks(spannable, object : MatrixPermalinkSpan.Callback {
|
.message(message)
|
||||||
override fun onUrlClicked(url: String) {
|
.informationData(informationData)
|
||||||
callback?.onUrlClicked(url)
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
Linkify.addLinks(spannable, Linkify.ALL)
|
private fun buildEmoteMessageItem(messageContent: MessageEmoteContent,
|
||||||
spannable
|
informationData: MessageInformationData,
|
||||||
|
callback: TimelineEventController.Callback?): MessageTextItem? {
|
||||||
|
|
||||||
|
val message = messageContent.body.let {
|
||||||
|
val formattedBody = "* ${informationData.memberName} $it"
|
||||||
|
linkifyBody(formattedBody, callback)
|
||||||
}
|
}
|
||||||
return MessageTextItem_()
|
return MessageTextItem_()
|
||||||
.message(message)
|
.message(message)
|
||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun linkifyBody(body: String, callback: TimelineEventController.Callback?): CharSequence {
|
||||||
|
val spannable = SpannableStringBuilder(body)
|
||||||
|
MatrixLinkify.addLinks(spannable, object : MatrixPermalinkSpan.Callback {
|
||||||
|
override fun onUrlClicked(url: String) {
|
||||||
|
callback?.onUrlClicked(url)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Linkify.addLinks(spannable, Linkify.ALL)
|
||||||
|
return spannable
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -109,6 +109,7 @@ internal class SyncThread(private val syncTask: SyncTask,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
|
Timber.e(failure)
|
||||||
if (failure !is Failure.NetworkConnection) {
|
if (failure !is Failure.NetworkConnection) {
|
||||||
// Wait 10s before retrying
|
// Wait 10s before retrying
|
||||||
sleep(RETRY_WAIT_TIME_MS)
|
sleep(RETRY_WAIT_TIME_MS)
|
||||||
|
|
Loading…
Reference in a new issue