Allow opening large (> 512px) stickers in media viewer

(cherry picked from commit 014b6a28bcec8255ae5ffde9da8fcf86e5695bb4)
This commit is contained in:
tehcneko 2021-02-19 17:06:04 +08:00 committed by 世界
parent 2dd69697cb
commit 368ab7ab8b
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
2 changed files with 22 additions and 1 deletions

View File

@ -1716,7 +1716,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
imagePressed = true;
result = true;
}
} else if (!currentMessageObject.isAnyKindOfSticker() || currentMessageObject.getInputStickerSet() != null || currentMessageObject.isAnimatedEmoji() || currentMessageObject.isDice()) {
} else if (!currentMessageObject.isAnyKindOfSticker() || currentMessageObject.getInputStickerSet() != null || currentMessageObject.isAnimatedEmoji() || currentMessageObject.isDice() || currentMessageObject.getInputStickerSet() == null && currentMessageObject.isSticker()) {
if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + photoImage.getImageWidth() && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
imagePressed = true;
result = true;

View File

@ -22499,6 +22499,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
} else if (message.type == MessageObject.TYPE_STICKER || message.type == MessageObject.TYPE_ANIMATED_STICKER) {
// In case we have a .webp file that is displayed as a sticker, but
// that doesn't fit in 512x512, we assume it may be a regular large
// .webp image and we allow to open it in media viewer.
// Inspired by https://github.com/telegramdesktop/tdesktop/commit/baccec623d45dbfd1132d5f808192f0f3ad87647
if (message.getInputStickerSet() == null) {
int photoHeight = 0;
int photoWidth = 0;
TLRPC.Document document = message.getDocument();
for (int a = 0, N = document.attributes.size(); a < N; a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeImageSize) {
photoWidth = attribute.w;
photoHeight = attribute.h;
break;
}
}
if (photoWidth > 512 || photoHeight > 512) {
openPhotoViewerForMessage(cell, message);
}
return;
}
StickersAlert alert = new StickersAlert(getParentActivity(), ChatActivity.this, message.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE && (currentChat == null || ChatObject.canSendStickers(currentChat)) ? chatActivityEnterView : null);
alert.setCalcMandatoryInsets(isKeyboardVisible());
showDialog(alert);