mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-24 02:33:00 +01:00
Fix message bubble caption exceeding the media width.
This commit is contained in:
committed by
Greyson Parrelli
parent
d05338cee0
commit
663e0a616e
@@ -602,7 +602,14 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
int collapsedTopMargin = -1 * (dateView.getMeasuredHeight() + ViewUtil.dpToPx(4));
|
||||
|
||||
if (bodyText.isSingleLine() && !messageRecord.isFailed()) {
|
||||
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
|
||||
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
|
||||
if (hasThumbnail(messageRecord) || hasBigImageLinkPreview(messageRecord)) {
|
||||
int thumbnailWidth = mediaThumbnailStub.resolved() ? mediaThumbnailStub.require().getMeasuredWidth() : 0;
|
||||
if (thumbnailWidth > 0) {
|
||||
maxBubbleWidth = Math.min(maxBubbleWidth, thumbnailWidth);
|
||||
}
|
||||
}
|
||||
|
||||
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
||||
int sizeWithMargins = bodyText.getMeasuredWidth() + TEXT_FOOTER_SPACING + footerWidth + bodyMargins;
|
||||
int minSize = Math.min(maxBubbleWidth, Math.max(bodyText.getMeasuredWidth() + TEXT_FOOTER_SPACING + footerWidth + bodyMargins, bodyBubble.getMeasuredWidth()));
|
||||
@@ -636,10 +643,12 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
|
||||
if (lineWidthChangedSlightly) {
|
||||
if (lastFooterWasCollapsed && ViewUtil.getTopMargin(footer) != collapsedTopMargin) {
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin, false);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin, false);
|
||||
updatingFooter = true;
|
||||
needsMeasure = true;
|
||||
if (requiredSpace - FOOTER_POSITION_THRESHOLD <= availableSpace) {
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin, false);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin, false);
|
||||
updatingFooter = true;
|
||||
needsMeasure = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (requiredSpace + FOOTER_POSITION_THRESHOLD <= availableSpace) {
|
||||
@@ -663,7 +672,10 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
boolean lineWidthChangedSlightly = Math.abs(currentLineWidth - lastFooterDecisionLineWidth) <= FOOTER_POSITION_THRESHOLD;
|
||||
|
||||
if (lineWidthChangedSlightly && lastFooterWasCollapsed) {
|
||||
shouldRevert = false;
|
||||
int currentRequiredSpace = currentLineWidth + TEXT_FOOTER_SPACING + footer.getMeasuredWidth();
|
||||
if (currentRequiredSpace - FOOTER_POSITION_THRESHOLD <= bodyText.getMeasuredWidth()) {
|
||||
shouldRevert = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,6 +714,17 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
}
|
||||
}
|
||||
|
||||
if (!isViewOnceMessage(messageRecord) && (hasThumbnail(messageRecord) || hasBigImageLinkPreview(messageRecord))) {
|
||||
int thumbnailWidth = mediaThumbnailStub.require().getMeasuredWidth();
|
||||
if (thumbnailWidth > 0 && bodyBubble.getMeasuredWidth() > thumbnailWidth) {
|
||||
bodyBubble.getLayoutParams().width = thumbnailWidth;
|
||||
updatingFooter = false;
|
||||
lastFooterDecisionLineWidth = -1;
|
||||
lastFooterWasCollapsed = false;
|
||||
needsMeasure = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needsMeasure) {
|
||||
if (measureCalls < MAX_MEASURE_CALLS) {
|
||||
measureCalls++;
|
||||
|
||||
Reference in New Issue
Block a user