Android-AdvancedWebView
Android-AdvancedWebView copied to clipboard
feature add suggestion in handleDownload
some downloads need cookies because it's only accessible for logged users, i suggest you add a cookies parameter in the handleDownload function to be added to the request maybe something like this request.addRequestHeader("Cookie", cookies);
Good idea, thank you!
What about the following (more general) solution?
// DEFINITION OF THE CALLBACK:
public static interface DownloadManagerRequestConfigurator {
public void configure(Request request);
}
// ...
// INTERNAL USAGE OF THE CALLBACK:
public static boolean handleDownload(final Context context, final String fromUrl, final String toFilename, final DownloadManagerRequestConfigurator configurator) {
// ...
if (configurator != null) {
configurator(request);
}
// ...
}
// ...
// SUPPLYING THE CALLBACK WITH YOUR METHOD CALL:
AdvancedWebView.handleDownload(this, url, suggestedFilename, new DownloadManagerRequestConfigurator() {
public void configure(final Request request) {
request.addRequestHeader("Cookie", "...");
}
});
yeah that's even better keep up the good work!
Is this implemented now or planned for a near date? I also need this for the same scenario.
Yes, experimental support has been added in a separate branch here: https://github.com/delight-im/Android-AdvancedWebView/commit/7d23524a1838c681888d2c4068fa4d8fc97aafcb
If you would like to try this, please replace your Gradle dependency with
compile 'com.github.delight-im:Android-AdvancedWebView:7d23524a1838c681888d2c4068fa4d8fc97aafcb'
and add the following as the fourth parameter to the handleDownload method:
new AdvancedWebView.DownloadManagerRequestConfigurator() {
public void configure(final DownloadManager.Request request) {
// optionally configure the request instance here
}
}
Does that work for you?
Yes, this works perfectly. Please merge it to the master branch.