X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=bef36d6a3de96444a723cf23bb4503c04be2c226;hp=cd7a164c44abac393c434c5720084393bdd4a4ef;hb=f825cc15f0383acce10bb16443e027edb869a11e;hpb=0e0e9f5c67bdc06877cbd19254fef6fc6cb69f2d diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index cd7a164c..bef36d6a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -5428,6 +5428,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the file name from the content disposition. String fileNameString = PrepareSaveDialog.getFileNameFromHeaders(this, contentDisposition, mimetype, downloadUrl); + // Prevent the dialog from displaying if the app window is not visible. + // The download listener continues to function even when the WebView is paused. Attempting to display a dialog in that state leads to a crash. + while (!activity.getWindow().isActive()) { + try { + // The window is not active. Wait 1 second. + wait(1000); + } catch (InterruptedException e) { + // Do nothing. + } + } + // Instantiate the save dialog. DialogFragment saveDialogFragment = SaveWebpageDialog.saveWebpage(StoragePermissionDialog.SAVE_URL, downloadUrl, formattedFileSizeString, fileNameString, userAgent, nestedScrollWebView.getAcceptFirstPartyCookies()); @@ -6429,6 +6440,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Store the SSL error handler. nestedScrollWebView.setSslErrorHandler(handler); + // Prevent the dialog from displaying if the app window is not visible. + // The SSL error handler continues to function even when the WebView is paused. Attempting to display a dialog in that state leads to a crash. + while (!activity.getWindow().isActive()) { + try { + // The window is not active. Wait 1 second. + wait(1000); + } catch (InterruptedException e) { + // Do nothing. + } + } + // Instantiate an SSL certificate error alert dialog. DialogFragment sslCertificateErrorDialogFragment = SslCertificateErrorDialog.displayDialog(error, nestedScrollWebView.getWebViewFragmentId());