kopia lustrzana https://github.com/ryukoposting/Signal-Android
Revert changes to message bubble sizing.
This reverts commitfork-5.53.84e67752850
. This reverts commit449acaf9df
. This reverts commite8882a8076
.
rodzic
ea92280cea
commit
b68bd9179c
|
@ -158,16 +158,9 @@ public class EmojiTextView extends AppCompatTextView {
|
|||
}
|
||||
|
||||
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int originalWidthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
widthMeasureSpec = applyWidthMeasureRoundingFix(widthMeasureSpec);
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
widthMeasureSpec = getPreciseWidthForMaxLines(originalWidthMode);
|
||||
if (widthMeasureSpec != 0) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
CharSequence text = getText();
|
||||
if (getLayout() == null || !measureLastLine || text == null || text.length() == 0) {
|
||||
lastLineWidth = -1;
|
||||
|
@ -215,29 +208,6 @@ public class EmojiTextView extends AppCompatTextView {
|
|||
return widthMeasureSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the width to use for this view based on the lines of text that will be shown, as
|
||||
* opposed to the default behavior which will consider lines after the max lines constraint.
|
||||
*
|
||||
* @param originalWidthMode the original mode passed for the width measure spec in {@link #onMeasure(int, int)}
|
||||
* @return the new measure spec to use for the width. 0 if the existing measurement should be used.
|
||||
*/
|
||||
private int getPreciseWidthForMaxLines(int originalWidthMode) {
|
||||
if (originalWidthMode != MeasureSpec.EXACTLY && getLineCount() > getMaxLines() && getLayout() != null) {
|
||||
float maxWidth = 0;
|
||||
for (int i = 0; i < getMaxLines(); i++) {
|
||||
maxWidth = Math.max(maxWidth, getLayout().getLineWidth(i));
|
||||
}
|
||||
|
||||
double desiredWidth = Math.ceil(maxWidth);
|
||||
if (desiredWidth < getMeasuredWidth()) {
|
||||
return MeasureSpec.makeMeasureSpec((int) desiredWidth, MeasureSpec.AT_MOST);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean hasMetricAffectingSpan(@NonNull CharSequence text) {
|
||||
if (!(text instanceof Spanned)) {
|
||||
return false;
|
||||
|
|
|
@ -202,7 +202,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
private int defaultBubbleColorForWallpaper;
|
||||
private int measureCalls;
|
||||
private boolean updatingFooter;
|
||||
private boolean canCollapseFooter;
|
||||
|
||||
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
||||
private final AttachmentDownloadClickListener downloadClickListener = new AttachmentDownloadClickListener();
|
||||
|
@ -309,9 +308,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
this.canPlayContent = false;
|
||||
this.mediaItem = null;
|
||||
this.colorizer = colorizer;
|
||||
this.measureCalls = 0;
|
||||
this.updatingFooter = false;
|
||||
this.canCollapseFooter = true;
|
||||
|
||||
this.recipient.observeForever(this);
|
||||
this.conversationRecipient.observeForever(this);
|
||||
|
@ -406,7 +402,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
int defaultBottomMargin = readDimen(R.dimen.message_bubble_bottom_padding);
|
||||
int collapsedBottomMargin = readDimen(R.dimen.message_bubble_collapsed_bottom_padding);
|
||||
|
||||
if (getActiveFooter(messageRecord) == footer &&
|
||||
if (!updatingFooter &&
|
||||
getActiveFooter(messageRecord) == footer &&
|
||||
!hasAudio(messageRecord) &&
|
||||
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
|
||||
!bodyText.isJumbomoji() &&
|
||||
|
@ -417,37 +414,29 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
|
||||
int collapsedTopMargin = -1 * (dateView.getMeasuredHeight() + ViewUtil.dpToPx(4));
|
||||
|
||||
if (!updatingFooter) {
|
||||
if (bodyText.isSingleLine() && !messageRecord.isFailed()) {
|
||||
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
|
||||
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
||||
int sizeWithMargins = bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins;
|
||||
int minSize = Math.min(maxBubbleWidth, Math.max(bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins, bodyBubble.getMeasuredWidth()));
|
||||
if (bodyText.isSingleLine() && !messageRecord.isFailed()) {
|
||||
int maxBubbleWidth = hasBigImageLinkPreview(messageRecord) || hasThumbnail(messageRecord) ? readDimen(R.dimen.media_bubble_max_width) : getMaxBubbleWidth();
|
||||
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
||||
int sizeWithMargins = bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins;
|
||||
int minSize = Math.min(maxBubbleWidth, Math.max(bodyText.getMeasuredWidth() + ViewUtil.dpToPx(6) + footerWidth + bodyMargins, bodyBubble.getMeasuredWidth()));
|
||||
|
||||
if (hasQuote(messageRecord) && sizeWithMargins < availableWidth) {
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||
needsMeasure = true;
|
||||
updatingFooter = true;
|
||||
} else if (sizeWithMargins != bodyText.getMeasuredWidth() && sizeWithMargins <= minSize) {
|
||||
bodyBubble.getLayoutParams().width = minSize;
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||
needsMeasure = true;
|
||||
updatingFooter = true;
|
||||
}
|
||||
if (hasQuote(messageRecord) && sizeWithMargins < availableWidth) {
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||
needsMeasure = true;
|
||||
updatingFooter = true;
|
||||
} else if (sizeWithMargins != bodyText.getMeasuredWidth() && sizeWithMargins <= minSize) {
|
||||
bodyBubble.getLayoutParams().width = minSize;
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||
needsMeasure = true;
|
||||
updatingFooter = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!messageRecord.isFailed() && canCollapseFooter && !bodyText.isSingleLine()) {
|
||||
if (bodyText.getLastLineWidth() + ViewUtil.dpToPx(6) + footerWidth <= bodyText.getMeasuredWidth()) {
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||
} else {
|
||||
ViewUtil.setTopMargin(footer, defaultTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, defaultBottomMargin);
|
||||
canCollapseFooter = false;
|
||||
}
|
||||
if (!updatingFooter && !messageRecord.isFailed() && bodyText.getLastLineWidth() + ViewUtil.dpToPx(6) + footerWidth <= bodyText.getMeasuredWidth()) {
|
||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||
updatingFooter = true;
|
||||
needsMeasure = true;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue