Fix footer alignment in RTL layouts
Change-Id: I453fe81150cd7b2ed626b6e95898c1a3dd0b7110
This commit is contained in:
parent
707012ee5c
commit
7e4a0ddb5c
|
@ -497,14 +497,22 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We can't use end and start because of our weird layout RTL tricks
|
||||||
|
val alignEnd = if(defaultRtl) RelativeLayout.ALIGN_LEFT else RelativeLayout.ALIGN_RIGHT
|
||||||
|
val alignStart = if(defaultRtl) RelativeLayout.ALIGN_RIGHT else RelativeLayout.ALIGN_LEFT
|
||||||
|
val startOf = if(defaultRtl) RelativeLayout.RIGHT_OF else RelativeLayout.LEFT_OF
|
||||||
|
val endOf = if(defaultRtl) RelativeLayout.LEFT_OF else RelativeLayout.RIGHT_OF
|
||||||
|
|
||||||
val footerLayoutParams = holder.bubbleFootView.layoutParams as RelativeLayout.LayoutParams
|
val footerLayoutParams = holder.bubbleFootView.layoutParams as RelativeLayout.LayoutParams
|
||||||
var footerMarginStartDp = 4
|
var footerMarginStartDp = 4
|
||||||
var footerMarginEndDp = 1
|
var footerMarginEndDp = 1
|
||||||
if (allowFooterOverlay(holder)) {
|
if (allowFooterOverlay(holder)) {
|
||||||
footerLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.viewStubContainer)
|
footerLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.viewStubContainer)
|
||||||
footerLayoutParams.addRule(RelativeLayout.ALIGN_END, R.id.viewStubContainer)
|
footerLayoutParams.addRule(alignEnd, R.id.viewStubContainer)
|
||||||
|
footerLayoutParams.removeRule(alignStart)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.BELOW)
|
footerLayoutParams.removeRule(RelativeLayout.BELOW)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.END_OF)
|
footerLayoutParams.removeRule(endOf)
|
||||||
|
footerLayoutParams.removeRule(startOf)
|
||||||
if (needsFooterReservation(holder)) {
|
if (needsFooterReservation(holder)) {
|
||||||
// Remove style used when not having reserved space
|
// Remove style used when not having reserved space
|
||||||
removeFooterOverlayStyle(holder, density)
|
removeFooterOverlayStyle(holder, density)
|
||||||
|
@ -523,16 +531,20 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
when {
|
when {
|
||||||
allowFooterBelow(holder) -> {
|
allowFooterBelow(holder) -> {
|
||||||
footerLayoutParams.addRule(RelativeLayout.BELOW, R.id.viewStubContainer)
|
footerLayoutParams.addRule(RelativeLayout.BELOW, R.id.viewStubContainer)
|
||||||
footerLayoutParams.addRule(RelativeLayout.ALIGN_END, R.id.viewStubContainer)
|
footerLayoutParams.addRule(alignEnd, R.id.viewStubContainer)
|
||||||
|
footerLayoutParams.removeRule(alignStart)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.ALIGN_BOTTOM)
|
footerLayoutParams.removeRule(RelativeLayout.ALIGN_BOTTOM)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.END_OF)
|
footerLayoutParams.removeRule(endOf)
|
||||||
|
footerLayoutParams.removeRule(startOf)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.START_OF)
|
footerLayoutParams.removeRule(RelativeLayout.START_OF)
|
||||||
}
|
}
|
||||||
reverseBubble -> /* force footer on the left / at the start */ {
|
reverseBubble -> /* force footer on the left / at the start */ {
|
||||||
footerLayoutParams.addRule(RelativeLayout.START_OF, R.id.viewStubContainer)
|
footerLayoutParams.addRule(RelativeLayout.START_OF, R.id.viewStubContainer)
|
||||||
footerLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.viewStubContainer)
|
footerLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.viewStubContainer)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.ALIGN_END)
|
footerLayoutParams.removeRule(alignEnd)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.END_OF)
|
footerLayoutParams.removeRule(alignStart)
|
||||||
|
footerLayoutParams.removeRule(endOf)
|
||||||
|
footerLayoutParams.removeRule(startOf)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.BELOW)
|
footerLayoutParams.removeRule(RelativeLayout.BELOW)
|
||||||
// Reverse margins
|
// Reverse margins
|
||||||
footerMarginStartDp = 1
|
footerMarginStartDp = 1
|
||||||
|
@ -540,17 +552,24 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
||||||
footerMarginEndDp = 8
|
footerMarginEndDp = 8
|
||||||
}
|
}
|
||||||
else -> /* footer on the right / at the end */ {
|
else -> /* footer on the right / at the end */ {
|
||||||
footerLayoutParams.addRule(RelativeLayout.END_OF, R.id.viewStubContainer)
|
footerLayoutParams.addRule(endOf, R.id.viewStubContainer)
|
||||||
footerLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.viewStubContainer)
|
footerLayoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.viewStubContainer)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.ALIGN_END)
|
footerLayoutParams.removeRule(startOf)
|
||||||
|
footerLayoutParams.removeRule(alignEnd)
|
||||||
|
footerLayoutParams.removeRule(alignStart)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.BELOW)
|
footerLayoutParams.removeRule(RelativeLayout.BELOW)
|
||||||
footerLayoutParams.removeRule(RelativeLayout.START_OF)
|
footerLayoutParams.removeRule(RelativeLayout.START_OF)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removeFooterOverlayStyle(holder, density)
|
removeFooterOverlayStyle(holder, density)
|
||||||
}
|
}
|
||||||
footerLayoutParams.marginStart = round(footerMarginStartDp*density).toInt()
|
if (defaultRtl) {
|
||||||
footerLayoutParams.marginEnd = round(footerMarginEndDp*density).toInt()
|
footerLayoutParams.rightMargin = round(footerMarginStartDp * density).toInt()
|
||||||
|
footerLayoutParams.leftMargin = round(footerMarginEndDp * density).toInt()
|
||||||
|
} else {
|
||||||
|
footerLayoutParams.leftMargin = round(footerMarginStartDp * density).toInt()
|
||||||
|
footerLayoutParams.rightMargin = round(footerMarginEndDp * density).toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bubbleStyle == BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN) {
|
if (bubbleStyle == BubbleThemeUtils.BUBBLE_STYLE_BOTH_HIDDEN) {
|
||||||
// We need to align the non-bubble member name view to pseudo bubbles
|
// We need to align the non-bubble member name view to pseudo bubbles
|
||||||
|
|
Loading…
Reference in New Issue