Commit 1c89b046 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

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:
parent 7648e8cf
......@@ -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);
} else {
intent.setDataAndType(fileDocument.getUri(), fileDocument.getType());
intent.setDataAndType(fileDocument.getUri(), mimeType);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment