Merge pull request #2383 from vector-im/feature/bma/crop_issue

Try to fix cropped image in timeline (#2126)
This commit is contained in:
Benoit Marty 2020-11-19 17:29:49 +01:00 committed by GitHub
commit 6daae83c3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -18,6 +18,7 @@ Bugfix 🐛:
- Fix issue when restoring draft after sharing (#2287) - Fix issue when restoring draft after sharing (#2287)
- Fix issue when updating the avatar of a room (new avatar vanishing) - Fix issue when updating the avatar of a room (new avatar vanishing)
- Discard change dialog displayed by mistake when avatar has been updated - Discard change dialog displayed by mistake when avatar has been updated
- Try to fix cropped image in timeline (#2126)
- Registration: annoying error message scares every new user when they add an email (#2391) - Registration: annoying error message scares every new user when they add an email (#2391)
Translations 🗣: Translations 🗣:

View file

@ -21,6 +21,7 @@ import android.net.Uri
import android.os.Parcelable import android.os.Parcelable
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.core.view.updateLayoutParams
import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.load.resource.bitmap.RoundedCorners import com.bumptech.glide.load.resource.bitmap.RoundedCorners
@ -96,15 +97,17 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
fun render(data: Data, mode: Mode, imageView: ImageView) { fun render(data: Data, mode: Mode, imageView: ImageView) {
val size = processSize(data, mode) val size = processSize(data, mode)
imageView.layoutParams.width = size.width imageView.updateLayoutParams {
imageView.layoutParams.height = size.height width = size.width
height = size.height
}
// a11y // a11y
imageView.contentDescription = data.filename imageView.contentDescription = data.filename
createGlideRequest(data, mode, imageView, size) createGlideRequest(data, mode, imageView, size)
.dontAnimate() .dontAnimate()
.transform(RoundedCorners(dimensionConverter.dpToPx(8))) .transform(RoundedCorners(dimensionConverter.dpToPx(8)))
.thumbnail(0.3f) // .thumbnail(0.3f)
.into(imageView) .into(imageView)
} }
@ -117,6 +120,9 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
} }
} }
/**
* Used by Attachment Viewer
*/
fun render(data: Data, contextView: View, target: CustomViewTarget<*, Drawable>) { fun render(data: Data, contextView: View, target: CustomViewTarget<*, Drawable>) {
val req = if (data.elementToDecrypt != null) { val req = if (data.elementToDecrypt != null) {
// Encrypted image // Encrypted image