From 80187b7215a5effdbe97ac48e8af34824a05c287 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 12 Jun 2018 11:11:14 -0700 Subject: [PATCH] Fix problems when domain settings changes settings before loading a new URL. https://redmine.stoutner.com/issues/286 --- .../privacybrowser/activities/MainWebViewActivity.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 74cb432a..97362dfe 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -1122,10 +1122,16 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("http")) { // Load the URL in Privacy Browser. + // Hide the WebView while applying domain settings so changes to things like JavaScript aren't rendered on the current URL, which otherwise will reload automatically. + mainWebView.setVisibility(View.INVISIBLE); + // Apply the domain settings for the new URL. applyDomainSettings(url, true, false); - // Returning false causes the current `WebView` to handle the URL and prevents it from adding redirects to the history list. + // Display the WebView again so that the new URL can be loaded. + mainWebView.setVisibility(View.VISIBLE); + + // Returning false causes the current WebView to handle the URL and prevents it from adding redirects to the history list. return false; } else if (url.startsWith("mailto:")) { // Load the email address in an external email program. // Use `ACTION_SENDTO` instead of `ACTION_SEND` so that only email programs are launched. -- 2.45.2