Skip to content

Instantly share code, notes, and snippets.

@t4kemyh4nd
Created July 19, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t4kemyh4nd/e57b228d0725c00b6c6e5f2f951a0964 to your computer and use it in GitHub Desktop.
Save t4kemyh4nd/e57b228d0725c00b6c6e5f2f951a0964 to your computer and use it in GitHub Desktop.
this.webView.setDownloadListener(new DownloadListener() {
public final void onDownloadStart(String str, String str2, String str3, String str4, long j) {
String str5;
if (!bhr.O000000o(WebActivity.this.getApplicationContext(), "android.permission.WRITE_EXTERNAL_STORAGE")) {
bhh.O000000o(WebActivity.this.getApplicationContext(), (int) R.string.storage_permission_error, 1);
return;
}
WebActivity.this.addDownloadListener();
Context applicationContext = WebActivity.this.getApplicationContext();
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
String cookie = CookieManager.getInstance().getCookie(beb.O0000oO);
bfs O0000o00 = bfs.O0000o00();
if (O0000o00.O0000o0O()) {
O0000o00.O00000Oo();
bec.O000000o.O00000oO();
if (O0000o00.O000000o(bec.O000000o.O00000o0()) == null) {
str5 = null;
} else {
bec.O000000o.O00000oO();
str5 = O0000o00.O000000o(bec.O000000o.O00000o0()).authToken;
}
cookie = bfc.O000000o("serviceToken", str5, bec.O00000Oo.O000000o, "/" + beb.O0000oo0, (String) null) + cookie;
}
bsd.O000000o((Object) cookie);
request.addRequestHeader("Cookie", cookie);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(1);
if (Build.VERSION.SDK_INT >= 16) {
request.setAllowedOverMetered(false);
}
request.setVisibleInDownloadsUi(true);
request.setAllowedOverRoaming(true);
request.setAllowedNetworkTypes(2);
String guessFileName = URLUtil.guessFileName(str, str3, str4);
bsd.O000000o((Object) "fileName:".concat(String.valueOf(guessFileName)));
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, guessFileName);
((DownloadManager) applicationContext.getSystemService("download")).enqueue(request);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment