Open image from URL Preview (#2705)
This commit is contained in:
parent
f6ad67f1c8
commit
ed99b503f5
@ -5,7 +5,7 @@ Features ✨:
|
|||||||
-
|
-
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
-
|
- Open image from URL Preview (#2705)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Duplicate thumbs | Mobile reactions for 👍 and 👎 are not the same as web (#2776)
|
- 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))
|
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) {
|
private fun onShareActionClicked(action: EventSharedAction.Share) {
|
||||||
if (action.messageContent is MessageTextContent) {
|
if (action.messageContent is MessageTextContent) {
|
||||||
shareText(requireContext(), action.messageContent.body)
|
shareText(requireContext(), action.messageContent.body)
|
||||||
|
@ -130,6 +130,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||||||
interface PreviewUrlCallback {
|
interface PreviewUrlCallback {
|
||||||
fun onPreviewUrlClicked(url: String)
|
fun onPreviewUrlClicked(url: String)
|
||||||
fun onPreviewUrlCloseClicked(eventId: String, url: String)
|
fun onPreviewUrlCloseClicked(eventId: String, url: String)
|
||||||
|
fun onPreviewUrlImageClicked(sharedView: View?, mxcUrl: String?, title: String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map eventId to adapter position
|
// 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() {
|
private fun onCloseClick() {
|
||||||
when (val finalState = state) {
|
when (val finalState = state) {
|
||||||
is PreviewUrlUiState.Data -> delegate?.onPreviewUrlCloseClicked(finalState.eventId, finalState.url)
|
is PreviewUrlUiState.Data -> delegate?.onPreviewUrlCloseClicked(finalState.eventId, finalState.url)
|
||||||
@ -94,6 +107,7 @@ class PreviewUrlView @JvmOverloads constructor(
|
|||||||
views = UrlPreviewBinding.bind(this)
|
views = UrlPreviewBinding.bind(this)
|
||||||
|
|
||||||
setOnClickListener(this)
|
setOnClickListener(this)
|
||||||
|
views.urlPreviewImage.setOnClickListener { onImageClick() }
|
||||||
views.urlPreviewClose.setOnClickListener { onCloseClick() }
|
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.terms.TermsService
|
||||||
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
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.session.widgets.model.WidgetType
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@ -256,11 +255,11 @@ class DefaultNavigator @Inject constructor(
|
|||||||
context.startActivity(RoomProfileActivity.newIntent(context, roomId, directAccess))
|
context.startActivity(RoomProfileActivity.newIntent(context, roomId, directAccess))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openBigImageViewer(activity: Activity, sharedElement: View?, matrixItem: MatrixItem) {
|
override fun openBigImageViewer(activity: Activity, sharedElement: View?, mxcUrl: String?, title: String?) {
|
||||||
matrixItem.avatarUrl
|
mxcUrl
|
||||||
?.takeIf { it.isNotBlank() }
|
?.takeIf { it.isNotBlank() }
|
||||||
?.let { avatarUrl ->
|
?.let { avatarUrl ->
|
||||||
val intent = BigImageViewerActivity.newIntent(activity, matrixItem.getBestName(), avatarUrl)
|
val intent = BigImageViewerActivity.newIntent(activity, title, avatarUrl)
|
||||||
val options = sharedElement?.let {
|
val options = sharedElement?.let {
|
||||||
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, it, ViewCompat.getTransitionName(it) ?: "")
|
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, it, ViewCompat.getTransitionName(it) ?: "")
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,11 @@ interface Navigator {
|
|||||||
|
|
||||||
fun openRoomProfile(context: Context, roomId: String, directAccess: Int? = null)
|
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,
|
fun openPinCode(context: Context,
|
||||||
activityResultLauncher: ActivityResultLauncher<Intent>,
|
activityResultLauncher: ActivityResultLauncher<Intent>,
|
||||||
|
Loading…
Reference in New Issue
Block a user