From 14a2570ea45ebe14d87ec5b800b2b682171c251f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 2 Jul 2019 14:35:22 +0200 Subject: [PATCH] Preview of encrypted images (first and fast implementation) --- .../media/ImageMediaViewerActivity.kt | 25 ++++++++++++++++--- .../layout/activity_image_media_viewer.xml | 8 ++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt index c68f594f..fc5e2725 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt @@ -20,9 +20,11 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.appcompat.widget.Toolbar +import androidx.core.view.isVisible import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator import com.github.piasy.biv.view.GlideImageViewFactory import im.vector.riotredesign.core.di.ScreenComponent +import im.vector.riotredesign.core.glide.GlideApp import im.vector.riotredesign.core.platform.VectorBaseActivity import kotlinx.android.synthetic.main.activity_image_media_viewer.* import javax.inject.Inject @@ -44,9 +46,26 @@ class ImageMediaViewerActivity : VectorBaseActivity() { finish() } else { configureToolbar(imageMediaViewerToolbar, mediaData) - imageMediaViewerImageView.setImageViewFactory(GlideImageViewFactory()) - imageMediaViewerImageView.setProgressIndicator(ProgressPieIndicator()) - imageContentRenderer.render(mediaData, imageMediaViewerImageView) + + if (mediaData.elementToDecrypt != null) { + // Encrypted image + imageMediaViewerImageView.isVisible = false + encryptedImageView.isVisible = true + + GlideApp + .with(this) + .load(mediaData) + .dontAnimate() + .into(encryptedImageView) + } else { + // Clear image + imageMediaViewerImageView.isVisible = true + encryptedImageView.isVisible = false + + imageMediaViewerImageView.setImageViewFactory(GlideImageViewFactory()) + imageMediaViewerImageView.setProgressIndicator(ProgressPieIndicator()) + imageContentRenderer.render(mediaData, imageMediaViewerImageView) + } } } diff --git a/vector/src/main/res/layout/activity_image_media_viewer.xml b/vector/src/main/res/layout/activity_image_media_viewer.xml index 194b9d60..61d5d286 100644 --- a/vector/src/main/res/layout/activity_image_media_viewer.xml +++ b/vector/src/main/res/layout/activity_image_media_viewer.xml @@ -1,6 +1,7 @@ @@ -18,4 +19,11 @@ app:failureImageInitScaleType="center" app:optimizeDisplay="true" /> + + \ No newline at end of file