1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Android: Fixes #6942: Fixed error when sharing a file (#7801)

This commit is contained in:
javad mnjd 2023-02-19 21:51:49 +03:30 committed by GitHub
parent 5c1eda3392
commit 21dbc800d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -22,8 +22,6 @@ public class DocumentStat {
private final Boolean isDirectory;
private final long size;
private final long lastModified;
private static final String encodedSlash = Uri.encode("/");
private static final String PATH_DOCUMENT = "document";
/**
* Cursor columns must be in the following format:
@ -51,11 +49,30 @@ public class DocumentStat {
this.internalUri = this.uri;
}
final int mimeTypeColIndex = c.getColumnIndex(DocumentsContract.Document.COLUMN_MIME_TYPE);
final int sizeColIndex = c.getColumnIndex(DocumentsContract.Document.COLUMN_SIZE);
final int lastModifiedColIndex = c.getColumnIndex(DocumentsContract.Document.COLUMN_LAST_MODIFIED);
this.displayName = c.getString(1);
this.mimeType = c.getString(2);
this.size = c.getLong(3);
this.lastModified = c.getLong(4);
if (mimeTypeColIndex != -1) {
this.mimeType = c.getString(mimeTypeColIndex);
} else {
this.mimeType = "*/*";
}
if (sizeColIndex != -1) {
this.size = c.getLong(sizeColIndex);
} else {
this.size = -1;
}
if (lastModifiedColIndex != -1) {
this.lastModified = c.getLong(lastModifiedColIndex);
}else {
this.lastModified = System.currentTimeMillis();
}
this.isDirectory = DocumentsContract.Document.MIME_TYPE_DIR.equals(this.mimeType);
}

View File

@ -95,7 +95,7 @@ public class EfficientDocumentHelper {
uri = Uri.fromFile(targetFile);
return uri;
} else if (UriHelper.isDocumentUri(uri)) {
} else if (UriHelper.isDocumentUri(uri) || !DocumentsContract.isTreeUri(uri)) {
// It's a document picked by user, nothing much we can do. operations limited.
DocumentStat stat = null;