Change rendering of notices to also allow formating
Change-Id: I49202fc3c8b7ea62c0e1fe1672f4fe590e33c784
This commit is contained in:
parent
e6b6bbc277
commit
daa20e629e
|
@ -72,6 +72,7 @@ import org.commonmark.node.Document
|
|||
import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||
|
@ -95,6 +96,7 @@ import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
|||
import org.matrix.android.sdk.api.util.MimeTypes
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageItemFactory @Inject constructor(
|
||||
|
@ -557,13 +559,36 @@ class MessageItemFactory @Inject constructor(
|
|||
informationData: MessageInformationData,
|
||||
highlight: Boolean,
|
||||
callback: TimelineEventController.Callback?,
|
||||
attributes: AbsMessageItem.Attributes): MessageTextItem? {
|
||||
attrs: AbsMessageItem.Attributes): VectorEpoxyModel<*>? {
|
||||
val attributes = attrs.copy(isNotice = true)
|
||||
|
||||
// We might want to use the normal text rendering in the future as following (but need to
|
||||
// ensure that notices are easily told apart also from code, ... formatted messages).
|
||||
// Maybe, instead of text coloring, we can come up with some other indicator that catches all cases automatically?
|
||||
/*
|
||||
val noticeAsTextContent = messageContent.toContent().toModel<MessageTextContent>()
|
||||
if (noticeAsTextContent != null && false) {
|
||||
return buildItemForTextContent(
|
||||
noticeAsTextContent,
|
||||
informationData,
|
||||
highlight,
|
||||
callback,
|
||||
attributes
|
||||
)
|
||||
}
|
||||
Timber.w("Could not parse notice as text item, using legacy fallback")
|
||||
*/
|
||||
|
||||
val htmlBody = messageContent.getHtmlBody()
|
||||
// SchildiChat likes to not overwrite message formatting for notices, compared to upstream
|
||||
val formattedBody = htmlBody
|
||||
/*
|
||||
val formattedBody = span {
|
||||
text = htmlBody
|
||||
textColor = colorProvider.getColorFromAttribute(R.attr.vctr_content_secondary)
|
||||
textStyle = "italic"
|
||||
}
|
||||
*/
|
||||
|
||||
val canUseTextFuture = spanUtils.canUseTextFuture(htmlBody)
|
||||
val message = formattedBody.linkify(callback)
|
||||
|
|
|
@ -268,6 +268,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
override val reactionPillCallback: TimelineEventController.ReactionPillCallback? = null,
|
||||
val avatarCallback: TimelineEventController.AvatarCallback? = null,
|
||||
override val readReceiptsCallback: TimelineEventController.ReadReceiptsCallback? = null,
|
||||
val isNotice: Boolean = false,
|
||||
val emojiTypeFace: Typeface? = null
|
||||
) : AbsBaseMessageItem.Attributes {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package im.vector.app.features.home.room.detail.timeline.item
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.text.TextUtils
|
||||
import android.text.method.MovementMethod
|
||||
import android.widget.LinearLayout
|
||||
|
@ -27,6 +28,7 @@ import com.airbnb.epoxy.EpoxyAttribute
|
|||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.ui.views.FooteredTextView
|
||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||
import im.vector.app.features.home.room.detail.timeline.tools.findPillsAndProcess
|
||||
|
@ -118,6 +120,9 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
|
|||
renderSendState(holder.messageView, holder.messageView)
|
||||
holder.messageView.onClick(attributes.itemClickListener)
|
||||
holder.messageView.setOnLongClickListener(attributes.itemLongClickListener)
|
||||
holder.messageView.setTextColor(ColorProvider(holder.messageView.context).getColorFromAttribute(
|
||||
if (attributes.isNotice) R.attr.vctr_content_secondary else R.attr.vctr_content_primary
|
||||
))
|
||||
|
||||
if (canUseTextFuture) {
|
||||
holder.messageView.setTextFuture(textFuture)
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="0dp"
|
||||
android:textColor="?vctr_content_primary"
|
||||
android:layout_gravity="left"
|
||||
tools:textColor="?vctr_content_primary"
|
||||
tools:text="@sample/messages.json/data/message"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
|
|
Loading…
Reference in New Issue