From ce3c3ae251f5c491df4dad1a5973525888f7f1e9 Mon Sep 17 00:00:00 2001 From: tgpetrov Date: Tue, 10 Jul 2018 14:02:35 +0300 Subject: [PATCH 1/3] chore: allow only local files for picking --- src/imagepicker.android.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index 1c1ab94..fb0f9af 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -196,7 +196,11 @@ export class ImagePicker { intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true); } - intent.setAction(Intent.ACTION_GET_CONTENT); + intent.putExtra(android.content.Intent.EXTRA_LOCAL_ONLY, true); + intent.putExtra(android.content.Intent.CATEGORY_OPENABLE, true); + intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + intent.setAction(android.content.Intent.ACTION_PICK); + let chooser = Intent.createChooser(intent, "Select Picture"); application.android.foregroundActivity.startActivityForResult(intent, RESULT_CODE_PICKER_IMAGES); From b0c14f75f869586a388fbdb35e4a763661753856 Mon Sep 17 00:00:00 2001 From: tgpetrov Date: Fri, 13 Jul 2018 15:26:09 +0300 Subject: [PATCH 2/3] chore: webpack dependencies removed from ngdemo --- demo-angular/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/demo-angular/package.json b/demo-angular/package.json index 9f3c8b9..2b8f1ce 100644 --- a/demo-angular/package.json +++ b/demo-angular/package.json @@ -26,7 +26,6 @@ "tns-core-modules": "^4.0.0" }, "devDependencies": { - "@angular/compiler-cli": "~6.1.0-beta.1", "babel-traverse": "6.24.1", "babel-types": "6.24.1", "babylon": "6.16.1", @@ -42,8 +41,7 @@ "tns-platform-declarations": "^3.0.0", "tslint": "~5.4.3", "typescript": "~2.7.2", - "zone.js": "^0.8.4", - "@ngtools/webpack": "6.1.0-rc.0" + "zone.js": "^0.8.4" }, "scripts": { "build.plugin": "cd ../src && npm run build", From 49121645e02f19e4da5318268a3e39de19476e10 Mon Sep 17 00:00:00 2001 From: tgpetrov Date: Tue, 17 Jul 2018 09:47:49 +0300 Subject: [PATCH 3/3] refactor: use open document intent --- src/imagepicker.android.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/imagepicker.android.ts b/src/imagepicker.android.ts index fb0f9af..8a927e9 100644 --- a/src/imagepicker.android.ts +++ b/src/imagepicker.android.ts @@ -26,6 +26,11 @@ class UriHelper { // DownloadsProvider else if (UriHelper.isDownloadsDocument(uri)) { id = DocumentsContract.getDocumentId(uri); + // Since Oreo the downloads id may be a raw string, + // containing the file path: + if (id.indexOf("raw:") !== -1) { + return id.substring(4, id.length); + } contentUri = android.content.ContentUris.withAppendedId( android.net.Uri.parse("content://downloads/public_downloads"), long(id)); @@ -197,11 +202,7 @@ export class ImagePicker { } intent.putExtra(android.content.Intent.EXTRA_LOCAL_ONLY, true); - intent.putExtra(android.content.Intent.CATEGORY_OPENABLE, true); - intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); - intent.setAction(android.content.Intent.ACTION_PICK); - - + intent.setAction("android.intent.action.OPEN_DOCUMENT"); let chooser = Intent.createChooser(intent, "Select Picture"); application.android.foregroundActivity.startActivityForResult(intent, RESULT_CODE_PICKER_IMAGES); });