add untested download code
parent
a6cf5ad190
commit
6f11b5eeba
|
@ -6,6 +6,7 @@
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
|
@ -3,7 +3,10 @@ package gallery.memories;
|
||||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.DownloadManager;
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -24,12 +27,14 @@ import gallery.memories.service.TimelineQuery;
|
||||||
public class NativeX {
|
public class NativeX {
|
||||||
public static final String TAG = "NativeX";
|
public static final String TAG = "NativeX";
|
||||||
Activity mActivity;
|
Activity mActivity;
|
||||||
|
WebView mWebView;
|
||||||
|
|
||||||
protected ImageService mImageService;
|
protected ImageService mImageService;
|
||||||
protected TimelineQuery mQuery;
|
protected TimelineQuery mQuery;
|
||||||
|
|
||||||
public NativeX(Activity activity, WebView webView) {
|
public NativeX(Activity activity, WebView webView) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
|
mWebView = webView;
|
||||||
mImageService = new ImageService(activity);
|
mImageService = new ImageService(activity);
|
||||||
mQuery = new TimelineQuery(activity);
|
mQuery = new TimelineQuery(activity);
|
||||||
}
|
}
|
||||||
|
@ -82,6 +87,21 @@ public class NativeX {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void downloadFromUrl(final String url) {
|
||||||
|
Uri uri = Uri.parse(url);
|
||||||
|
DownloadManager manager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
|
DownloadManager.Request request = new DownloadManager.Request(uri);
|
||||||
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
|
||||||
|
|
||||||
|
// Copy all cookies from the webview to the download request
|
||||||
|
String cookies = android.webkit.CookieManager.getInstance().getCookie(url);
|
||||||
|
request.addRequestHeader("cookie", cookies);
|
||||||
|
|
||||||
|
// Start the download
|
||||||
|
manager.enqueue(request);
|
||||||
|
}
|
||||||
|
|
||||||
protected WebResourceResponse routerGet(final String path) throws Exception {
|
protected WebResourceResponse routerGet(final String path) throws Exception {
|
||||||
String[] parts = path.split("/");
|
String[] parts = path.split("/");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue