From 459cf09f06541b47c7ea1d8ce64e96a0ac181eff Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 8 Nov 2017 20:34:08 +0100 Subject: [PATCH] FileProvider: attempt to work with sd cards --- .../persistance/FileBackend.java | 2 +- .../ui/adapter/MessageAdapter.java | 2 ++ src/main/res/xml/file_paths.xml | 23 +++++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index dca426fc1..c1bf21ea0 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -515,7 +515,7 @@ public class FileBackend { return FileProvider.getUriForFile(context, packageId + FILE_PROVIDER, file); } catch(IllegalArgumentException e) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - throw new SecurityException(); + throw new SecurityException(e); } else { return Uri.fromFile(file); } diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index b450bb030..2cfcb127e 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -22,6 +22,7 @@ import android.text.style.RelativeSizeSpan; import android.text.style.StyleSpan; import android.text.util.Linkify; import android.util.DisplayMetrics; +import android.util.Log; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; @@ -967,6 +968,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie try { uri = FileBackend.getUriForFile(activity, file); } catch (SecurityException e) { + Log.d(Config.LOGTAG,"No permission to access "+file.getAbsolutePath(),e); Toast.makeText(activity, activity.getString(R.string.no_permission_to_access_x, file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); return; } diff --git a/src/main/res/xml/file_paths.xml b/src/main/res/xml/file_paths.xml index 4147940e8..813b1b5f0 100644 --- a/src/main/res/xml/file_paths.xml +++ b/src/main/res/xml/file_paths.xml @@ -1,8 +1,21 @@ - - - - - + + + + + + \ No newline at end of file