mirror of
https://github.com/oxen-io/session-android.git
synced 2025-03-13 21:30:56 +00:00
Fixing quote cutoff when font is too large.
This commit is contained in:
parent
39d997a636
commit
5936efea53
@ -78,11 +78,14 @@ class QuoteView : LinearLayout {
|
||||
}
|
||||
val body = quoteViewBodyTextView.text
|
||||
val bodyTextViewIntrinsicHeight = TextUtilities.getIntrinsicHeight(body, quoteViewBodyTextView.paint, maxContentWidth)
|
||||
val staticLayout = TextUtilities.getIntrinsicLayout(body, quoteViewBodyTextView.paint, maxContentWidth)
|
||||
result += bodyTextViewIntrinsicHeight
|
||||
if (!quoteViewAuthorTextView.isVisible) {
|
||||
// We want to at least be as high as the cancel button, and no higher than 56 DP (that's
|
||||
// approximately the height of 3 lines.
|
||||
return min(max(result, toPx(32, resources)), toPx(56, resources))
|
||||
|
||||
// Calculating height based on proportion of the static layout.
|
||||
return min((result / staticLayout.lineCount) * 3, result)
|
||||
} else {
|
||||
// Because we're showing the author text view, we should have a height of at least 32 DP
|
||||
// anyway, so there's no need to constrain to that. We constrain to a max height of 56 DP
|
||||
@ -97,7 +100,7 @@ class QuoteView : LinearLayout {
|
||||
// and then center everything inside vertically. This effectively means we're applying padding.
|
||||
// Applying padding the regular way results in a clipping issue though due to a bug in
|
||||
// RelativeLayout.
|
||||
return getIntrinsicContentHeight(maxContentWidth) + 2 * vPadding
|
||||
return getIntrinsicContentHeight(maxContentWidth) + (2 * vPadding )
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
@ -20,6 +20,14 @@ object TextUtilities {
|
||||
return layout.height
|
||||
}
|
||||
|
||||
fun getIntrinsicLayout(text: CharSequence, paint: TextPaint, width: Int): StaticLayout {
|
||||
val builder = StaticLayout.Builder.obtain(text, 0, text.length, paint, width)
|
||||
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
|
||||
.setLineSpacing(0.0f, 1.0f)
|
||||
.setIncludePad(false)
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun TextView.getIntersectedModalSpans(event: MotionEvent): List<ModalURLSpan> {
|
||||
val xInt = event.rawX.toInt()
|
||||
val yInt = event.rawY.toInt()
|
||||
|
Loading…
x
Reference in New Issue
Block a user