Align reactions better with message bubbles

Change-Id: I128a23009b1636ce10619e17fccc507fc39028d4
This commit is contained in:
SpiritCroc 2020-12-21 18:29:48 +01:00
parent 794325f74e
commit fa5acb49ca
2 changed files with 32 additions and 9 deletions

View File

@ -123,6 +123,7 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
abstract class Holder(@IdRes stubId: Int) : BaseEventItem.BaseHolder(stubId) { abstract class Holder(@IdRes stubId: Int) : BaseEventItem.BaseHolder(stubId) {
val reactionsContainer by bind<ViewGroup>(R.id.reactionsContainer) val reactionsContainer by bind<ViewGroup>(R.id.reactionsContainer)
val informationBottom by bind<ViewGroup>(R.id.informationBottom)
val e2EDecorationView by bind<ImageView>(R.id.messageE2EDecoration) val e2EDecorationView by bind<ImageView>(R.id.messageE2EDecoration)
} }

View File

@ -326,8 +326,11 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
BubbleThemeUtils.BUBBLE_STYLE_BOTH, BubbleThemeUtils.BUBBLE_STYLE_BOTH,
BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN, BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN,
BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN -> { BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN -> {
// Padding for bubble content: long for side with tail, short for other sides
val longPadding: Int val longPadding: Int
val shortPadding: Int val shortPadding: Int
// Padding for other views that align with the bubble (should be roughly the bubble tail width
var alignPadding: Int
if (BubbleThemeUtils.drawsActualBubbles(bubbleStyle)) { if (BubbleThemeUtils.drawsActualBubbles(bubbleStyle)) {
if (attributes.informationData.showInformation) { if (attributes.informationData.showInformation) {
bubbleView.setBackgroundResource(if (reverseBubble) R.drawable.msg_bubble_outgoing else R.drawable.msg_bubble_incoming) bubbleView.setBackgroundResource(if (reverseBubble) R.drawable.msg_bubble_outgoing else R.drawable.msg_bubble_incoming)
@ -343,9 +346,11 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
bubbleView.backgroundTintList = tintColor bubbleView.backgroundTintList = tintColor
longPadding = 20 longPadding = 20
shortPadding = 8 shortPadding = 8
alignPadding = 12
} else { } else {
longPadding = 10 longPadding = 10
shortPadding = 0//if (attributes.informationData.showInformation && !hideSenderInformation()) { 8 } else { 0 } shortPadding = 0//if (attributes.informationData.showInformation && !hideSenderInformation()) { 8 } else { 0 }
alignPadding = 0
} }
val density = bubbleView.resources.displayMetrics.density val density = bubbleView.resources.displayMetrics.density
if (reverseBubble) { if (reverseBubble) {
@ -360,20 +365,36 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
(bubbleView.layoutParams as RelativeLayout.LayoutParams).topMargin = round(8*density).toInt() (bubbleView.layoutParams as RelativeLayout.LayoutParams).topMargin = round(8*density).toInt()
(bubbleView.layoutParams as RelativeLayout.LayoutParams).bottomMargin = round(8*density).toInt() (bubbleView.layoutParams as RelativeLayout.LayoutParams).bottomMargin = round(8*density).toInt()
*/ */
// TODO padding? val shortPaddingDp = round(shortPadding * density).toInt()
val longPaddingDp = round(longPadding * density).toInt()
val alignPaddingDp = round(alignPadding * density).toInt()
if (reverseBubble) { if (reverseBubble) {
bubbleView.setPaddingRelative( bubbleView.setPaddingRelative(
round(shortPadding * density).toInt(), shortPaddingDp,
round(shortPadding * density).toInt(), shortPaddingDp,
round(longPadding * density).toInt(), longPaddingDp,
round(shortPadding * density).toInt() shortPaddingDp
)
// Align reactions container to bubble
holder.informationBottom.setPaddingRelative(
0,
0,
alignPaddingDp,
0
) )
} else { } else {
bubbleView.setPaddingRelative( bubbleView.setPaddingRelative(
round(longPadding * density).toInt(), longPaddingDp,
round(shortPadding * density).toInt(), shortPaddingDp,
round(shortPadding * density).toInt(), shortPaddingDp,
round(shortPadding * density).toInt() shortPaddingDp
)
// Align reactions container to bubble
holder.informationBottom.setPaddingRelative(
alignPaddingDp,
0,
0,
0
) )
} }
@ -451,6 +472,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
(bubbleView.layoutParams as RelativeLayout.LayoutParams).bottomMargin = 0 (bubbleView.layoutParams as RelativeLayout.LayoutParams).bottomMargin = 0
*/ */
bubbleView.setPadding(0, 0, 0, 0) bubbleView.setPadding(0, 0, 0, 0)
holder.informationBottom.setPadding(0, 0, 0, 0)
} }
} }