From e8baff42733f6cf99b407542493616ae74e54174 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Mon, 8 May 2023 20:30:23 -0700 Subject: [PATCH] dl: filename --- app/src/main/java/gallery/memories/NativeX.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/gallery/memories/NativeX.java b/app/src/main/java/gallery/memories/NativeX.java index d353b39c..71062b92 100644 --- a/app/src/main/java/gallery/memories/NativeX.java +++ b/app/src/main/java/gallery/memories/NativeX.java @@ -88,7 +88,7 @@ public class NativeX { } @JavascriptInterface - public void downloadFromUrl(final String url) { + public void downloadFromUrl(final String url, final String filename) { Uri uri = Uri.parse(url); DownloadManager manager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(uri); @@ -98,6 +98,9 @@ public class NativeX { String cookies = android.webkit.CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); + // Save the file to external storage + request.setDestinationInExternalPublicDir(android.os.Environment.DIRECTORY_DOWNLOADS, "memories/" + filename); + // Start the download manager.enqueue(request); }