Compare commits

...

1 Commits

Author SHA1 Message Date
ericdecanini
92322aa4c6 Adds conditional transition logic on opening images 2022-06-09 15:05:34 +02:00
9 changed files with 35 additions and 11 deletions

View File

@ -2008,7 +2008,7 @@ class TimelineFragment @Inject constructor(
activity = requireActivity(),
roomId = timelineArgs.roomId,
mediaData = mediaData,
view = view
view = view,
) { pairs ->
pairs.add(Pair(views.roomToolbar, ViewCompat.getTransitionName(views.roomToolbar) ?: ""))
pairs.add(Pair(views.composerLayout, ViewCompat.getTransitionName(views.composerLayout) ?: ""))

View File

@ -515,6 +515,7 @@ class MessageItemFactory @Inject constructor(
filename = messageContent.body,
mimeType = messageContent.mimeType,
url = messageContent.getFileUrl(),
filesize = messageContent.info?.size,
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
height = messageContent.info?.height,
maxHeight = maxHeight,
@ -557,6 +558,7 @@ class MessageItemFactory @Inject constructor(
filename = messageContent.body,
mimeType = messageContent.mimeType,
url = messageContent.videoInfo?.getThumbnailUrl(),
filesize = messageContent.videoInfo?.size,
elementToDecrypt = messageContent.videoInfo?.thumbnailFile?.toElementToDecrypt(),
height = messageContent.videoInfo?.height,
maxHeight = maxHeight,
@ -570,6 +572,7 @@ class MessageItemFactory @Inject constructor(
filename = messageContent.body,
mimeType = messageContent.mimeType,
url = messageContent.getFileUrl(),
filesize = messageContent.videoInfo?.size,
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
thumbnailMediaData = thumbnailData
)

View File

@ -36,6 +36,7 @@ fun TimelineEvent.buildImageContentRendererData(maxHeight: Int): ImageContentRen
filename = messageImageContent.body,
mimeType = messageImageContent.mimeType,
url = messageImageContent.getFileUrl(),
filesize = messageImageContent.info?.size,
elementToDecrypt = messageImageContent.encryptedFileInfo?.toElementToDecrypt(),
height = messageImageContent.info?.height,
maxHeight = maxHeight,
@ -52,6 +53,7 @@ fun TimelineEvent.buildImageContentRendererData(maxHeight: Int): ImageContentRen
filename = messageVideoContent.body,
mimeType = videoInfo?.thumbnailInfo?.mimeType,
url = videoInfo?.getThumbnailUrl(),
filesize = messageVideoContent.videoInfo?.size,
elementToDecrypt = videoInfo?.thumbnailFile?.toElementToDecrypt(),
height = videoInfo?.thumbnailInfo?.height,
maxHeight = maxHeight,

View File

@ -57,6 +57,7 @@ interface AttachmentData : Parcelable {
val filename: String
val mimeType: String?
val url: String?
val filesize: Long?
val elementToDecrypt: ElementToDecrypt?
// If true will load non mxc url, be careful to set it only for attachments sent by you
@ -79,6 +80,7 @@ class ImageContentRenderer @Inject constructor(
override val filename: String,
override val mimeType: String?,
override val url: String?,
override val filesize: Long?,
override val elementToDecrypt: ElementToDecrypt?,
val height: Int?,
val maxHeight: Int,
@ -254,7 +256,6 @@ class ImageContentRenderer @Inject constructor(
return false
}
})
.onlyRetrieveFromCache(true)
.fitCenter()
.into(imageView)
}

View File

@ -63,6 +63,7 @@ class RoomEventsAttachmentProvider(
filename = content.body,
mimeType = content.mimeType,
url = content.getFileUrl(),
filesize = content.info?.size,
elementToDecrypt = content.encryptedFileInfo?.toElementToDecrypt(),
maxHeight = -1,
maxWidth = -1,
@ -90,6 +91,7 @@ class RoomEventsAttachmentProvider(
filename = content.body,
mimeType = content.mimeType,
url = content.getFileUrl(),
filesize = content.info?.size,
elementToDecrypt = content.encryptedFileInfo?.toElementToDecrypt(),
maxHeight = -1,
maxWidth = -1,
@ -117,6 +119,7 @@ class RoomEventsAttachmentProvider(
filename = content.body,
mimeType = content.mimeType,
url = content.videoInfo?.getThumbnailUrl(),
filesize = content.videoInfo?.size,
elementToDecrypt = content.videoInfo?.thumbnailFile?.toElementToDecrypt(),
height = content.videoInfo?.height,
maxHeight = -1,
@ -131,6 +134,7 @@ class RoomEventsAttachmentProvider(
url = content.getFileUrl(),
elementToDecrypt = content.encryptedFileInfo?.toElementToDecrypt(),
thumbnailMediaData = thumbnailData,
filesize = content.videoInfo?.size,
allowNonMxcUrls = it.root.sendState.isSending()
)
AttachmentInfo.Video(
@ -154,7 +158,7 @@ class RoomEventsAttachmentProvider(
}
}
override fun getTimelineEventAtPosition(position: Int): TimelineEvent? {
override fun getTimelineEventAtPosition(position: Int): TimelineEvent {
return getItem(position)
}

View File

@ -51,6 +51,7 @@ class VideoContentRenderer @Inject constructor(
override val filename: String,
override val mimeType: String?,
override val url: String?,
override val filesize: Long?,
override val elementToDecrypt: ElementToDecrypt?,
val thumbnailMediaData: ImageContentRenderer.Data,
// If true will load non mxc url, be careful to set it only for video sent by you

View File

@ -76,6 +76,7 @@ import im.vector.app.features.matrixto.MatrixToBottomSheet
import im.vector.app.features.matrixto.OriginOfMatrixTo
import im.vector.app.features.media.AttachmentData
import im.vector.app.features.media.BigImageViewerActivity
import im.vector.app.features.media.ImageContentRenderer
import im.vector.app.features.media.VectorAttachmentViewerActivity
import im.vector.app.features.onboarding.OnboardingActivity
import im.vector.app.features.pin.PinActivity
@ -539,14 +540,18 @@ class DefaultNavigator @Inject constructor(
inMemory: List<AttachmentData>,
options: ((MutableList<Pair<View, String>>) -> Unit)?
) {
VectorAttachmentViewerActivity.newIntent(
val intent = VectorAttachmentViewerActivity.newIntent(
activity,
mediaData,
roomId,
mediaData.eventId,
inMemory,
ViewCompat.getTransitionName(view)
).let { intent ->
)
val shouldTransition = mediaData !is ImageContentRenderer.Data || (mediaData.filesize ?: 0) < 1000000
if (shouldTransition) {
val pairs = ArrayList<Pair<View, String>>()
activity.window.decorView.findViewById<View>(android.R.id.statusBarBackground)?.let {
pairs.add(Pair(it, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME))
@ -560,6 +565,8 @@ class DefaultNavigator @Inject constructor(
val bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, *pairs.toTypedArray()).toBundle()
activity.startActivity(intent, bundle)
} else {
activity.startActivity(intent)
}
}

View File

@ -112,7 +112,7 @@ class RoomUploadsMediaFragment @Inject constructor(
roomId = state.roomId,
mediaData = mediaData,
view = view,
inMemory = inMemory
inMemory = inMemory,
) { pairs ->
trickFindAppBar()?.let {
pairs.add(Pair(it, ViewCompat.getTransitionName(it) ?: ""))
@ -129,11 +129,12 @@ class RoomUploadsMediaFragment @Inject constructor(
filename = content.body,
mimeType = content.mimeType,
url = content.getFileUrl(),
filesize = content.info?.size,
elementToDecrypt = content.encryptedFileInfo?.toElementToDecrypt(),
maxHeight = -1,
maxWidth = -1,
width = null,
height = null
height = null,
)
}
is MessageVideoContent -> {
@ -142,17 +143,19 @@ class RoomUploadsMediaFragment @Inject constructor(
filename = content.body,
mimeType = content.mimeType,
url = content.videoInfo?.getThumbnailUrl(),
filesize = content.videoInfo?.size,
elementToDecrypt = content.videoInfo?.thumbnailFile?.toElementToDecrypt(),
height = content.videoInfo?.height,
maxHeight = -1,
width = content.videoInfo?.width,
maxWidth = -1
maxWidth = -1,
)
VideoContentRenderer.Data(
eventId = it.eventId,
filename = content.body,
mimeType = content.mimeType,
url = content.getFileUrl(),
filesize = content.videoInfo?.size,
elementToDecrypt = content.encryptedFileInfo?.toElementToDecrypt(),
thumbnailMediaData = thumbnailData
)
@ -169,7 +172,7 @@ class RoomUploadsMediaFragment @Inject constructor(
roomId = state.roomId,
mediaData = mediaData,
view = view,
inMemory = inMemory
inMemory = inMemory,
) { pairs ->
trickFindAppBar()?.let {
pairs.add(Pair(it, ViewCompat.getTransitionName(it) ?: ""))

View File

@ -111,11 +111,12 @@ class UploadsMediaController @Inject constructor(
filename = messageContent.body,
url = messageContent.getFileUrl(),
mimeType = messageContent.mimeType,
filesize = messageContent.info?.size,
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
height = messageContent.info?.height,
maxHeight = itemSize,
width = messageContent.info?.width,
maxWidth = itemSize
maxWidth = itemSize,
)
}
@ -127,11 +128,12 @@ class UploadsMediaController @Inject constructor(
filename = messageContent.body,
mimeType = messageContent.mimeType,
url = messageContent.videoInfo?.getThumbnailUrl(),
filesize = messageContent.videoInfo?.size,
elementToDecrypt = messageContent.videoInfo?.thumbnailFile?.toElementToDecrypt(),
height = messageContent.videoInfo?.height,
maxHeight = itemSize,
width = messageContent.videoInfo?.width,
maxWidth = itemSize
maxWidth = itemSize,
)
return VideoContentRenderer.Data(
@ -139,6 +141,7 @@ class UploadsMediaController @Inject constructor(
filename = messageContent.body,
mimeType = messageContent.mimeType,
url = messageContent.getFileUrl(),
filesize = messageContent.videoInfo?.size,
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
thumbnailMediaData = thumbnailData
)