aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-01-05 22:57:18 +0100
committerChristian Schneppe <christian@pix-art.de>2017-01-05 22:57:18 +0100
commit94fb468742e88abae4690b81fd02dab80f77fc97 (patch)
treed8ea243430ddc97c401c724502a97049e085c30d
parent0eaa0bf5c593f82fcdbae74f341d78c9f1721c93 (diff)
add overlay to indicate that image is gif
-rw-r--r--art/play_gif.svg68
-rwxr-xr-xart/render.rb3
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java31
-rw-r--r--src/main/res/drawable-hdpi/play_gif.pngbin0 -> 1739 bytes
-rw-r--r--src/main/res/drawable-hdpi/play_video.pngbin14537 -> 9620 bytes
-rw-r--r--src/main/res/drawable-mdpi/play_gif.pngbin0 -> 904 bytes
-rw-r--r--src/main/res/drawable-mdpi/play_video.pngbin5208 -> 4450 bytes
-rw-r--r--src/main/res/drawable-xhdpi/play_gif.pngbin0 -> 2567 bytes
-rw-r--r--src/main/res/drawable-xhdpi/play_video.pngbin23862 -> 12361 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/play_gif.pngbin0 -> 5085 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/play_video.pngbin47970 -> 24711 bytes
-rw-r--r--src/main/res/drawable-xxxhdpi/play_gif.pngbin0 -> 7359 bytes
-rw-r--r--src/main/res/drawable-xxxhdpi/play_video.pngbin34505 -> 29246 bytes
13 files changed, 95 insertions, 7 deletions
diff --git a/art/play_gif.svg b/art/play_gif.svg
new file mode 100644
index 000000000..47f5cc24d
--- /dev/null
+++ b/art/play_gif.svg
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="play_gif.svg">
+ <metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="1200"
+ id="namedview12"
+ showgrid="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="1.5762712"
+ inkscape:cy="11.084746"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg2" />
+ <defs
+ id="defs4">
+ <path
+ id="a"
+ d="M24 24H0V0h24v24z" />
+ </defs>
+ <clipPath
+ id="b">
+ <use
+ xlink:href="#a"
+ overflow="visible"
+ id="use8" />
+ </clipPath>
+ <path
+ d="M11.5 9H13v6h-1.5zM9 9H6c-.6 0-1 .5-1 1v4c0 .5.4 1 1 1h3c.6 0 1-.5 1-1v-2H8.5v1.5h-2v-3H10V10c0-.5-.4-1-1-1zm10 1.5V9h-4.5v6H16v-2h2v-1.5h-2v-1z"
+ clip-path="url(#b)"
+ id="path10"
+ style="fill:#ffffff;fill-opacity:0.7019608" />
+</svg>
diff --git a/art/render.rb b/art/render.rb
index 92ef1ee11..260c7dc24 100755
--- a/art/render.rb
+++ b/art/render.rb
@@ -13,7 +13,8 @@ resolutions = {
images = {
'ic_launcher.svg' => ['ic_launcher', 48],
'main_logo.svg' => ['main_logo', 200],
- 'play_video.svg' => ['play_video', 96],
+ 'play_video.svg' => ['play_video', 128],
+ 'play_gif.svg' => ['play_gif', 128],
'conversations_mono.svg' => ['ic_notification', 24],
'ic_received_indicator.svg' => ['ic_received_indicator', 12],
'ic_read_indicator.svg' => ['ic_read_indicator', 12],
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 88e53efd4..c85c2c34a 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
+import android.graphics.Paint;
import android.graphics.RectF;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
@@ -426,7 +427,8 @@ public class FileBackend {
return thumbnail;
}
DownloadableFile file = getFile(message);
- if (file.getMimeType().startsWith("video/")) {
+ final String mime = file.getMimeType();
+ if (mime.startsWith("video/")) {
thumbnail = getVideoPreview(file, size);
} else {
Bitmap fullsize = getFullsizeImagePreview(file, size);
@@ -435,6 +437,12 @@ public class FileBackend {
}
thumbnail = resize(fullsize, size);
thumbnail = rotate(thumbnail, getRotation(file));
+ if (mime.equals("image/gif")) {
+ Bitmap withGifOverlay = thumbnail.copy(Bitmap.Config.ARGB_8888, true);
+ drawOverlay(withGifOverlay, R.drawable.play_gif, 1.0f);
+ thumbnail.recycle();
+ thumbnail = withGifOverlay;
+ }
}
this.mXmppConnectionService.getBitmapCache().put(uuid, thumbnail);
}
@@ -453,6 +461,21 @@ public class FileBackend {
}
}
+ private void drawOverlay(Bitmap bitmap, int resource, float factor) {
+ Bitmap overlay = BitmapFactory.decodeResource(mXmppConnectionService.getResources(), resource);
+ Canvas canvas = new Canvas(bitmap);
+ Paint paint = new Paint();
+ paint.setAntiAlias(true);
+ paint.setFilterBitmap(true);
+ paint.setDither(true);
+ float targetSize = Math.min(canvas.getWidth(), canvas.getHeight()) * factor;
+ Log.d(Config.LOGTAG, "target size overlay: " + targetSize + " overlay bitmap size was " + overlay.getHeight());
+ float left = (canvas.getWidth() - targetSize) / 2.0f;
+ float top = (canvas.getHeight() - targetSize) / 2.0f;
+ RectF dst = new RectF(left, top, left + targetSize - 1, top + targetSize - 1);
+ canvas.drawBitmap(overlay, null, dst, paint);
+ }
+
private Bitmap getVideoPreview(File file, int size) {
MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
Bitmap frame;
@@ -465,11 +488,7 @@ public class FileBackend {
frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
frame.eraseColor(0xff000000);
}
- Canvas canvas = new Canvas(frame);
- Bitmap play = BitmapFactory.decodeResource(mXmppConnectionService.getResources(), R.drawable.play_video);
- float x = (frame.getWidth() - play.getWidth()) / 2.0f;
- float y = (frame.getHeight() - play.getHeight()) / 2.0f;
- canvas.drawBitmap(play, x, y, null);
+ drawOverlay(frame,R.drawable.play_video,0.75f);
return frame;
}
diff --git a/src/main/res/drawable-hdpi/play_gif.png b/src/main/res/drawable-hdpi/play_gif.png
new file mode 100644
index 000000000..e5fe110f0
--- /dev/null
+++ b/src/main/res/drawable-hdpi/play_gif.png
Binary files differ
diff --git a/src/main/res/drawable-hdpi/play_video.png b/src/main/res/drawable-hdpi/play_video.png
index 76e8f5258..34ed2a7e5 100644
--- a/src/main/res/drawable-hdpi/play_video.png
+++ b/src/main/res/drawable-hdpi/play_video.png
Binary files differ
diff --git a/src/main/res/drawable-mdpi/play_gif.png b/src/main/res/drawable-mdpi/play_gif.png
new file mode 100644
index 000000000..0d731789e
--- /dev/null
+++ b/src/main/res/drawable-mdpi/play_gif.png
Binary files differ
diff --git a/src/main/res/drawable-mdpi/play_video.png b/src/main/res/drawable-mdpi/play_video.png
index a6fa5185b..a3291b0bb 100644
--- a/src/main/res/drawable-mdpi/play_video.png
+++ b/src/main/res/drawable-mdpi/play_video.png
Binary files differ
diff --git a/src/main/res/drawable-xhdpi/play_gif.png b/src/main/res/drawable-xhdpi/play_gif.png
new file mode 100644
index 000000000..270d9f719
--- /dev/null
+++ b/src/main/res/drawable-xhdpi/play_gif.png
Binary files differ
diff --git a/src/main/res/drawable-xhdpi/play_video.png b/src/main/res/drawable-xhdpi/play_video.png
index bdeb15cdf..6c0250b92 100644
--- a/src/main/res/drawable-xhdpi/play_video.png
+++ b/src/main/res/drawable-xhdpi/play_video.png
Binary files differ
diff --git a/src/main/res/drawable-xxhdpi/play_gif.png b/src/main/res/drawable-xxhdpi/play_gif.png
new file mode 100644
index 000000000..74221d4f9
--- /dev/null
+++ b/src/main/res/drawable-xxhdpi/play_gif.png
Binary files differ
diff --git a/src/main/res/drawable-xxhdpi/play_video.png b/src/main/res/drawable-xxhdpi/play_video.png
index 2b4d827df..46cad76d6 100644
--- a/src/main/res/drawable-xxhdpi/play_video.png
+++ b/src/main/res/drawable-xxhdpi/play_video.png
Binary files differ
diff --git a/src/main/res/drawable-xxxhdpi/play_gif.png b/src/main/res/drawable-xxxhdpi/play_gif.png
new file mode 100644
index 000000000..484b93362
--- /dev/null
+++ b/src/main/res/drawable-xxxhdpi/play_gif.png
Binary files differ
diff --git a/src/main/res/drawable-xxxhdpi/play_video.png b/src/main/res/drawable-xxxhdpi/play_video.png
index 550d48394..8f09ea422 100644
--- a/src/main/res/drawable-xxxhdpi/play_video.png
+++ b/src/main/res/drawable-xxxhdpi/play_video.png
Binary files differ