Preview of encrypted images (first and fast implementation)

This commit is contained in:
Benoit Marty 2019-07-02 14:35:22 +02:00
parent 994ee1d23f
commit 14a2570ea4
2 changed files with 30 additions and 3 deletions

View File

@ -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)
}
}
}


View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -18,4 +19,11 @@
app:failureImageInitScaleType="center"
app:optimizeDisplay="true" />

<ImageView
android:id="@+id/encryptedImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
tools:visibility="visible" />

</LinearLayout>