Fix crash when editing image

This commit is contained in:
Benoit Marty 2020-02-26 17:45:39 +01:00
parent b8eeede5fd
commit b5a402c1e1

View file

@ -201,7 +201,9 @@ class AttachmentsPreviewFragment @Inject constructor(
private fun doHandleEditAction() = withState(viewModel) {
val currentAttachment = it.attachments.getOrNull(it.currentAttachmentIndex) ?: return@withState
val destinationFile = File(requireContext().cacheDir, "${currentAttachment.name}_edited_image_${System.currentTimeMillis()}")
UCrop.of(currentAttachment.queryUri.toUri(), destinationFile.toUri())
// Note: using currentAttachment.queryUri.toUri() make the app crash when sharing from Google Photos
val uri = File(currentAttachment.path).toUri()
UCrop.of(uri, destinationFile.toUri())
.withOptions(
UCrop.Options()
.apply {