Allow same-line message footer even if text RTL != locale RTL if space

Change-Id: I54683129c651697dd831ed832fe8cc45d668cb14
This commit is contained in:
SpiritCroc 2021-05-19 17:54:55 +02:00
parent 7e4a0ddb5c
commit 859cc32d81

View File

@ -50,11 +50,6 @@ class FooteredTextView @JvmOverloads constructor(
val viewIsRtl = layoutDirection == LAYOUT_DIRECTION_RTL val viewIsRtl = layoutDirection == LAYOUT_DIRECTION_RTL
val lastVisibleCharacter = layout.getLineVisibleEnd(lastLine) - 1 val lastVisibleCharacter = layout.getLineVisibleEnd(lastLine) - 1
val looksLikeRtl = layout.isRtlCharAt(lastVisibleCharacter) val looksLikeRtl = layout.isRtlCharAt(lastVisibleCharacter)
if (looksLikeRtl != viewIsRtl) {
// Our footer would overlap text even if there is space in the last line, so reserve space in y-direction
setMeasuredDimension(max(measuredWidth, footerWidth), measuredHeight + footerHeight)
return
}
// Get required width for all lines // Get required width for all lines
var maxLineWidth = 0f var maxLineWidth = 0f
@ -70,7 +65,7 @@ class FooteredTextView @JvmOverloads constructor(
val widthLastLine = layout.getLineWidth(lastLine) val widthLastLine = layout.getLineWidth(lastLine)
// Required width if putting footer in the same line as the last line // Required width if putting footer in the same line as the last line
val widthWithHorizontalFooter = widthLastLine + footerWidth val widthWithHorizontalFooter = (if (looksLikeRtl == viewIsRtl) widthLastLine else maxLineWidth) + footerWidth
// Is there space for a horizontal footer? // Is there space for a horizontal footer?
if (widthWithHorizontalFooter <= widthLimit) { if (widthWithHorizontalFooter <= widthLimit) {