]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Don't add URL redirects to the history list. Implements https://redmine.stoutner...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index 3c832ae3ed2ec5806ac596f6dfa6f9a0f467d80e..a7dfad7e6831f198d03bded1742a29a58c1e51d6 100644 (file)
@@ -568,8 +568,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             @SuppressWarnings("deprecation")
             @Override
             public boolean shouldOverrideUrlLoading(WebView view, String url) {
-                // Use an external email program if the link begins with `mailto:`.
-                if (url.startsWith("mailto:")) {
+                if (url.startsWith("mailto:")) {  // Load the URL in an external email program because it begins with `mailto:`.
                     // We use `ACTION_SENDTO` instead of `ACTION_SEND` so that only email programs are launched.
                     Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
 
@@ -581,10 +580,15 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
                     // Make it so.
                     startActivity(emailIntent);
+
+                    // Returning `true` indicates the application is handling the URL.
                     return true;
                 } else {  // Load the URL in Privacy Browser.
-                    loadUrl(url);
-                    return true;
+                    // Apply the domain settings for the new URL.
+                    applyDomainSettings(url);
+
+                    // Returning `false` causes the current `WebView` to handle the URL and prevents it from adding redirects to the history list.
+                    return false;
                 }
             }