Skip to content

Commit 27a9ea9

Browse files
authored
SES-4614 : Read More Indicator Appears Erroneously (#1525)
1 parent b4a4031 commit 27a9ea9

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

app/src/main/java/org/session/libsession/utilities/ViewUtils.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@ fun TextView.needsCollapsing(
3434
availableWidthPx: Int,
3535
maxLines: Int
3636
): Boolean {
37-
// Pick the width the TextView will actually respect before draw
38-
val rawWidth = when {
39-
measuredWidth > 0 -> measuredWidth
40-
// if maxWidth is set, we check it
41-
maxWidth in 1 until Int.MAX_VALUE -> minOf(availableWidthPx, maxWidth)
42-
else -> availableWidthPx
43-
}
44-
val contentWidth = (rawWidth - paddingLeft - paddingRight).coerceAtLeast(0)
37+
val contentWidth = (availableWidthPx - paddingLeft - paddingRight).coerceAtLeast(0)
4538
if (contentWidth <= 0 || text.isNullOrEmpty()) return false
4639

4740
val textForLayout = transformationMethod?.getTransformation(text, this) ?: text
@@ -67,7 +60,7 @@ fun TextView.needsCollapsing(
6760
.setAlignment(alignment)
6861
.setTextDirection(direction)
6962
.setMaxLines(maxLines) // cap at maxLines
70-
.setEllipsize(ellipsize ?: TextUtils.TruncateAt.END) // compute ellipsis
63+
.setEllipsize(ellipsize) // compute ellipsis
7164

7265
builder.setJustificationMode(justificationMode)
7366

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,9 @@ class VisibleMessageContentView : ConstraintLayout {
356356
}
357357
}
358358

359-
val widthCap = binding.bodyTextView.maxWidth
360-
.takeIf { it > 0 && it < Int.MAX_VALUE }
361-
?: resources.getDimensionPixelSize(R.dimen.max_bubble_width)
362-
363359
// if the text was already manually expanded, we can skip this logic
364360
if(!isTextExpanded && binding.bodyTextView.needsCollapsing(
365-
availableWidthPx = widthCap,
361+
availableWidthPx = binding.bodyTextView.maxWidth,
366362
maxLines = MAX_COLLAPSED_LINE_COUNT)
367363
){
368364
// show the "Read mode" button

0 commit comments

Comments
 (0)