mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84d874332a | |||
| 9496c809d4 | |||
| 95ef05c512 |
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user