From: Soren Stoutner Date: Tue, 12 Jun 2018 18:11:14 +0000 (-0700) Subject: Fix problems when domain settings changes settings before loading a new URL. https... X-Git-Tag: v2.11~3 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=80187b7215a5effdbe97ac48e8af34824a05c287;p=PrivacyBrowserAndroid.git Fix problems when domain settings changes settings before loading a new URL. https://redmine.stoutner.com/issues/286 --- 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.