Show preview when sending attachment from the keyboard (#2440)
It's actually a revert of a3b205b310
This commit is contained in:
parent
38843f74ab
commit
eb30b9fae9
@ -15,6 +15,7 @@ Bugfix 🐛:
|
|||||||
- Fix cancellation of sending event (#2438)
|
- Fix cancellation of sending event (#2438)
|
||||||
- Double bottomsheet effect after verify with passphrase
|
- Double bottomsheet effect after verify with passphrase
|
||||||
- EditText cursor jumps to the start while typing fast (#2469)
|
- EditText cursor jumps to the start while typing fast (#2469)
|
||||||
|
- Show preview when sending attachment from the keyboard (#2440)
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
-
|
-
|
||||||
|
@ -1176,11 +1176,9 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun sendUri(uri: Uri): Boolean {
|
private fun sendUri(uri: Uri): Boolean {
|
||||||
roomDetailViewModel.preventAttachmentPreview = true
|
|
||||||
val shareIntent = Intent(Intent.ACTION_SEND, uri)
|
val shareIntent = Intent(Intent.ACTION_SEND, uri)
|
||||||
val isHandled = attachmentsHelper.handleShareIntent(requireContext(), shareIntent)
|
val isHandled = attachmentsHelper.handleShareIntent(requireContext(), shareIntent)
|
||||||
if (!isHandled) {
|
if (!isHandled) {
|
||||||
roomDetailViewModel.preventAttachmentPreview = false
|
|
||||||
Toast.makeText(requireContext(), R.string.error_handling_incoming_share, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.error_handling_incoming_share, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
return isHandled
|
return isHandled
|
||||||
@ -1936,24 +1934,18 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
// AttachmentsHelper.Callback
|
// AttachmentsHelper.Callback
|
||||||
|
|
||||||
override fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>) {
|
override fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>) {
|
||||||
if (roomDetailViewModel.preventAttachmentPreview) {
|
val grouped = attachments.toGroupedContentAttachmentData()
|
||||||
roomDetailViewModel.preventAttachmentPreview = false
|
if (grouped.notPreviewables.isNotEmpty()) {
|
||||||
roomDetailViewModel.handle(RoomDetailAction.SendMedia(attachments, false))
|
// Send the not previewable attachments right now (?)
|
||||||
} else {
|
roomDetailViewModel.handle(RoomDetailAction.SendMedia(grouped.notPreviewables, false))
|
||||||
val grouped = attachments.toGroupedContentAttachmentData()
|
}
|
||||||
if (grouped.notPreviewables.isNotEmpty()) {
|
if (grouped.previewables.isNotEmpty()) {
|
||||||
// Send the not previewable attachments right now (?)
|
val intent = AttachmentsPreviewActivity.newIntent(requireContext(), AttachmentsPreviewArgs(grouped.previewables))
|
||||||
roomDetailViewModel.handle(RoomDetailAction.SendMedia(grouped.notPreviewables, false))
|
contentAttachmentActivityResultLauncher.launch(intent)
|
||||||
}
|
|
||||||
if (grouped.previewables.isNotEmpty()) {
|
|
||||||
val intent = AttachmentsPreviewActivity.newIntent(requireContext(), AttachmentsPreviewArgs(grouped.previewables))
|
|
||||||
contentAttachmentActivityResultLauncher.launch(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttachmentsProcessFailed() {
|
override fun onAttachmentsProcessFailed() {
|
||||||
roomDetailViewModel.preventAttachmentPreview = false
|
|
||||||
Toast.makeText(requireContext(), R.string.error_attachment, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.error_attachment, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +128,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
// Slot to keep a pending action during permission request
|
// Slot to keep a pending action during permission request
|
||||||
var pendingAction: RoomDetailAction? = null
|
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 trackUnreadMessages = AtomicBoolean(false)
|
||||||
private var mostRecentDisplayedEvent: TimelineEvent? = null
|
private var mostRecentDisplayedEvent: TimelineEvent? = null
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user