Compare commits

...

3 Commits

Author SHA1 Message Date
adb 84d874332a Merge branch 'main' into copilot/fix-xcf-attachments-crash 2025-12-05 23:25:48 +01:00
copilot-swe-agent[bot] 9496c809d4 Fix crash when exporting XCF attachments with image/* MIME type
XCF files with MIME type image/x-xcf (or similar non-standard image types)
cause a crash when exported because Android's MediaStore only accepts
standard image formats.

Added isMediaStoreImageType() helper to check if MIME type is a standard
image format (JPEG, PNG, GIF, WebP, BMP, HEIC, HEIF, AVIF). Non-standard
image types like XCF and PSD are now saved to Downloads instead.

Fixes: XCF attachments crash issue

Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
2025-12-05 01:08:39 +00:00
copilot-swe-agent[bot] 95ef05c512 Initial plan 2025-12-05 01:01:24 +00:00
@@ -152,13 +152,34 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
return StorageUtil.getVideoUri();
} else if (contentType.startsWith("audio/")) {
return StorageUtil.getAudioUri();
} else if (contentType.startsWith("image/")) {
} else if (isMediaStoreImageType(contentType)) {
return StorageUtil.getImageUri();
} else {
return StorageUtil.getDownloadUri();
}
}
/**
* Checks if the content type is a standard image format supported by Android's MediaStore.
* Non-standard image formats (like XCF, PSD, etc.) should be saved to Downloads instead.
*/
private boolean isMediaStoreImageType(@NonNull String contentType) {
if (!contentType.startsWith("image/")) {
return false;
}
// Standard image formats supported by Android MediaStore
// Note: image/jpg is non-standard but included for compatibility with systems that use it
return contentType.equals("image/jpeg") ||
contentType.equals("image/jpg") ||
contentType.equals("image/png") ||
contentType.equals("image/gif") ||
contentType.equals("image/webp") ||
contentType.equals("image/bmp") ||
contentType.equals("image/heic") ||
contentType.equals("image/heif") ||
contentType.equals("image/avif");
}
private @Nullable File ensureExternalPath(@Nullable File path) {
if (path != null && path.exists()) {
return path;
@@ -197,7 +218,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
} else if (contentType.startsWith("audio/")) {
storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
} else if (contentType.startsWith("image/")) {
} else if (isMediaStoreImageType(contentType)) {
storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
}