Skip to content

Commit 905e5ed

Browse files
authored
Update CustomWebView.java
1 parent 2523b7e commit 905e5ed

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

CustomWebView.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,12 @@ public void PrintWebContent(String documentName)throws Exception{
14461446
}
14471447
}
14481448
}
1449+
@SimpleFunction(description = "Hides previously shown custom view")
1450+
public void HideCustomView(){
1451+
if (webView != null) {
1452+
webView.getWebChromeClient().onHideCustomView();
1453+
}
1454+
}
14491455
@SimpleFunction(description="Restarts current/previous print job. You can request restart of a failed print job.")
14501456
public void RestartPrinting()throws Exception{
14511457
boolean printFinished = false;
@@ -1471,7 +1477,6 @@ public void CancelJsRequests(){
14711477
mFilePathCallback = null;
14721478
}
14731479
}
1474-
@SimpleFunction(description= "Downloads the file from url")
14751480
public void Download(String url,String mimeType,String contentDisposition,String fileName,String downloadDir){
14761481
if (!hasWriteAccess){
14771482
new Handler().post(new Runnable() {
@@ -1497,14 +1502,18 @@ public void HandlePermissionResponse(String permission, boolean granted) {
14971502
request.addRequestHeader("User-Agent", UserAgent);
14981503
request.setDescription("Downloading file...");
14991504
request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType));
1500-
request.allowScanningByMediaScanner();
1505+
//request.allowScanningByMediaScanner();
15011506
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
15021507
if (downloadDir.isEmpty()){
15031508
dir = Environment.DIRECTORY_DOWNLOADS;
15041509
}else if (fileName.isEmpty()){
15051510
name = URLUtil.guessFileName(url, contentDisposition, mimeType);
15061511
}
1507-
request.setDestinationInExternalPublicDir(dir, name);
1512+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
1513+
request.setDestinationInExternalFilesDir(context,dir,name);
1514+
}else {
1515+
request.setDestinationInExternalPublicDir(dir, name);
1516+
}
15081517
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
15091518
dm.enqueue(request);
15101519
}
@@ -1635,7 +1644,7 @@ protected void onCreate(Bundle saved){
16351644
}
16361645
}
16371646
}
1638-
// thanks to gregko (https://stackoverflow.com/a/13445760)
1647+
// thanks to Gregko (https://stackoverflow.com/a/13445760)
16391648
public abstract static class WebArchiveReader {
16401649
private Document myDoc = null;
16411650
private boolean myLoadingArchive = false;

0 commit comments

Comments
 (0)