From fd7c592347f6e5fb54e926e69b5093b37247d9a1 Mon Sep 17 00:00:00 2001 From: rmm-fl <143930462+rmm-fl@users.noreply.github.com> Date: Thu, 21 Sep 2023 01:32:16 +0530 Subject: [PATCH] Update picker to avoid showing svg images on android --- patches/react-native-image-picker+5.1.0.patch | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 patches/react-native-image-picker+5.1.0.patch diff --git a/patches/react-native-image-picker+5.1.0.patch b/patches/react-native-image-picker+5.1.0.patch new file mode 100644 index 000000000000..0defc430e669 --- /dev/null +++ b/patches/react-native-image-picker+5.1.0.patch @@ -0,0 +1,133 @@ +diff --git a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModuleImpl.java b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModuleImpl.java +index 89b69a8..d86ab1e 100644 +--- a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModuleImpl.java ++++ b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModuleImpl.java +@@ -29,6 +29,120 @@ public class ImagePickerModuleImpl implements ActivityEventListener { + public static final int REQUEST_LAUNCH_VIDEO_CAPTURE = 13002; + public static final int REQUEST_LAUNCH_LIBRARY = 13003; + ++ // Prevent svg images from being selected as they are not supported (Image component does not support them) ++ // and also because iOS does not allow them to be selected (for consistency). ++ // Since, we can't exclude a mime type, we instead allow all image mime types except 'image/svg+xml'. ++ // Image mime types are generated by merging the Android image mime type support and the IANA media-types lists. ++ // https://android.googlesource.com/platform/external/mime-support/+/main/mime.types#636 ++ // https://www.iana.org/assignments/media-types/media-types.xhtml#image ++ private static final String[] ALLOWED_IMAGE_MIME_TYPES = { ++ "image/aces", ++ "image/apng", ++ "image/avci", ++ "image/avcs", ++ "image/avif", ++ "image/bmp", ++ "image/cgm", ++ "image/dicom-rle", ++ "image/dpx", ++ "image/emf", ++ "image/example", ++ "image/fits", ++ "image/g3fax", ++ "image/gif", ++ "image/heic-sequence", ++ "image/heic", ++ "image/heif-sequence", ++ "image/heif", ++ "image/hej2k", ++ "image/hsj2", ++ "image/ief", ++ "image/j2c", ++ "image/jls", ++ "image/jp2", ++ "image/jpeg", ++ "image/jph", ++ "image/jphc", ++ "image/jpm", ++ "image/jpx", ++ "image/jxr", ++ "image/jxrA", ++ "image/jxrS", ++ "image/jxs", ++ "image/jxsc", ++ "image/jxsi", ++ "image/jxss", ++ "image/ktx", ++ "image/ktx2", ++ "image/naplps", ++ "image/pcx", ++ "image/png", ++ "image/prs.btif", ++ "image/prs.pti", ++ "image/pwg-raster", ++ // "image/svg+xml", ++ "image/t38", ++ "image/tiff-fx", ++ "image/tiff", ++ "image/vnd.adobe.photoshop", ++ "image/vnd.airzip.accelerator.azv", ++ "image/vnd.cns.inf2", ++ "image/vnd.dece.graphic", ++ "image/vnd.djvu", ++ "image/vnd.dvb.subtitle", ++ "image/vnd.dwg", ++ "image/vnd.dxf", ++ "image/vnd.fastbidsheet", ++ "image/vnd.fpx", ++ "image/vnd.fst", ++ "image/vnd.fujixerox.edmics-mmr", ++ "image/vnd.fujixerox.edmics-rlc", ++ "image/vnd.globalgraphics.pgb", ++ "image/vnd.microsoft.icon", ++ "image/vnd.mix", ++ "image/vnd.mozilla.apng", ++ "image/vnd.ms-modi", ++ "image/vnd.net-fpx", ++ "image/vnd.pco.b16", ++ "image/vnd.radiance", ++ "image/vnd.sealed.png", ++ "image/vnd.sealedmedia.softseal.gif", ++ "image/vnd.sealedmedia.softseal.jpg", ++ "image/vnd.svf", ++ "image/vnd.tencent.tap", ++ "image/vnd.valve.source.texture", ++ "image/vnd.wap.wbmp", ++ "image/vnd.xiff", ++ "image/vnd.zbrush.pcx", ++ "image/webp", ++ "image/wmf", ++ "image/x-canon-cr2", ++ "image/x-canon-crw", ++ "image/x-cmu-raster", ++ "image/x-coreldraw", ++ "image/x-coreldrawpattern", ++ "image/x-coreldrawtemplate", ++ "image/x-corelphotopaint", ++ "image/x-emf", ++ "image/x-epson-erf", ++ "image/x-icon", ++ "image/x-jg", ++ "image/x-jng", ++ "image/x-ms-bmp", ++ "image/x-nikon-nef", ++ "image/x-olympus-orf", ++ "image/x-photoshop", ++ "image/x-portable-anymap", ++ "image/x-portable-bitmap", ++ "image/x-portable-graymap", ++ "image/x-portable-pixmap", ++ "image/x-rgb", ++ "image/x-wmf", ++ "image/x-xbitmap", ++ "image/x-xpixmap", ++ "image/x-xwindowdump", ++ }; ++ + private Uri fileUri; + + private ReactApplicationContext reactContext; +@@ -148,6 +262,7 @@ public class ImagePickerModuleImpl implements ActivityEventListener { + + if (isPhoto) { + libraryIntent.setType("image/*"); ++ libraryIntent.putExtra(Intent.EXTRA_MIME_TYPES, this.ALLOWED_IMAGE_MIME_TYPES); + } else if (isVideo) { + libraryIntent.setType("video/*"); + } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {