FileProvider: attempt to work with sd cards

This commit is contained in:
Daniel Gultsch 2017-11-08 20:34:08 +01:00
parent 0e12b2d19a
commit 459cf09f06
3 changed files with 21 additions and 6 deletions

View File

@ -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);
}

View File

@ -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<Message> 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;
}

View File

@ -1,8 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external" path="/"/>
<files-path path="Images/" name="pictures" />
<files-path path="Videos" name="videos"/>
<files-path path="Files/" name="files" />
<cache-path path="Camera/" name="camera" />
<external-path
name="external"
path="/"/>
<root-path
name="storage"
path="/storage/"/>
<files-path
name="pictures"
path="Images/"/>
<files-path
name="videos"
path="Videos"/>
<files-path
name="files"
path="Files/"/>
<cache-path
name="camera"
path="Camera/"/>
</paths>