forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-native-image-picker+7.1.2+001+allowedMimeTypes.patch
133 lines (130 loc) · 4.7 KB
/
react-native-image-picker+7.1.2+001+allowedMimeTypes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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 afe4b3e..0f35bc2 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
@@ -31,6 +31,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;
@@ -150,6 +264,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) {