mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-23 01:20:35 +03:00
Fix incomplete reactions bubble alignment
Related to:
fa5acb49c
Align reactions better with message bubbles
We do not want to change the alignment for views that draw actual
bubbles, but also pseudo-bubbles, such as media items.
Change-Id: Ie6e0e8d9145239d284ee4e35987459a9184e48ff
This commit is contained in:
parent
b6f2ca85f7
commit
1a6d8398aa
2 changed files with 40 additions and 20 deletions
|
@ -28,7 +28,9 @@ 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.MessageColorProvider
|
||||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||||
import im.vector.app.features.reactions.widget.ReactionButton
|
import im.vector.app.features.reactions.widget.ReactionButton
|
||||||
|
import im.vector.app.features.themes.BubbleThemeUtils
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
|
import kotlin.math.round
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base timeline item with reactions and read receipts.
|
* Base timeline item with reactions and read receipts.
|
||||||
|
@ -121,6 +123,44 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
|
||||||
failureIndicator?.isVisible = baseAttributes.informationData.sendState.hasFailed()
|
failureIndicator?.isVisible = baseAttributes.informationData.sendState.hasFailed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setBubbleLayout(holder: H, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean) {
|
||||||
|
super.setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble)
|
||||||
|
|
||||||
|
// ATTENTION: we go over the bubbleStyleSetting here: this might differ from the effective bubbleStyle
|
||||||
|
// for this view class! We want to use the setting to do some uniform alignments for all views though.
|
||||||
|
when (bubbleStyleSetting) {
|
||||||
|
BubbleThemeUtils.BUBBLE_STYLE_START,
|
||||||
|
BubbleThemeUtils.BUBBLE_STYLE_BOTH,
|
||||||
|
BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN,
|
||||||
|
BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN -> {
|
||||||
|
val density = holder.informationBottom.resources.displayMetrics.density
|
||||||
|
// Padding for views that align with the bubble (should be roughly the bubble tail width)
|
||||||
|
val bubbleStartAlignWidth = round(12 * density).toInt()
|
||||||
|
if (reverseBubble) {
|
||||||
|
// Align reactions container to bubble
|
||||||
|
holder.informationBottom.setPaddingRelative(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
bubbleStartAlignWidth,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// Align reactions container to bubble
|
||||||
|
holder.informationBottom.setPaddingRelative(
|
||||||
|
bubbleStartAlignWidth,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// No alignment padding for reactions required
|
||||||
|
holder.informationBottom.setPaddingRelative(0, 0, 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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 informationBottom by bind<ViewGroup>(R.id.informationBottom)
|
||||||
|
|
|
@ -329,8 +329,6 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
// Padding for bubble content: long for side with tail, short for other sides
|
// 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)
|
||||||
|
@ -346,11 +344,9 @@ 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) {
|
||||||
|
@ -367,7 +363,6 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
*/
|
*/
|
||||||
val shortPaddingDp = round(shortPadding * density).toInt()
|
val shortPaddingDp = round(shortPadding * density).toInt()
|
||||||
val longPaddingDp = round(longPadding * density).toInt()
|
val longPaddingDp = round(longPadding * density).toInt()
|
||||||
val alignPaddingDp = round(alignPadding * density).toInt()
|
|
||||||
if (reverseBubble) {
|
if (reverseBubble) {
|
||||||
bubbleView.setPaddingRelative(
|
bubbleView.setPaddingRelative(
|
||||||
shortPaddingDp,
|
shortPaddingDp,
|
||||||
|
@ -375,13 +370,6 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
longPaddingDp,
|
longPaddingDp,
|
||||||
shortPaddingDp
|
shortPaddingDp
|
||||||
)
|
)
|
||||||
// Align reactions container to bubble
|
|
||||||
holder.informationBottom.setPaddingRelative(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
alignPaddingDp,
|
|
||||||
0
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
bubbleView.setPaddingRelative(
|
bubbleView.setPaddingRelative(
|
||||||
longPaddingDp,
|
longPaddingDp,
|
||||||
|
@ -389,13 +377,6 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
shortPaddingDp,
|
shortPaddingDp,
|
||||||
shortPaddingDp
|
shortPaddingDp
|
||||||
)
|
)
|
||||||
// Align reactions container to bubble
|
|
||||||
holder.informationBottom.setPaddingRelative(
|
|
||||||
alignPaddingDp,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentInBubble) {
|
if (contentInBubble) {
|
||||||
|
@ -472,7 +453,6 @@ 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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue