handle invalid image bounds
This commit is contained in:
parent
157d644750
commit
6fe5c5e770
|
@ -888,7 +888,9 @@ public class FileBackend {
|
||||||
if (image || video) {
|
if (image || video) {
|
||||||
try {
|
try {
|
||||||
Dimensions dimensions = image ? getImageDimensions(file) : getVideoDimensions(file);
|
Dimensions dimensions = image ? getImageDimensions(file) : getVideoDimensions(file);
|
||||||
|
if (dimensions.valid()) {
|
||||||
body.append('|').append(dimensions.width).append('|').append(dimensions.height);
|
body.append('|').append(dimensions.width).append('|').append(dimensions.height);
|
||||||
|
}
|
||||||
} catch (NotAVideoFile notAVideoFile) {
|
} catch (NotAVideoFile notAVideoFile) {
|
||||||
Log.d(Config.LOGTAG, "file with mime type " + file.getMimeType() + " was not a video file");
|
Log.d(Config.LOGTAG, "file with mime type " + file.getMimeType() + " was not a video file");
|
||||||
//fall threw
|
//fall threw
|
||||||
|
@ -1015,6 +1017,10 @@ public class FileBackend {
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
return Math.min(width, height);
|
return Math.min(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean valid() {
|
||||||
|
return width > 0 && height > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NotAVideoFile extends Exception {
|
private static class NotAVideoFile extends Exception {
|
||||||
|
|
|
@ -790,9 +790,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
} else {
|
} else {
|
||||||
displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first, darkBackground);
|
displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first, darkBackground);
|
||||||
}
|
}
|
||||||
} else if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
|
} else if (message.isFileOrImage() && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||||
displayImageMessage(viewHolder, message);
|
|
||||||
} else if (message.getType() == Message.TYPE_FILE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
|
|
||||||
if (message.getFileParams().width > 0 && message.getFileParams().height > 0) {
|
if (message.getFileParams().width > 0 && message.getFileParams().height > 0) {
|
||||||
displayImageMessage(viewHolder, message);
|
displayImageMessage(viewHolder, message);
|
||||||
} else if (message.getFileParams().runtime > 0) {
|
} else if (message.getFileParams().runtime > 0) {
|
||||||
|
|
Loading…
Reference in a new issue