No preview for elements sent from the keyboard

This commit is contained in:
Benoit Marty 2020-02-17 14:48:12 +01:00
parent ca0cd9e97d
commit a3b205b310
2 changed files with 18 additions and 8 deletions

View file

@ -650,9 +650,11 @@ class RoomDetailFragment @Inject constructor(
}
private fun sendUri(uri: Uri): Boolean {
roomDetailViewModel.preventAttachmentPreview = true
val shareIntent = Intent(Intent.ACTION_SEND, uri)
val isHandled = attachmentsHelper.handleShareIntent(shareIntent)
if (!isHandled) {
roomDetailViewModel.preventAttachmentPreview = false
Toast.makeText(requireContext(), R.string.error_handling_incoming_share, Toast.LENGTH_SHORT).show()
}
return isHandled
@ -1347,18 +1349,24 @@ class RoomDetailFragment @Inject constructor(
// AttachmentsHelper.Callback
override fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>) {
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))
startActivityForResult(intent, AttachmentsPreviewActivity.REQUEST_CODE)
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))
startActivityForResult(intent, AttachmentsPreviewActivity.REQUEST_CODE)
}
}
}
override fun onAttachmentsProcessFailed() {
roomDetailViewModel.preventAttachmentPreview = false
Toast.makeText(requireContext(), R.string.error_attachment, Toast.LENGTH_SHORT).show()
}

View file

@ -115,6 +115,8 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
var pendingAction: RoomDetailAction? = null
// Slot to keep a pending uri during permission request
var pendingUri: Uri? = 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