Single-side bubbles don't need margin to other side

The margin is there for dual-side bubbles, so the bubbles are more
connected to the same side of the sender avatar.
For single-side bubbles, this is a waste of space, so remove it for this
scenario.

Change-Id: Ib70cd0b1d30c2a8dbb356c80bd12a8310dceda8c
This commit is contained in:
SpiritCroc 2020-11-20 09:44:53 +01:00
parent e1cb8c520a
commit ac713124e7
2 changed files with 9 additions and 5 deletions

View File

@ -287,8 +287,12 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
return attributes.informationData.sentByMe
}
open fun getBubbleMargin(density: Float, reverseBubble: Boolean): Int {
return round(96*density).toInt()
open fun getBubbleMargin(density: Float, bubbleStyle: String, reverseBubble: Boolean): Int {
return when (bubbleStyle) {
BubbleThemeUtils.BUBBLE_STYLE_START,
BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN -> 0
else -> round(96*density).toInt()
}
}
open fun allowFooterOverlay(holder: H): Boolean {
@ -353,11 +357,11 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
val density = bubbleView.resources.displayMetrics.density
// TODO 96 = 2 * avatar size?
if (reverseBubble) {
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginStart = getBubbleMargin(density, reverseBubble)
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginStart = getBubbleMargin(density, bubbleStyle, reverseBubble)
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = 0
} else {
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginStart = 0
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = getBubbleMargin(density, reverseBubble)
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = getBubbleMargin(density, bubbleStyle, reverseBubble)
}
/*
(bubbleView.layoutParams as RelativeLayout.LayoutParams).marginStart = round(20*density).toInt()

View File

@ -97,7 +97,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
return true
}
override fun getBubbleMargin(density: Float, reverseBubble: Boolean): Int {
override fun getBubbleMargin(density: Float, bubbleStyle: String, reverseBubble: Boolean): Int {
return 0
}