Reduce reserved space for dual-side bubbles
The reason for this being two times the reserved avatar size was aligning it to the right side, even when having avatars on both sides. By now, we hide the user's avatar, so one times the reserved avatar size is enough. For landscape tablets, don't reduce it, as we have enough screen estate. Change-Id: I526d11e891612627418fe31bb40c3c131ea18c4c
This commit is contained in:
parent
ac713124e7
commit
8a06ad5c89
|
@ -18,6 +18,7 @@ package im.vector.app.features.home.room.detail.timeline.item
|
|||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Typeface
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
|
@ -287,11 +288,11 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
return attributes.informationData.sentByMe
|
||||
}
|
||||
|
||||
open fun getBubbleMargin(density: Float, bubbleStyle: String, reverseBubble: Boolean): Int {
|
||||
open fun getBubbleMargin(resources: Resources, bubbleStyle: String, reverseBubble: Boolean): Int {
|
||||
return when (bubbleStyle) {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_START,
|
||||
BubbleThemeUtils.BUBBLE_STYLE_START_HIDDEN -> 0
|
||||
else -> round(96*density).toInt()
|
||||
else -> resources.getDimensionPixelSize(R.dimen.dual_bubble_other_side_margin)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,6 +322,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
when (bubbleStyle) {
|
||||
BubbleThemeUtils.BUBBLE_STYLE_NONE -> {
|
||||
bubbleView.background = null
|
||||
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginStart = 0
|
||||
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = 0
|
||||
/*
|
||||
(bubbleView.layoutParams as RelativeLayout.LayoutParams).marginStart = 0
|
||||
|
@ -355,13 +357,12 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
shortPadding = 0//if (attributes.informationData.showInformation && !hideSenderInformation()) { 8 } else { 0 }
|
||||
}
|
||||
val density = bubbleView.resources.displayMetrics.density
|
||||
// TODO 96 = 2 * avatar size?
|
||||
if (reverseBubble) {
|
||||
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginStart = getBubbleMargin(density, bubbleStyle, reverseBubble)
|
||||
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginStart = getBubbleMargin(bubbleView.resources, 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, bubbleStyle, reverseBubble)
|
||||
(bubbleView.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = getBubbleMargin(bubbleView.resources, bubbleStyle, reverseBubble)
|
||||
}
|
||||
/*
|
||||
(bubbleView.layoutParams as RelativeLayout.LayoutParams).marginStart = round(20*density).toInt()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package im.vector.app.features.home.room.detail.timeline.item
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
|
@ -97,7 +98,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
|
|||
return true
|
||||
}
|
||||
|
||||
override fun getBubbleMargin(density: Float, bubbleStyle: String, reverseBubble: Boolean): Int {
|
||||
override fun getBubbleMargin(resources: Resources, bubbleStyle: String, reverseBubble: Boolean): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<dimen name="dual_bubble_other_side_margin">96dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<dimen name="dual_bubble_other_side_margin">48dp</dimen>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue