mirror of
https://github.com/element-hq/element-android
synced 2024-10-15 04:24:53 +00:00
Remove undocumented attribute and fix issue with image size when it contains exif rotation
This commit is contained in:
parent
f34f28b668
commit
3f9b7813bc
|
@ -17,6 +17,7 @@ Bugfix:
|
||||||
- Fix opening a permalink: the targeted event is displayed twice (#556)
|
- Fix opening a permalink: the targeted event is displayed twice (#556)
|
||||||
- Fix opening a permalink paginates all the history up to the last event (#282)
|
- Fix opening a permalink paginates all the history up to the last event (#282)
|
||||||
- after login, the icon in the top left is a green 'A' for (all communities) rather than my avatar (#267)
|
- after login, the icon in the top left is a green 'A' for (all communities) rather than my avatar (#267)
|
||||||
|
- Picture uploads are unreliable, pictures are shown in wrong aspect ratio on desktop client (#517)
|
||||||
|
|
||||||
Translations:
|
Translations:
|
||||||
-
|
-
|
||||||
|
|
|
@ -42,16 +42,6 @@ data class ImageInfo(
|
||||||
*/
|
*/
|
||||||
@Json(name = "size") val size: Int = 0,
|
@Json(name = "size") val size: Int = 0,
|
||||||
|
|
||||||
/**
|
|
||||||
* Not documented
|
|
||||||
*/
|
|
||||||
@Json(name = "rotation") val rotation: Int = 0,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Not documented
|
|
||||||
*/
|
|
||||||
@Json(name = "orientation") val orientation: Int = 0,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata about the image referred to in thumbnail_url.
|
* Metadata about the image referred to in thumbnail_url.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.matrix.android.internal.session.room.send
|
package im.vector.matrix.android.internal.session.room.send
|
||||||
|
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
|
import androidx.exifinterface.media.ExifInterface
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import im.vector.matrix.android.R
|
import im.vector.matrix.android.R
|
||||||
import im.vector.matrix.android.api.permalinks.PermalinkFactory
|
import im.vector.matrix.android.api.permalinks.PermalinkFactory
|
||||||
|
@ -173,14 +174,27 @@ internal class LocalEchoEventFactory @Inject constructor(@UserId private val use
|
||||||
|
|
||||||
|
|
||||||
private fun createImageEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
private fun createImageEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
||||||
|
var width = attachment.width
|
||||||
|
var height = attachment.height
|
||||||
|
|
||||||
|
when (attachment.exifOrientation) {
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_90,
|
||||||
|
ExifInterface.ORIENTATION_TRANSVERSE,
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_270,
|
||||||
|
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
||||||
|
val tmp = width
|
||||||
|
width = height
|
||||||
|
height = tmp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val content = MessageImageContent(
|
val content = MessageImageContent(
|
||||||
type = MessageType.MSGTYPE_IMAGE,
|
type = MessageType.MSGTYPE_IMAGE,
|
||||||
body = attachment.name ?: "image",
|
body = attachment.name ?: "image",
|
||||||
info = ImageInfo(
|
info = ImageInfo(
|
||||||
mimeType = attachment.mimeType,
|
mimeType = attachment.mimeType,
|
||||||
width = attachment.width?.toInt() ?: 0,
|
width = width?.toInt() ?: 0,
|
||||||
height = attachment.height?.toInt() ?: 0,
|
height = height?.toInt() ?: 0,
|
||||||
orientation = attachment.exifOrientation,
|
|
||||||
size = attachment.size.toInt()
|
size = attachment.size.toInt()
|
||||||
),
|
),
|
||||||
url = attachment.path
|
url = attachment.path
|
||||||
|
|
|
@ -189,9 +189,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
height = messageContent.info?.height,
|
height = messageContent.info?.height,
|
||||||
maxHeight = maxHeight,
|
maxHeight = maxHeight,
|
||||||
width = messageContent.info?.width,
|
width = messageContent.info?.width,
|
||||||
maxWidth = maxWidth,
|
maxWidth = maxWidth
|
||||||
orientation = messageContent.info?.orientation,
|
|
||||||
rotation = messageContent.info?.rotation
|
|
||||||
)
|
)
|
||||||
return MessageImageVideoItem_()
|
return MessageImageVideoItem_()
|
||||||
.attributes(attributes)
|
.attributes(attributes)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.exifinterface.media.ExifInterface
|
|
||||||
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
|
||||||
|
@ -49,9 +48,7 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
|
||||||
val height: Int?,
|
val height: Int?,
|
||||||
val maxHeight: Int,
|
val maxHeight: Int,
|
||||||
val width: Int?,
|
val width: Int?,
|
||||||
val maxWidth: Int,
|
val maxWidth: Int
|
||||||
val orientation: Int? = null,
|
|
||||||
val rotation: Int? = null
|
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
fun isLocalFile() = url.isLocalFile()
|
fun isLocalFile() = url.isLocalFile()
|
||||||
|
@ -152,26 +149,14 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
|
||||||
private fun processSize(data: Data, mode: Mode): Pair<Int, Int> {
|
private fun processSize(data: Data, mode: Mode): Pair<Int, Int> {
|
||||||
val maxImageWidth = data.maxWidth
|
val maxImageWidth = data.maxWidth
|
||||||
val maxImageHeight = data.maxHeight
|
val maxImageHeight = data.maxHeight
|
||||||
val rotationAngle = data.rotation ?: 0
|
val width = data.width ?: maxImageWidth
|
||||||
val orientation = data.orientation ?: ExifInterface.ORIENTATION_NORMAL
|
val height = data.height ?: maxImageHeight
|
||||||
var width = data.width ?: maxImageWidth
|
|
||||||
var height = data.height ?: maxImageHeight
|
|
||||||
var finalHeight = -1
|
var finalHeight = -1
|
||||||
var finalWidth = -1
|
var finalWidth = -1
|
||||||
|
|
||||||
// if the image size is known
|
// if the image size is known
|
||||||
// compute the expected height
|
// compute the expected height
|
||||||
if (width > 0 && height > 0) {
|
if (width > 0 && height > 0) {
|
||||||
// swap width and height if the image is side oriented
|
|
||||||
if (rotationAngle == 90 || rotationAngle == 270) {
|
|
||||||
val tmp = width
|
|
||||||
width = height
|
|
||||||
height = tmp
|
|
||||||
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_90 || orientation == ExifInterface.ORIENTATION_ROTATE_270) {
|
|
||||||
val tmp = width
|
|
||||||
width = height
|
|
||||||
height = tmp
|
|
||||||
}
|
|
||||||
if (mode == Mode.FULL_SIZE) {
|
if (mode == Mode.FULL_SIZE) {
|
||||||
finalHeight = height
|
finalHeight = height
|
||||||
finalWidth = width
|
finalWidth = width
|
||||||
|
|
Loading…
Reference in a new issue