2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Fix file opening

Summary: During the SharePlugin refactoring the way the mime type was determined changed which broke opening files from the desktop.

Test Plan: I can open pkpass/jsonld files in Itinerary again

Reviewers: #kde_connect, albertvaka

Reviewed By: #kde_connect, albertvaka

Subscribers: eduisters, kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D17976
This commit is contained in:
Nicolas Fella
2019-03-05 00:28:24 +01:00
parent 7648e8cf33
commit 1c89b0460a

View File

@@ -310,15 +310,16 @@ class CompositeReceiveFileRunnable implements Runnable {
}
private void openFile(DocumentFile fileDocument) {
String mimeType = FilesHelper.getMimeTypeFromFile(fileDocument.getName());
Intent intent = new Intent(Intent.ACTION_VIEW);
if (Build.VERSION.SDK_INT >= 24) {
//Nougat and later require "content://" uris instead of "file://" uris
File file = new File(fileDocument.getUri().getPath());
Uri contentUri = FileProvider.getUriForFile(device.getContext(), "org.kde.kdeconnect_tp.fileprovider", file);
intent.setDataAndType(contentUri, fileDocument.getType());
intent.setDataAndType(contentUri, mimeType);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {
intent.setDataAndType(fileDocument.getUri(), fileDocument.getType());
intent.setDataAndType(fileDocument.getUri(), mimeType);
}
device.getContext().startActivity(intent);