Make pseudo-bubbles align properly with bubbles again

Change-Id: Ib841827f7df8712eb35c126a94fb1554d1182c6f
This commit is contained in:
SpiritCroc 2021-12-26 10:50:18 +01:00
parent 6a9b6e38e4
commit 127e151c41
2 changed files with 9 additions and 8 deletions

View File

@ -456,8 +456,8 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
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 // Padding for bubble content: long for side with tail, short for other sides
val longPadding: Int val longPaddingDp: Int
val shortPadding: Int val shortPaddingDp: Int
if (BubbleThemeUtils.drawsActualBubbles(bubbleStyle)) { if (BubbleThemeUtils.drawsActualBubbles(bubbleStyle)) {
val bubbleRes = if (attributes.informationData.showInformation) { // tail val bubbleRes = if (attributes.informationData.showInformation) { // tail
if (reverseBubble) { // outgoing if (reverseBubble) { // outgoing
@ -473,11 +473,11 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
} }
} }
bubbleView.setBackgroundResource(bubbleRes) bubbleView.setBackgroundResource(bubbleRes)
longPadding = 20 longPaddingDp = bubbleView.resources.getDimensionPixelSize(R.dimen.sc_bubble_inner_padding_long_side)
shortPadding = 8 shortPaddingDp = bubbleView.resources.getDimensionPixelSize(R.dimen.sc_bubble_inner_padding_short_side)
} else { } else {
longPadding = 10 longPaddingDp = bubbleView.resources.getDimensionPixelSize(R.dimen.sc_bubble_tail_size)
shortPadding = 0//if (attributes.informationData.showInformation && !hideSenderInformation()) { 8 } else { 0 } shortPaddingDp = 0//if (attributes.informationData.showInformation && !hideSenderInformation()) { 8 } else { 0 }
} }
val density = bubbleView.resources.displayMetrics.density val density = bubbleView.resources.displayMetrics.density
if (reverseBubble != defaultRtl) { if (reverseBubble != defaultRtl) {
@ -493,8 +493,6 @@ 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()
*/ */
val shortPaddingDp = round(shortPadding * density).toInt()
val longPaddingDp = round(longPadding * density).toInt()
if (reverseBubble != defaultRtl) { if (reverseBubble != defaultRtl) {
// Use left/right instead of start/end: bubbleView is always LTR // Use left/right instead of start/end: bubbleView is always LTR
bubbleView.setPadding( bubbleView.setPadding(

View File

@ -13,5 +13,8 @@
<dimen name="sc_bubble_radius_in_tail">3dp</dimen> <dimen name="sc_bubble_radius_in_tail">3dp</dimen>
<dimen name="sc_bubble_tail_size">12dp</dimen> <dimen name="sc_bubble_tail_size">12dp</dimen>
<dimen name="sc_bubble_stroke">2dp</dimen> <dimen name="sc_bubble_stroke">2dp</dimen>
<dimen name="sc_bubble_inner_padding_short_side">8dp</dimen>
<!-- long_side = short_side + tail -->
<dimen name="sc_bubble_inner_padding_long_side">20dp</dimen>
</resources> </resources>