Skip to content

Commit 0569c35

Browse files
committed
fix(chrome-downloads): update to support pie api changes
Allows selection of files that have been downloaded from chrome
1 parent b8a66e6 commit 0569c35

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/imagepicker.android.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ class UriHelper {
2525
}
2626
// DownloadsProvider
2727
else if (UriHelper.isDownloadsDocument(uri)) {
28-
id = DocumentsContract.getDocumentId(uri);
29-
// Since Oreo the downloads id may be a raw string,
30-
// containing the file path:
31-
if (id.indexOf("raw:") !== -1) {
32-
return id.substring(4, id.length);
33-
}
34-
contentUri = android.content.ContentUris.withAppendedId(
35-
android.net.Uri.parse("content://downloads/public_downloads"), long(id));
36-
37-
return UriHelper.getDataColumn(contentUri, null, null);
28+
return UriHelper.getDataColumn(uri, null, null);
3829
}
3930
// MediaProvider
4031
else if (UriHelper.isMediaDocument(uri)) {
@@ -73,15 +64,17 @@ class UriHelper {
7364

7465
private static getDataColumn(uri: android.net.Uri, selection, selectionArgs) {
7566
let cursor = null;
76-
let columns = [android.provider.MediaStore.MediaColumns.DATA];
7767
let filePath;
68+
let columns = ["_display_name"];
7869

7970
try {
8071
cursor = this.getContentResolver().query(uri, columns, selection, selectionArgs, null);
8172
if (cursor != null && cursor.moveToFirst()) {
8273
let column_index = cursor.getColumnIndexOrThrow(columns[0]);
8374
filePath = cursor.getString(column_index);
8475
if (filePath) {
76+
const dl = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS);
77+
filePath = `${dl}/${filePath}`;
8578
return filePath;
8679
}
8780
}

0 commit comments

Comments
 (0)