diff --git a/res/values/strings.xml b/res/values/strings.xml index d49d5acc..486b91a8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -316,7 +316,7 @@ This plugin needs permissions to work You need to grant extra permissions to enable all functions Some plugins have features disabled because of lack of permission (tap for more info): - To receive shared files you need to choose a destination directory + To receive files you need to allow storage access To read and write SMS from your desktop you need to give permission to SMS To see phone calls on the desktop you need to give permission to phone call logs and phone state To see a contact name instead of a phone number you need to give access to the phone\'s contacts diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java index c5b8945e..9c89e6c8 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java @@ -132,20 +132,15 @@ class ReceiveNotification { } } - if (!"file".equals(destinationUri.getScheme())) { - return; - } - Intent intent = new Intent(Intent.ACTION_VIEW); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType(mimeType); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && "file".equals(destinationUri.getScheme())) { //Nougat and later require "content://" uris instead of "file://" uris File file = new File(destinationUri.getPath()); Uri contentUri = FileProvider.getUriForFile(device.getContext(), "org.kde.kdeconnect_tp.fileprovider", file); intent.setDataAndType(contentUri, mimeType); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); } else { intent.setDataAndType(destinationUri, mimeType); diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java index f178b4c8..97c36428 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java @@ -13,7 +13,9 @@ import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.os.Looper; import android.util.Log; @@ -23,6 +25,7 @@ import androidx.annotation.NonNull; import androidx.annotation.WorkerThread; import androidx.core.content.ContextCompat; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.kde.kdeconnect.Helpers.FilesHelper; import org.kde.kdeconnect.Helpers.IntentHelper; @@ -127,12 +130,7 @@ public class SharePlugin extends Plugin { } if (np.has("filename")) { - if (isPermissionGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - receiveFile(np); - } else { - Log.i("SharePlugin", "no Permission for Storage"); - } - + receiveFile(np); } else if (np.has("text")) { Log.i("SharePlugin", "hasText"); receiveText(np); @@ -289,7 +287,11 @@ public class SharePlugin extends Plugin { @Override public String[] getOptionalPermissions() { - return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + return ArrayUtils.EMPTY_STRING_ARRAY; + } else { + return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}; + } } private class Callback implements BackgroundJob.Callback {