From ef3689f9b3303b70c207c715c08f1e7f2e0e99f4 Mon Sep 17 00:00:00 2001 From: Kirill Goncharov Date: Tue, 27 Aug 2019 14:34:43 +0300 Subject: [PATCH] fix(android): don't set EXTRA_MIME_TYPES when using 'Any' media type on Android Currently everything except images and videos is not selectable (text for example). This commit fixes it and partly reverts changes made in #290 and #291. --- src/imagepicker.android.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 5037f76..cc5c9cc 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -227,19 +227,13 @@ export class ImagePicker { let intent = new Intent(); intent.setType(this.mediaType); - let length = this.mediaType === "*/*" ? 2 : 1; - let mimeTypes = Array.create(java.lang.String, length); - - if (this.mediaType === "*/*") { - mimeTypes[0] = "image/*"; - mimeTypes[1] = "video/*"; - } - else { + if (this.mediaType !== '*/*') { + let mimeTypes = Array.create(java.lang.String, 1); mimeTypes[0] = this.mediaType; + // not in platform-declaration typings + intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, mimeTypes); } - // not in platform-declaration typings - intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, mimeTypes); // TODO: Use (android).content.Intent.EXTRA_ALLOW_MULTIPLE if (this.mode === 'multiple') { intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);