diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-06-24 21:34:47 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-06-29 21:55:43 +0200 |
commit | d9d40ecb4297a7ade4205d6dca411c01aa728663 (patch) | |
tree | 2853511ab2432799cbb9d2ab1a7d736e424c8e63 /src/main/java/de/pixart/messenger/persistance | |
parent | 6633eedbb75d5fa85186c053aa7797b5b5458fc6 (diff) |
WIP: set room avatar and slight redesign of group details
*show jid in group details (in advanced mode)
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index e893ea129..3bb1e5c4e 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -614,6 +614,14 @@ public class FileBackend { } public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) { + final Avatar uncompressAvatar = getUncompressedAvatar(image); + if (uncompressAvatar != null && uncompressAvatar.image.length() <= Config.AVATAR_CHAR_LIMIT) { + return uncompressAvatar; + } + if (uncompressAvatar != null) { + Log.d(Config.LOGTAG, "uncompressed avatar exceeded char limit by " + (uncompressAvatar.image.length() - Config.AVATAR_CHAR_LIMIT)); + } + Bitmap bm = cropCenterSquare(image, size); if (bm == null) { return null; @@ -627,6 +635,19 @@ public class FileBackend { return getPepAvatar(bm, format, 100); } + private Avatar getUncompressedAvatar(Uri uri) { + Bitmap bitmap = null; + try { + bitmap = BitmapFactory.decodeStream(mXmppConnectionService.getContentResolver().openInputStream(uri)); + return getPepAvatar(bitmap, Bitmap.CompressFormat.PNG, 100); + } catch (Exception e) { + if (bitmap != null) { + bitmap.recycle(); + } + } + return null; + } + private Avatar getPepAvatar(Bitmap bitmap, Bitmap.CompressFormat format, int quality) { try { ByteArrayOutputStream mByteArrayOutputStream = new ByteArrayOutputStream(); |