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) {
|
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
int originalWidthMode = MeasureSpec.getMode(widthMeasureSpec);
|
|
||||||
widthMeasureSpec = applyWidthMeasureRoundingFix(widthMeasureSpec);
|
widthMeasureSpec = applyWidthMeasureRoundingFix(widthMeasureSpec);
|
||||||
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
widthMeasureSpec = getPreciseWidthForMaxLines(originalWidthMode);
|
|
||||||
if (widthMeasureSpec != 0) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
CharSequence text = getText();
|
CharSequence text = getText();
|
||||||
if (getLayout() == null || !measureLastLine || text == null || text.length() == 0) {
|
if (getLayout() == null || !measureLastLine || text == null || text.length() == 0) {
|
||||||
lastLineWidth = -1;
|
lastLineWidth = -1;
|
||||||
|
@ -215,29 +208,6 @@ public class EmojiTextView extends AppCompatTextView {
|
||||||
return widthMeasureSpec;
|
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) {
|
private boolean hasMetricAffectingSpan(@NonNull CharSequence text) {
|
||||||
if (!(text instanceof Spanned)) {
|
if (!(text instanceof Spanned)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -202,7 +202,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||||
private int defaultBubbleColorForWallpaper;
|
private int defaultBubbleColorForWallpaper;
|
||||||
private int measureCalls;
|
private int measureCalls;
|
||||||
private boolean updatingFooter;
|
private boolean updatingFooter;
|
||||||
private boolean canCollapseFooter;
|
|
||||||
|
|
||||||
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
||||||
private final AttachmentDownloadClickListener downloadClickListener = new AttachmentDownloadClickListener();
|
private final AttachmentDownloadClickListener downloadClickListener = new AttachmentDownloadClickListener();
|
||||||
|
@ -309,9 +308,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||||
this.canPlayContent = false;
|
this.canPlayContent = false;
|
||||||
this.mediaItem = null;
|
this.mediaItem = null;
|
||||||
this.colorizer = colorizer;
|
this.colorizer = colorizer;
|
||||||
this.measureCalls = 0;
|
|
||||||
this.updatingFooter = false;
|
|
||||||
this.canCollapseFooter = true;
|
|
||||||
|
|
||||||
this.recipient.observeForever(this);
|
this.recipient.observeForever(this);
|
||||||
this.conversationRecipient.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 defaultBottomMargin = readDimen(R.dimen.message_bubble_bottom_padding);
|
||||||
int collapsedBottomMargin = readDimen(R.dimen.message_bubble_collapsed_bottom_padding);
|
int collapsedBottomMargin = readDimen(R.dimen.message_bubble_collapsed_bottom_padding);
|
||||||
|
|
||||||
if (getActiveFooter(messageRecord) == footer &&
|
if (!updatingFooter &&
|
||||||
|
getActiveFooter(messageRecord) == footer &&
|
||||||
!hasAudio(messageRecord) &&
|
!hasAudio(messageRecord) &&
|
||||||
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
|
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
|
||||||
!bodyText.isJumbomoji() &&
|
!bodyText.isJumbomoji() &&
|
||||||
|
@ -417,7 +414,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||||
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
|
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
|
||||||
int collapsedTopMargin = -1 * (dateView.getMeasuredHeight() + ViewUtil.dpToPx(4));
|
int collapsedTopMargin = -1 * (dateView.getMeasuredHeight() + ViewUtil.dpToPx(4));
|
||||||
|
|
||||||
if (!updatingFooter) {
|
|
||||||
if (bodyText.isSingleLine() && !messageRecord.isFailed()) {
|
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();
|
||||||
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
int bodyMargins = ViewUtil.getLeftMargin(bodyText) + ViewUtil.getRightMargin(bodyText);
|
||||||
|
@ -437,17 +433,10 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||||
updatingFooter = true;
|
updatingFooter = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!messageRecord.isFailed() && canCollapseFooter && !bodyText.isSingleLine()) {
|
if (!updatingFooter && !messageRecord.isFailed() && bodyText.getLastLineWidth() + ViewUtil.dpToPx(6) + footerWidth <= bodyText.getMeasuredWidth()) {
|
||||||
if (bodyText.getLastLineWidth() + ViewUtil.dpToPx(6) + footerWidth <= bodyText.getMeasuredWidth()) {
|
|
||||||
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
ViewUtil.setTopMargin(footer, collapsedTopMargin);
|
||||||
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
ViewUtil.setBottomMargin(footer, collapsedBottomMargin);
|
||||||
} else {
|
|
||||||
ViewUtil.setTopMargin(footer, defaultTopMargin);
|
|
||||||
ViewUtil.setBottomMargin(footer, defaultBottomMargin);
|
|
||||||
canCollapseFooter = false;
|
|
||||||
}
|
|
||||||
updatingFooter = true;
|
updatingFooter = true;
|
||||||
needsMeasure = true;
|
needsMeasure = true;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue