From 795f9a729db8e842ec0e996b6b87a037ca138f2c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 7 Feb 2019 09:25:11 +0000 Subject: [PATCH] Optionally allow read storage --- FAQ.md | 2 ++ app/src/main/AndroidManifest.xml | 1 + app/src/main/java/eu/faircode/email/FragmentCompose.java | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/FAQ.md b/FAQ.md index 9454f27764..b04a274bc6 100644 --- a/FAQ.md +++ b/FAQ.md @@ -149,6 +149,7 @@ FairEmail follows all the best practices for an email client as decribed in [thi * *prevent device from sleeping* (WAKE_LOCK): to keep the device awake while synchronizing messages * Optional: *read your contacts* (READ_CONTACTS): to autocomplete addresses and to show photos * Optional: *find accounts on the device* (GET_ACCOUNTS): to use [OAuth](https://en.wikipedia.org/wiki/OAuth) instead of passwords +* Optional: *read the contents of your SD card* (READ_EXTERNAL_STORAGE): to accept files from other, outdated apps, see also [this FAQ](#user-content-faq49) * Android 5.1 Lollipop and before: *use accounts on the device* (USE_CREDENTIALS): needed to select accounts (not used/needed on later Android versions)
@@ -864,6 +865,7 @@ For security and privacy reasons modern apps like FairEmail have no full access This can result into the error message *An outdated app sent a file path instead of a file stream* when a file name instead of a file stream is presented to FairEmail. You can fix this by switching to an up-to-date file manager or an app designed for recent Android versions. +Alternatively, you can grant FairEmail read access to the storage space on your device in the Android app settings. See also [question 25](#user-content-faq25) and [what Google writes about it](https://developer.android.com/training/secure-file-sharing/share-file#RespondToRequest). diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 20d2bd371f..e217c8277e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ + diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 3edeeb56d6..6939c37ae8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1327,14 +1327,15 @@ public class FragmentCompose extends FragmentBase { private static EntityAttachment addAttachment(Context context, long id, Uri uri, boolean image) throws IOException { - if ("file".equals(uri.getScheme())) { + if ("file".equals(uri.getScheme()) && + !Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) { Log.w("Add attachment uri=" + uri); throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); } EntityAttachment attachment = new EntityAttachment(); - String name = null; + String name = uri.getLastPathSegment(); String s = null; Cursor cursor = null;