]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Fix problems when domain settings changes settings before loading a new URL. https...
authorSoren Stoutner <soren@stoutner.com>
Tue, 12 Jun 2018 18:11:14 +0000 (11:11 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 12 Jun 2018 18:11:14 +0000 (11:11 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java

index 74cb432adc57ff185ca2e10b2f4cdb8e46917c57..97362dfe9cf5db1dda2d3d25ebecf4fac883d46b 100644 (file)
@@ -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.