From eb30b9fae9df12082b051d6cfa3bebe99c172ad8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 1 Dec 2020 17:11:05 +0100 Subject: [PATCH] Show preview when sending attachment from the keyboard (#2440) It's actually a revert of a3b205b310fa10c8a82b22c2bd3cbdd348ce92f3 --- CHANGES.md | 1 + .../home/room/detail/RoomDetailFragment.kt | 24 +++++++------------ .../home/room/detail/RoomDetailViewModel.kt | 3 --- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a4aa0b7a0f..206e48170f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ Bugfix 🐛: - Fix cancellation of sending event (#2438) - Double bottomsheet effect after verify with passphrase - EditText cursor jumps to the start while typing fast (#2469) + - Show preview when sending attachment from the keyboard (#2440) Translations 🗣: - diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index 29036a91fb..c471b90e8e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -1176,11 +1176,9 @@ class RoomDetailFragment @Inject constructor( } private fun sendUri(uri: Uri): Boolean { - roomDetailViewModel.preventAttachmentPreview = true val shareIntent = Intent(Intent.ACTION_SEND, uri) val isHandled = attachmentsHelper.handleShareIntent(requireContext(), shareIntent) if (!isHandled) { - roomDetailViewModel.preventAttachmentPreview = false Toast.makeText(requireContext(), R.string.error_handling_incoming_share, Toast.LENGTH_SHORT).show() } return isHandled @@ -1936,24 +1934,18 @@ class RoomDetailFragment @Inject constructor( // AttachmentsHelper.Callback override fun onContentAttachmentsReady(attachments: List) { - if (roomDetailViewModel.preventAttachmentPreview) { - roomDetailViewModel.preventAttachmentPreview = false - roomDetailViewModel.handle(RoomDetailAction.SendMedia(attachments, false)) - } else { - val grouped = attachments.toGroupedContentAttachmentData() - if (grouped.notPreviewables.isNotEmpty()) { - // Send the not previewable attachments right now (?) - roomDetailViewModel.handle(RoomDetailAction.SendMedia(grouped.notPreviewables, false)) - } - if (grouped.previewables.isNotEmpty()) { - val intent = AttachmentsPreviewActivity.newIntent(requireContext(), AttachmentsPreviewArgs(grouped.previewables)) - contentAttachmentActivityResultLauncher.launch(intent) - } + val grouped = attachments.toGroupedContentAttachmentData() + if (grouped.notPreviewables.isNotEmpty()) { + // Send the not previewable attachments right now (?) + roomDetailViewModel.handle(RoomDetailAction.SendMedia(grouped.notPreviewables, false)) + } + if (grouped.previewables.isNotEmpty()) { + val intent = AttachmentsPreviewActivity.newIntent(requireContext(), AttachmentsPreviewArgs(grouped.previewables)) + contentAttachmentActivityResultLauncher.launch(intent) } } override fun onAttachmentsProcessFailed() { - roomDetailViewModel.preventAttachmentPreview = false Toast.makeText(requireContext(), R.string.error_attachment, Toast.LENGTH_SHORT).show() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index 6db2a9205a..13362c8a2e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -128,9 +128,6 @@ class RoomDetailViewModel @AssistedInject constructor( // Slot to keep a pending action during permission request var pendingAction: RoomDetailAction? = null - // Slot to store if we want to prevent preview of attachment - var preventAttachmentPreview = false - private var trackUnreadMessages = AtomicBoolean(false) private var mostRecentDisplayedEvent: TimelineEvent? = null