diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 4285b80..8a1d7f1 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -157,6 +157,20 @@ export class ImagePicker { } } + get mimeTypes() { + 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; + } + return mimeTypes; + } + authorize(): Promise { if ((android).os.Build.VERSION.SDK_INT >= 23) { return permissions.requestPermission([(android).Manifest.permission.READ_EXTERNAL_STORAGE]); @@ -227,19 +241,9 @@ 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 { - mimeTypes[0] = this.mediaType; - } - // not in platform-declaration typings - intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, mimeTypes); + intent.putExtra((android.content.Intent as any).EXTRA_MIME_TYPES, this.mimeTypes); + // TODO: Use (android).content.Intent.EXTRA_ALLOW_MULTIPLE if (this.mode === 'multiple') { intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true); diff --git a/src/index.d.ts b/src/index.d.ts index d28b76f..8a5b1a8 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -4,6 +4,9 @@ import { ImageAsset } from "tns-core-modules/image-asset"; import { View } from "tns-core-modules/ui/core/view/view"; export class ImagePicker { + + constructor(options?: Options); + /** * Call this before 'present' to request any additional permissions that may be necessary. * In case of failed authorization consider notifying the user for degraded functionality.