Update after Ganfra's review

This commit is contained in:
Benoit Marty 2019-10-15 11:02:16 +02:00
parent 116d569fa8
commit e4d0e0b0bf
3 changed files with 9 additions and 9 deletions

View file

@ -53,6 +53,7 @@ import javax.inject.Inject
class MessageItemFactory @Inject constructor( class MessageItemFactory @Inject constructor(
private val colorProvider: ColorProvider, private val colorProvider: ColorProvider,
private val dimensionConverter: DimensionConverter,
private val timelineMediaSizeProvider: TimelineMediaSizeProvider, private val timelineMediaSizeProvider: TimelineMediaSizeProvider,
private val htmlRenderer: Lazy<EventHtmlRenderer>, private val htmlRenderer: Lazy<EventHtmlRenderer>,
private val stringProvider: StringProvider, private val stringProvider: StringProvider,
@ -243,7 +244,7 @@ class MessageItemFactory @Inject constructor(
return MessageTextItem_() return MessageTextItem_()
.apply { .apply {
if (informationData.hasBeenEdited) { if (informationData.hasBeenEdited) {
val spannable = annotateWithEdited(linkifiedBody, callback, attributes.dimensionConverter, informationData) val spannable = annotateWithEdited(linkifiedBody, callback, informationData)
message(spannable) message(spannable)
} else { } else {
message(linkifiedBody) message(linkifiedBody)
@ -260,7 +261,6 @@ class MessageItemFactory @Inject constructor(
private fun annotateWithEdited(linkifiedBody: CharSequence, private fun annotateWithEdited(linkifiedBody: CharSequence,
callback: TimelineEventController.Callback?, callback: TimelineEventController.Callback?,
dimensionConverter: DimensionConverter,
informationData: MessageInformationData): SpannableStringBuilder { informationData: MessageInformationData): SpannableStringBuilder {
val spannable = SpannableStringBuilder() val spannable = SpannableStringBuilder()
spannable.append(linkifiedBody) spannable.append(linkifiedBody)
@ -276,7 +276,12 @@ class MessageItemFactory @Inject constructor(
Spanned.SPAN_INCLUSIVE_EXCLUSIVE) Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
// Note: text size is set to 14sp // Note: text size is set to 14sp
spannable.setSpan(AbsoluteSizeSpan(dimensionConverter.spToPx(13)), editStart, editEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) spannable.setSpan(
AbsoluteSizeSpan(dimensionConverter.spToPx(13)),
editStart,
editEnd,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
spannable.setSpan(object : ClickableSpan() { spannable.setSpan(object : ClickableSpan() {
override fun onClick(widget: View?) { override fun onClick(widget: View?) {
callback?.onEditedDecorationClicked(informationData) callback?.onEditedDecorationClicked(informationData)
@ -326,7 +331,7 @@ class MessageItemFactory @Inject constructor(
return MessageTextItem_() return MessageTextItem_()
.apply { .apply {
if (informationData.hasBeenEdited) { if (informationData.hasBeenEdited) {
val spannable = annotateWithEdited(message, callback, attributes.dimensionConverter, informationData) val spannable = annotateWithEdited(message, callback, informationData)
message(spannable) message(spannable)
} else { } else {
message(message) message(message)

View file

@ -22,7 +22,6 @@ import im.vector.matrix.android.api.session.room.model.message.MessageContent
import im.vector.riotx.EmojiCompatFontProvider import im.vector.riotx.EmojiCompatFontProvider
import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.utils.DebouncedClickListener import im.vector.riotx.core.utils.DebouncedClickListener
import im.vector.riotx.core.utils.DimensionConverter
import im.vector.riotx.features.home.AvatarRenderer import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
import im.vector.riotx.features.home.room.detail.timeline.item.AbsMessageItem import im.vector.riotx.features.home.room.detail.timeline.item.AbsMessageItem
@ -33,7 +32,6 @@ class MessageItemAttributesFactory @Inject constructor(
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val colorProvider: ColorProvider, private val colorProvider: ColorProvider,
private val avatarSizeProvider: AvatarSizeProvider, private val avatarSizeProvider: AvatarSizeProvider,
private val dimensionConverter: DimensionConverter,
private val emojiCompatFontProvider: EmojiCompatFontProvider) { private val emojiCompatFontProvider: EmojiCompatFontProvider) {
fun create(messageContent: MessageContent?, fun create(messageContent: MessageContent?,
@ -44,7 +42,6 @@ class MessageItemAttributesFactory @Inject constructor(
informationData = informationData, informationData = informationData,
avatarRenderer = avatarRenderer, avatarRenderer = avatarRenderer,
colorProvider = colorProvider, colorProvider = colorProvider,
dimensionConverter = dimensionConverter,
itemLongClickListener = View.OnLongClickListener { view -> itemLongClickListener = View.OnLongClickListener { view ->
callback?.onEventLongClicked(informationData, messageContent, view) ?: false callback?.onEventLongClicked(informationData, messageContent, view) ?: false
}, },

View file

@ -29,7 +29,6 @@ import im.vector.riotx.R
import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.ui.views.ReadMarkerView import im.vector.riotx.core.ui.views.ReadMarkerView
import im.vector.riotx.core.utils.DebouncedClickListener import im.vector.riotx.core.utils.DebouncedClickListener
import im.vector.riotx.core.utils.DimensionConverter
import im.vector.riotx.features.home.AvatarRenderer import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
import im.vector.riotx.features.reactions.widget.ReactionButton import im.vector.riotx.features.reactions.widget.ReactionButton
@ -173,7 +172,6 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : BaseEventItem<H>() {
val informationData: MessageInformationData, val informationData: MessageInformationData,
val avatarRenderer: AvatarRenderer, val avatarRenderer: AvatarRenderer,
val colorProvider: ColorProvider, val colorProvider: ColorProvider,
val dimensionConverter: DimensionConverter,
val itemLongClickListener: View.OnLongClickListener? = null, val itemLongClickListener: View.OnLongClickListener? = null,
val itemClickListener: View.OnClickListener? = null, val itemClickListener: View.OnClickListener? = null,
val memberClickListener: View.OnClickListener? = null, val memberClickListener: View.OnClickListener? = null,