diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-10-22 21:23:44 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-10-22 21:23:44 +0200 |
commit | e42c9a515c127e1106a43a62b6aee1e492813f2b (patch) | |
tree | e6527b0d0d429d6f342ab2af56fcc91d6a191849 /src | |
parent | 8fd5796fd18af4cb4741781b9b39c02b86ad4534 (diff) |
bring back animated gif view in MediaViewer
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java | 14 | ||||
-rw-r--r-- | src/main/res/layout/activity_media_viewer.xml | 7 | ||||
-rw-r--r-- | src/main/res/values/defaults.xml | 3 | ||||
-rw-r--r-- | src/main/res/values/ids.xml | 1 |
4 files changed, 22 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java b/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java index a8285d594..a0464956d 100644 --- a/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java +++ b/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java @@ -42,6 +42,7 @@ import de.pixart.messenger.R; import de.pixart.messenger.persistance.FileBackend; import de.pixart.messenger.utils.ExifHelper; import de.pixart.messenger.utils.MimeUtils; +import pl.droidsonroids.gif.GifImageView; import static de.pixart.messenger.persistance.FileBackend.close; @@ -49,6 +50,7 @@ public class MediaViewerActivity extends XmppActivity { Integer oldOrientation; SubsamplingScaleImageView mImage; + GifImageView mGIF; FullscreenVideoLayout mVideo; ImageView mFullscreenbutton; Uri mFileUri; @@ -96,6 +98,7 @@ public class MediaViewerActivity extends XmppActivity { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_media_viewer); mImage = findViewById(R.id.message_image_view); + mGIF = findViewById(R.id.message_gif_view); mVideo = findViewById(R.id.message_video_view); mFullscreenbutton = findViewById(R.id.vcv_img_fullscreen); fab = findViewById(R.id.fab); @@ -236,6 +239,8 @@ public class MediaViewerActivity extends XmppActivity { } private void DisplayImage(final File file, final Uri FileUri) { + boolean gif = false; + gif = "image/gif".equalsIgnoreCase(getMimeType(file.toString())); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(new File(file.getPath()).getAbsolutePath(), options); @@ -246,9 +251,14 @@ public class MediaViewerActivity extends XmppActivity { if (useAutoRotateScreen()) { rotateScreen(width, height, rotation); } - mImage.setVisibility(View.VISIBLE); try { - mImage.setImage(ImageSource.uri(FileUri)); + if (gif) { + mGIF.setVisibility(View.VISIBLE); + mGIF.setImageURI(FileUri); + } else { + mImage.setVisibility(View.VISIBLE); + mImage.setImage(ImageSource.uri(FileUri)); + } } catch (Exception e) { Toast.makeText(this, getString(R.string.error_file_corrupt), Toast.LENGTH_LONG).show(); e.printStackTrace(); diff --git a/src/main/res/layout/activity_media_viewer.xml b/src/main/res/layout/activity_media_viewer.xml index 2eaad0d04..33f6a1059 100644 --- a/src/main/res/layout/activity_media_viewer.xml +++ b/src/main/res/layout/activity_media_viewer.xml @@ -20,6 +20,13 @@ android:adjustViewBounds="true" android:visibility="gone" /> + <pl.droidsonroids.gif.GifImageView + android:id="@id/message_gif_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:adjustViewBounds="true" + android:visibility="gone" /> + <com.github.rtoshiro.view.video.FullscreenVideoLayout android:id="@id/message_video_view" android:layout_width="match_parent" diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 29e560124..7c0072f86 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -42,6 +42,7 @@ \n\nhttp://hc.apache.org/httpcomponents-core\n(Apache License, Version 2.0) \n\nhttps://github.com/bumptech/glide\n(BSD, The MIT License (MIT) and Apache License, Version 2.0) \n\nhttps://github.com/davemorrissey/subsampling-scale-image-view\n(Apache License, Version 2.0) + \n\nhttps://github.com/koral--/android-gif-drawable\n(The MIT License (MIT)) \n\nhttps://github.com/rtoshiro/FullscreenVideoView\n(Apache License, Version 2.0) \n\nhttps://github.com/mangstadt/ez-vcard\n(FreeBSD) \n\nhttps://github.com/googlesamples/easypermissions\n(Apache License, Version 2.0) @@ -111,7 +112,7 @@ <item>pix-art.de</item> <item>conversations.im</item> <item>jabber.cat</item> - <item>jabbers.one</item> + <item>jabbers.one</item> <item>jabjab.de</item> <item>im.koderoot.net</item> <item>riotcat.org</item> diff --git a/src/main/res/values/ids.xml b/src/main/res/values/ids.xml index c4f584851..ffdd80eee 100644 --- a/src/main/res/values/ids.xml +++ b/src/main/res/values/ids.xml @@ -3,6 +3,7 @@ <item name="snackbar_location_message" type="id" /> <item name="message_image_view" type="id" /> <item name="message_video_view" type="id" /> + <item name="message_gif_view" type="id" /> <item name="import_text" type="id" /> <item name="TAG_ACCOUNT" type="id" /> <item name="TAG_FINGERPRINT" type="id" /> |