1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-22 19:08:03 +01:00

Make sure Diaspora image folder exists before sharing/downloading images

This commit is contained in:
vanitasvitae 2017-01-24 13:12:34 +01:00
parent 392b76c53d
commit 9f39e3ca1c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -108,11 +108,17 @@ public class ContextMenuWebView extends NestedWebView {
}
}
if (writeToStoragePermitted) {
//Make sure, Diaspora Folder exists
File destinationFolder = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora");
if(!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
if (url != null) {
Uri source = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(source);
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"
+ System.currentTimeMillis() + ".png");
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"+ System.currentTimeMillis() + ".png");
request.setDestinationUri(Uri.fromFile(destinationFile));
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
@ -150,6 +156,12 @@ public class ContextMenuWebView extends NestedWebView {
}
}
if (writeToStoragePermitted) {
//Make sure, Diaspora Folder exists
File destinationFolder = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora");
if(!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
final Uri local = Uri.parse(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/" + System.currentTimeMillis() + ".png");
new ImageDownloadTask(null, local.getPath()) {
@Override