From 0aa7bea42122faca43fd4412e67bce87a9114930 Mon Sep 17 00:00:00 2001 From: mylmz10 Date: Mon, 29 Jul 2019 11:38:42 +0300 Subject: [PATCH 1/4] Added video support for android platform. --- src/imagepicker.android.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 09d8053..a46abe8 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -227,6 +227,12 @@ export class ImagePicker { let intent = new Intent(); intent.setType(this.mediaType); + let mimeTypes = Array.create(java.lang.String, 2); + mimeTypes[0] = 'image/*'; + mimeTypes[1] = 'video/*'; + // 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); From aff1c62d4a04dea8c1b7463726ff80edebe8afba Mon Sep 17 00:00:00 2001 From: mylmz10 Date: Mon, 29 Jul 2019 13:21:47 +0300 Subject: [PATCH 2/4] mimetype check add for mediaType --- src/imagepicker.android.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index a46abe8..876e216 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -227,9 +227,17 @@ export class ImagePicker { let intent = new Intent(); intent.setType(this.mediaType); - let mimeTypes = Array.create(java.lang.String, 2); - mimeTypes[0] = 'image/*'; - mimeTypes[1] = 'video/*'; + let length = this.mediaType === "*/*" ? 2 : 1; + let mimeTypes = Array.create(java.lang.String, length); + + if (this.mediaType === "*/*") { + mimeTypes[0] = "image/*"; + mimeTypes[1] = "video/*"; + } + else { + mimeTypes[0] = this.mediaType; + } + // not in platform-declaration typings intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, mimeTypes); From de77ed89add9a0b9fe6e6e51d16d8ec72357d7c4 Mon Sep 17 00:00:00 2001 From: mylmz10 Date: Tue, 30 Jul 2019 14:13:04 +0300 Subject: [PATCH 3/4] mediaType description change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 475aca3..7a0d25e 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ context | prompt | iOS | undefined | Display prompt text when selecting assets. | | numberOfColumnsInPortrait | iOS | 4 | Set the number of columns in Portrait orientation. | | numberOfColumnsInLandscape | iOS | 7 | Set the number of columns in Landscape orientation. | -| mediaType | both | Any (iOS), Image (Android) | Choose whether to pick Image/Video/Any type of assets. | +| mediaType | both | Any | Choose whether to pick Image/Video/Any type of assets. | The **hostView** parameter can be set to the view that hosts the image picker. Applicable in iOS only, intended to be used when open picker from a modal page. From 540856b1c73bb42a7f39582652bc569aeee60f43 Mon Sep 17 00:00:00 2001 From: mylmz10 Date: Tue, 30 Jul 2019 15:56:03 +0300 Subject: [PATCH 4/4] Default value of mediaType set "Any" for android --- src/imagepicker.android.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 876e216..54703b9 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -147,7 +147,7 @@ export class ImagePicker { } get mediaType(): string { - const mediaType = this._options && 'mediaType' in this._options ? this._options.mediaType : ImagePickerMediaType.Image; + const mediaType = this._options && 'mediaType' in this._options ? this._options.mediaType : ImagePickerMediaType.Any; if (mediaType === ImagePickerMediaType.Image) { return "image/*"; } else if (mediaType === ImagePickerMediaType.Video) {