Skip to content

Commit ef3689f

Browse files
committed
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 NativeScript#290 and NativeScript#291.
1 parent c93c574 commit ef3689f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/imagepicker.android.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,13 @@ export class ImagePicker {
227227
let intent = new Intent();
228228
intent.setType(this.mediaType);
229229

230-
let length = this.mediaType === "*/*" ? 2 : 1;
231-
let mimeTypes = Array.create(java.lang.String, length);
232-
233-
if (this.mediaType === "*/*") {
234-
mimeTypes[0] = "image/*";
235-
mimeTypes[1] = "video/*";
236-
}
237-
else {
230+
if (this.mediaType !== '*/*') {
231+
let mimeTypes = Array.create(java.lang.String, 1);
238232
mimeTypes[0] = this.mediaType;
233+
// not in platform-declaration typings
234+
intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, mimeTypes);
239235
}
240236

241-
// not in platform-declaration typings
242-
intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, mimeTypes);
243237
// TODO: Use (<any>android).content.Intent.EXTRA_ALLOW_MULTIPLE
244238
if (this.mode === 'multiple') {
245239
intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);

0 commit comments

Comments
 (0)