Skip to content

Commit

Permalink
fix(android): support raw document identifiers (#11395)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27406
  • Loading branch information
garymathews authored and sgtcoolguy committed Jan 9, 2020
1 parent 16fa664 commit c2d89d4
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ protected void init()
} else if (url.startsWith("content://com.android.providers.downloads.documents")) {
// This was a file downloaded from the Google cloud.
String id = DocumentsContract.getDocumentId(Uri.parse(url));
Uri uri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
try (Cursor cursor = contentResolver.query(uri, projection, null, null, null)) {
if ((cursor != null) && cursor.moveToNext()) {
this.name = getStringFrom(cursor, 0);
this.path = getStringFrom(cursor, 1);
try {
if (id.startsWith("raw:")) {
this.path = id.substring(4);
this.name = this.path.substring(this.path.lastIndexOf(File.pathSeparatorChar) + 1);
} else {
Uri uri =
ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
Cursor cursor = contentResolver.query(uri, projection, null, null, null);
if ((cursor != null) && cursor.moveToNext()) {
this.name = getStringFrom(cursor, 0);
this.path = getStringFrom(cursor, 1);
}
}
} catch (Exception ex) {
}
Expand Down

0 comments on commit c2d89d4

Please sign in to comment.