mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
[android] scale thumbnails to minimum size, don't upscale to maximum size
This commit is contained in:
@@ -175,10 +175,18 @@ class AttachmentController {
|
|||||||
float widthPercentage = maxWidth / (float) width;
|
float widthPercentage = maxWidth / (float) width;
|
||||||
float heightPercentage = maxHeight / (float) height;
|
float heightPercentage = maxHeight / (float) height;
|
||||||
float scaleFactor = Math.min(widthPercentage, heightPercentage);
|
float scaleFactor = Math.min(widthPercentage, heightPercentage);
|
||||||
|
if (scaleFactor > 1) scaleFactor = 1f;
|
||||||
int thumbnailWidth = (int) (width * scaleFactor);
|
int thumbnailWidth = (int) (width * scaleFactor);
|
||||||
int thumbnailHeight = (int) (height * scaleFactor);
|
int thumbnailHeight = (int) (height * scaleFactor);
|
||||||
if (thumbnailWidth < minWidth) thumbnailWidth = minWidth;
|
if (thumbnailWidth < minWidth || thumbnailHeight < minHeight) {
|
||||||
if (thumbnailHeight < minHeight) thumbnailHeight = minHeight;
|
widthPercentage = minWidth / (float) width;
|
||||||
|
heightPercentage = minHeight / (float) height;
|
||||||
|
scaleFactor = Math.max(widthPercentage, heightPercentage);
|
||||||
|
thumbnailWidth = (int) (width * scaleFactor);
|
||||||
|
thumbnailHeight = (int) (height * scaleFactor);
|
||||||
|
if (thumbnailWidth > maxWidth) thumbnailWidth = maxWidth;
|
||||||
|
if (thumbnailHeight > maxHeight) thumbnailHeight = maxHeight;
|
||||||
|
}
|
||||||
return new Size(thumbnailWidth, thumbnailHeight);
|
return new Size(thumbnailWidth, thumbnailHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.logging.Logger;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static com.bumptech.glide.load.DataSource.LOCAL;
|
import static com.bumptech.glide.load.DataSource.LOCAL;
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
@@ -52,7 +51,7 @@ class BriarDataFetcher implements DataFetcher<InputStream> {
|
|||||||
@Override
|
@Override
|
||||||
public void loadData(Priority priority,
|
public void loadData(Priority priority,
|
||||||
DataCallback<? super InputStream> callback) {
|
DataCallback<? super InputStream> callback) {
|
||||||
MessageId id = requireNonNull(attachment).getMessageId();
|
MessageId id = attachment.getMessageId();
|
||||||
dbExecutor.execute(() -> {
|
dbExecutor.execute(() -> {
|
||||||
if (cancel) return;
|
if (cancel) return;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user