Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix media message reactions popup #1773

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ class LoadingDrawableLocation {
private int commentUnreadX;
private boolean commentDrawUnread;
private int commentWidth;
private CharSequence currentComment;
private int commentX;
private int totalCommentWidth;
private int commentNumberWidth;
Expand Down Expand Up @@ -4143,7 +4144,7 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
messageObject.translated != lastTranslated;
boolean groupChanged = groupedMessages != currentMessagesGroup;
boolean pollChanged = false;

boolean captionChanged = currentCaption != messageObject.caption;
if (!messageIdChanged && currentMessageObject != null) {
messageObject.copyStableParams(currentMessageObject);
}
Expand Down Expand Up @@ -4512,7 +4513,12 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
}
}
commentWidth = totalCommentWidth = (int) Math.ceil(Theme.chat_commentTextPaint.measureText(comment));
commentLayout = new StaticLayout(comment, Theme.chat_commentTextPaint, commentWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
boolean commentChanged = currentComment == null || !currentComment.equals(comment);
if (commentLayout == null || commentChanged) {
commentLayout = new StaticLayout(comment, Theme.chat_commentTextPaint, commentWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
currentComment = comment;
}

if (commentCount != 0 && !LocaleController.isRTL) {
drawCommentNumber = true;
if (commentNumberLayout == null) {
Expand Down Expand Up @@ -6180,7 +6186,7 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
int width = backgroundWidth - AndroidUtilities.dp(31);
widthForCaption = width - AndroidUtilities.dp(10) - getExtraTextX() * 2;

if (!messageObject.isRestrictedMessage && !TextUtils.isEmpty(messageObject.caption)) {
if (captionChanged && !messageObject.isRestrictedMessage && !TextUtils.isEmpty(messageObject.caption)) {
try {
currentCaption = messageObject.caption;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Expand Down Expand Up @@ -6984,14 +6990,16 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
if (currentCaption != null) {
try {
widthForCaption -= getExtraTextX() * 2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.build();
} else {
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (captionLayout == null || captionChanged) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.build();
} else {
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
}
updateCaptionSpoilers();
int lineCount = captionLayout.getLineCount();
Expand Down Expand Up @@ -7362,14 +7370,16 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
width -= AndroidUtilities.dp(24);
}
int widthForCaption = width - AndroidUtilities.dp(31 + (currentMessageObject.type != MessageObject.TYPE_ROUND_VIDEO ? 10 : 0)) - getExtraTextX() * 2;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.build();
} else {
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (captionLayout == null || captionChanged) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.build();
} else {
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
}
updateSeekBarWaveformWidth(null);
updateCaptionSpoilers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,23 @@ public void setSelectedMessages(List<MessageObject> messages) {

private void animateVisible(boolean visible) {
if (visible) {
currentPrimaryObject = findPrimaryObject();
checkCreateReactionsLayout();
invalidatePosition(false);

setVisibility(VISIBLE);
if (reactionsContainerLayout.isEnabled()) {
messageSet = true;
reactionsContainerLayout.setMessage(currentPrimaryObject, parentFragment.getCurrentChatInfo());
reactionsContainerLayout.startEnterAnimation(false);
} else {
messageSet = false;
reactionsContainerLayout.setTransitionProgress(1f);
}

// The width of the current view must be calculated before creating [reactionsContainerLayout]
post(() -> {
currentPrimaryObject = findPrimaryObject();
checkCreateReactionsLayout();
invalidatePosition(false);

if (reactionsContainerLayout.isEnabled()) {
messageSet = true;
reactionsContainerLayout.setMessage(currentPrimaryObject, parentFragment.getCurrentChatInfo());
reactionsContainerLayout.startEnterAnimation(false);
} else {
messageSet = false;
reactionsContainerLayout.setTransitionProgress(1f);
}
});
} else {
messageSet = false;
ValueAnimator animator = ValueAnimator.ofFloat(1, 0).setDuration(150);
Expand Down