mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 12:22:08 +01:00
Make sure Diaspora image folder exists before sharing/downloading images
This commit is contained in:
parent
392b76c53d
commit
9f39e3ca1c
1 changed files with 14 additions and 2 deletions
|
@ -108,11 +108,17 @@ public class ContextMenuWebView extends NestedWebView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (writeToStoragePermitted) {
|
if (writeToStoragePermitted) {
|
||||||
|
//Make sure, Diaspora Folder exists
|
||||||
|
File destinationFolder = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora");
|
||||||
|
if(!destinationFolder.exists()) {
|
||||||
|
destinationFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
Uri source = Uri.parse(url);
|
Uri source = Uri.parse(url);
|
||||||
DownloadManager.Request request = new DownloadManager.Request(source);
|
DownloadManager.Request request = new DownloadManager.Request(source);
|
||||||
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"
|
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"+ System.currentTimeMillis() + ".png");
|
||||||
+ System.currentTimeMillis() + ".png");
|
|
||||||
request.setDestinationUri(Uri.fromFile(destinationFile));
|
request.setDestinationUri(Uri.fromFile(destinationFile));
|
||||||
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
||||||
|
|
||||||
|
@ -150,6 +156,12 @@ public class ContextMenuWebView extends NestedWebView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (writeToStoragePermitted) {
|
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");
|
final Uri local = Uri.parse(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/" + System.currentTimeMillis() + ".png");
|
||||||
new ImageDownloadTask(null, local.getPath()) {
|
new ImageDownloadTask(null, local.getPath()) {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue