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

Fixed: Gallery viewer was showing low-res portrait photos #422

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 21 additions & 11 deletions TMessagesProj/src/main/java/org/telegram/ui/GalleryImageViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,7 @@ private TLRPC.InputFileLocation getCurrentFile() {
}
}
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f);
int height = width + Utilities.dp(100);
if (width > 800) {
width = 800;
}
if (height > 800) {
height = 800;
}

TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, width, height);
TLRPC.PhotoSize sizeFull = getPhotoFullSize(message.messageOwner.media.photo.sizes);
if (sizeFull != null) {
TLRPC.TL_inputFileLocation location = new TLRPC.TL_inputFileLocation();
location.local_id = sizeFull.location.local_id;
Expand All @@ -561,6 +552,25 @@ private TLRPC.InputFileLocation getCurrentFile() {
return null;
}

protected TLRPC.PhotoSize getPhotoFullSize(ArrayList<TLRPC.PhotoSize> sizes) {
if(sizes != null && !sizes.isEmpty()) {
int width = 1000;
int height = 1000;
// width = (int) (Math.min(displaySize.x, displaySize.y) * 0.7f);
// height = width + Utilities.dp(100);
// if (width > 800) {
// width = 800;
// }
// if (height > 800) {
// height = 800;
// }

return PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
}
else
return null;
}

@Override
public void topBtn() {
if (getSupportActionBar().isShowing()) {
Expand Down Expand Up @@ -999,7 +1009,7 @@ public Object instantiateItem(View collection, int position) {
height = 800;
}

TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
TLRPC.PhotoSize sizeFull = getPhotoFullSize(sizes);
if (message.imagePreview != null) {
iv.setImage(sizeFull.location, null, message.imagePreview, sizeFull.size);
} else {
Expand Down