mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 11:42:15 -05:00
rotate thumbnails. fixes #1438
This commit is contained in:
parent
5fb77a9739
commit
64dbb069ab
@ -260,6 +260,10 @@ public class FileBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getRotation(File file) {
|
||||||
|
return getRotation(Uri.parse("file://"+file.getAbsolutePath()));
|
||||||
|
}
|
||||||
|
|
||||||
private int getRotation(Uri image) {
|
private int getRotation(Uri image) {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try {
|
try {
|
||||||
@ -274,8 +278,7 @@ public class FileBackend {
|
|||||||
|
|
||||||
public Bitmap getThumbnail(Message message, int size, boolean cacheOnly)
|
public Bitmap getThumbnail(Message message, int size, boolean cacheOnly)
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
Bitmap thumbnail = mXmppConnectionService.getBitmapCache().get(
|
Bitmap thumbnail = mXmppConnectionService.getBitmapCache().get(message.getUuid());
|
||||||
message.getUuid());
|
|
||||||
if ((thumbnail == null) && (!cacheOnly)) {
|
if ((thumbnail == null) && (!cacheOnly)) {
|
||||||
File file = getFile(message);
|
File file = getFile(message);
|
||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
@ -285,8 +288,12 @@ public class FileBackend {
|
|||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
}
|
}
|
||||||
thumbnail = resize(fullsize, size);
|
thumbnail = resize(fullsize, size);
|
||||||
this.mXmppConnectionService.getBitmapCache().put(message.getUuid(),
|
fullsize.recycle();
|
||||||
thumbnail);
|
int rotation = getRotation(file);
|
||||||
|
if (rotation > 0) {
|
||||||
|
thumbnail = rotate(thumbnail, rotation);
|
||||||
|
}
|
||||||
|
this.mXmppConnectionService.getBitmapCache().put(message.getUuid(),thumbnail);
|
||||||
}
|
}
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
@ -512,8 +519,10 @@ public class FileBackend {
|
|||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
options.inJustDecodeBounds = true;
|
options.inJustDecodeBounds = true;
|
||||||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||||
int imageHeight = options.outHeight;
|
int rotation = getRotation(file);
|
||||||
int imageWidth = options.outWidth;
|
boolean rotated = rotation == 90 || rotation == 270;
|
||||||
|
int imageHeight = rotated ? options.outWidth : options.outHeight;
|
||||||
|
int imageWidth = rotated ? options.outHeight : options.outWidth;
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
message.setBody(Long.toString(file.getSize()) + '|' + imageWidth + '|' + imageHeight);
|
message.setBody(Long.toString(file.getSize()) + '|' + imageWidth + '|' + imageHeight);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user