mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Open image from URL Preview (#2705)
This commit is contained in:
parent
f6ad67f1c8
commit
ed99b503f5
6 changed files with 28 additions and 6 deletions
|
@ -5,7 +5,7 @@ Features ✨:
|
|||
-
|
||||
|
||||
Improvements 🙌:
|
||||
-
|
||||
- Open image from URL Preview (#2705)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Duplicate thumbs | Mobile reactions for 👍 and 👎 are not the same as web (#2776)
|
||||
|
|
|
@ -1687,6 +1687,10 @@ class RoomDetailFragment @Inject constructor(
|
|||
roomDetailViewModel.handle(RoomDetailAction.DoNotShowPreviewUrlFor(eventId, url))
|
||||
}
|
||||
|
||||
override fun onPreviewUrlImageClicked(sharedView: View?, mxcUrl: String?, title: String?) {
|
||||
navigator.openBigImageViewer(requireActivity(), sharedView, mxcUrl, title)
|
||||
}
|
||||
|
||||
private fun onShareActionClicked(action: EventSharedAction.Share) {
|
||||
if (action.messageContent is MessageTextContent) {
|
||||
shareText(requireContext(), action.messageContent.body)
|
||||
|
|
|
@ -130,6 +130,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
interface PreviewUrlCallback {
|
||||
fun onPreviewUrlClicked(url: String)
|
||||
fun onPreviewUrlCloseClicked(eventId: String, url: String)
|
||||
fun onPreviewUrlImageClicked(sharedView: View?, mxcUrl: String?, title: String?)
|
||||
}
|
||||
|
||||
// Map eventId to adapter position
|
||||
|
|
|
@ -80,6 +80,19 @@ class PreviewUrlView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun onImageClick() {
|
||||
when (val finalState = state) {
|
||||
is PreviewUrlUiState.Data -> {
|
||||
delegate?.onPreviewUrlImageClicked(
|
||||
sharedView = views.urlPreviewImage,
|
||||
mxcUrl = finalState.previewUrlData.mxcUrl,
|
||||
title = finalState.previewUrlData.title
|
||||
)
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
private fun onCloseClick() {
|
||||
when (val finalState = state) {
|
||||
is PreviewUrlUiState.Data -> delegate?.onPreviewUrlCloseClicked(finalState.eventId, finalState.url)
|
||||
|
@ -94,6 +107,7 @@ class PreviewUrlView @JvmOverloads constructor(
|
|||
views = UrlPreviewBinding.bind(this)
|
||||
|
||||
setOnClickListener(this)
|
||||
views.urlPreviewImage.setOnClickListener { onImageClick() }
|
||||
views.urlPreviewClose.setOnClickListener { onCloseClick() }
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ import org.matrix.android.sdk.api.session.room.model.thirdparty.RoomDirectoryDat
|
|||
import org.matrix.android.sdk.api.session.terms.TermsService
|
||||
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
||||
import org.matrix.android.sdk.api.session.widgets.model.WidgetType
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -256,11 +255,11 @@ class DefaultNavigator @Inject constructor(
|
|||
context.startActivity(RoomProfileActivity.newIntent(context, roomId, directAccess))
|
||||
}
|
||||
|
||||
override fun openBigImageViewer(activity: Activity, sharedElement: View?, matrixItem: MatrixItem) {
|
||||
matrixItem.avatarUrl
|
||||
override fun openBigImageViewer(activity: Activity, sharedElement: View?, mxcUrl: String?, title: String?) {
|
||||
mxcUrl
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?.let { avatarUrl ->
|
||||
val intent = BigImageViewerActivity.newIntent(activity, matrixItem.getBestName(), avatarUrl)
|
||||
val intent = BigImageViewerActivity.newIntent(activity, title, avatarUrl)
|
||||
val options = sharedElement?.let {
|
||||
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, it, ViewCompat.getTransitionName(it) ?: "")
|
||||
}
|
||||
|
|
|
@ -80,7 +80,11 @@ interface Navigator {
|
|||
|
||||
fun openRoomProfile(context: Context, roomId: String, directAccess: Int? = null)
|
||||
|
||||
fun openBigImageViewer(activity: Activity, sharedElement: View?, matrixItem: MatrixItem)
|
||||
fun openBigImageViewer(activity: Activity, sharedElement: View?, matrixItem: MatrixItem) {
|
||||
openBigImageViewer(activity, sharedElement, matrixItem.avatarUrl, matrixItem.getBestName())
|
||||
}
|
||||
|
||||
fun openBigImageViewer(activity: Activity, sharedElement: View?, mxcUrl: String?, title: String?)
|
||||
|
||||
fun openPinCode(context: Context,
|
||||
activityResultLauncher: ActivityResultLauncher<Intent>,
|
||||
|
|
Loading…
Reference in a new issue