diff --git a/vector/src/main/java/im/vector/app/core/ui/views/BubbleDependentView.kt b/vector/src/main/java/im/vector/app/core/ui/views/BubbleDependentView.kt index 68c4243add..ab9f96a707 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/BubbleDependentView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/BubbleDependentView.kt @@ -7,27 +7,6 @@ import im.vector.app.features.themes.BubbleThemeUtils interface BubbleDependentView { - fun updateMessageBubble(context: Context, holder: H) { - val bubbleStyleSetting = BubbleThemeUtils.getBubbleStyle(context) - val bubbleStyle = when { - messageBubbleAllowed(context) -> { - bubbleStyleSetting - } - bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_BOTH && pseudoBubbleAllowed() -> { - BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN - } - bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_START && pseudoBubbleAllowed() -> { - BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN - } - else -> { - BubbleThemeUtils.BUBBLE_STYLE_NONE - } - } - val reverseBubble = shouldReverseBubble() && BubbleThemeUtils.drawsDualSide(bubbleStyle) - - setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble) - } - fun messageBubbleAllowed(context: Context): Boolean { return false } @@ -41,15 +20,38 @@ interface BubbleDependentView { } fun setBubbleLayout(holder: H, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean) +} - fun setFlatRtl(layout: ViewGroup, direction: Int, childDirection: Int, depth: Int = 1) { - layout.layoutDirection = direction - for (child in layout.children) { - if (depth > 1 && child is ViewGroup) { - setFlatRtl(child, direction, childDirection, depth-1) - } else { - child.layoutDirection = childDirection - } +// This function belongs to BubbleDependentView, but turned out to raise a NoSuchMethodError since recently +// when called from an onImageSizeUpdated listener +fun updateMessageBubble(context: Context, view: BubbleDependentView, holder: H) { + val bubbleStyleSetting = BubbleThemeUtils.getBubbleStyle(context) + val bubbleStyle = when { + view.messageBubbleAllowed(context) -> { + bubbleStyleSetting + } + bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_BOTH && view.pseudoBubbleAllowed() -> { + BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN + } + bubbleStyleSetting == BubbleThemeUtils.BUBBLE_STYLE_START && view.pseudoBubbleAllowed() -> { + BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN + } + else -> { + BubbleThemeUtils.BUBBLE_STYLE_NONE + } + } + val reverseBubble = view.shouldReverseBubble() && BubbleThemeUtils.drawsDualSide(bubbleStyle) + + view.setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble) +} + +fun setFlatRtl(layout: ViewGroup, direction: Int, childDirection: Int, depth: Int = 1) { + layout.layoutDirection = direction + for (child in layout.children) { + if (depth > 1 && child is ViewGroup) { + setFlatRtl(child, direction, childDirection, depth-1) + } else { + child.layoutDirection = childDirection } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt index 8c4e9632da..9c356b09be 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsMessageItem.kt @@ -39,6 +39,7 @@ import im.vector.app.R import im.vector.app.core.epoxy.ClickListener import im.vector.app.core.epoxy.onClick import im.vector.app.core.ui.views.SendStateImageView +import im.vector.app.core.ui.views.setFlatRtl 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 diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BaseEventItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BaseEventItem.kt index 1e7a01c384..66672008c6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BaseEventItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BaseEventItem.kt @@ -32,6 +32,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.platform.CheckableView import im.vector.app.core.ui.views.BubbleDependentView +import im.vector.app.core.ui.views.updateMessageBubble import im.vector.app.core.utils.DimensionConverter import im.vector.app.features.themes.BubbleThemeUtils @@ -129,4 +130,8 @@ abstract class BaseEventItem : VectorEpoxyModel */ } + + fun updateMessageBubble(context: Context, holder: H) { + return updateMessageBubble(context, this, holder) + } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/ReadReceiptsItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/ReadReceiptsItem.kt index 3510316f7b..1483853a99 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/ReadReceiptsItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/ReadReceiptsItem.kt @@ -16,6 +16,7 @@ package im.vector.app.features.home.room.detail.timeline.item +import android.content.Context import android.view.Gravity import android.view.View import android.widget.FrameLayout @@ -30,6 +31,8 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.onClick import im.vector.app.core.ui.views.BubbleDependentView import im.vector.app.core.ui.views.ReadReceiptsView +import im.vector.app.core.ui.views.setFlatRtl +import im.vector.app.core.ui.views.updateMessageBubble import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.themes.BubbleThemeUtils import timber.log.Timber @@ -105,4 +108,9 @@ abstract class ReadReceiptsItem : EpoxyModelWithHolder( // Also set rtl to have members fill from the natural side setFlatRtl(holder.readReceiptsView, if (dualBubbles) reverseDirection else defaultDirection, defaultDirection) } + + fun updateMessageBubble(context: Context, holder: Holder) { + return updateMessageBubble(context, this, holder) + } + }