/*
- * Copyright 2015-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2015-2017 Soren Stoutner <soren@stoutner.com>.
*
* Download cookie code contributed 2017 Hendrik Knackstedt. Copyright assigned to Soren Stoutner <soren@stoutner.com>.
*
@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);
// 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;
}
}
return true;
case R.id.share:
+ // Setup the share string.
+ String shareString;
+ if (webViewTitle != null) {
+ shareString = webViewTitle + " – " + urlTextBox.getText().toString();
+ } else {
+ shareString = urlTextBox.getText().toString();
+ }
+
+ // Create the share intent.
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, urlTextBox.getText().toString());
+ shareIntent.putExtra(Intent.EXTRA_TEXT, shareString);
shareIntent.setType("text/plain");
+
+ // Make it so.
startActivity(Intent.createChooser(shareIntent, "Share URL"));
return true;
}, 200);
return true;
- case R.id.refresh:
- mainWebView.reload();
- return true;
-
case R.id.print:
// Get a `PrintManager` instance.
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
//Everything else will be handled by `CreateHomeScreenShortcutDialog` and the associated listener below.
return true;
+ case R.id.refresh:
+ mainWebView.reload();
+ return true;
+
default:
// Don't consume the event.
return super.onOptionsItemSelected(menuItem);
incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false);
boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false);
boolean proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
- fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("enable_full_screen_browsing_mode", false);
+ fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("full_screen_browsing_mode", false);
hideSystemBarsOnFullscreen = sharedPreferences.getBoolean("hide_system_bars", false);
translucentNavigationBarOnFullscreen = sharedPreferences.getBoolean("translucent_navigation_bar", true);
swipeToRefreshEnabled = sharedPreferences.getBoolean("swipe_to_refresh", false);