+ case R.id.user_agent_privacy_browser:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[0]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_webview_default:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString("");
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_firefox_on_android:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[2]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_chrome_on_android:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[3]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_safari_on_ios:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[4]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_firefox_on_linux:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[5]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_chromium_on_linux:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[6]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_firefox_on_windows:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[7]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_chrome_on_windows:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[8]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_edge_on_windows:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[9]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_internet_explorer_on_windows:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[10]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_safari_on_macos:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(getResources().getStringArray(R.array.user_agent_data)[11]);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.user_agent_custom:
+ // Update the user agent.
+ mainWebView.getSettings().setUserAgentString(defaultCustomUserAgentString);
+
+ // Reload the WebView.
+ mainWebView.reload();
+ return true;
+
+ case R.id.font_size_twenty_five_percent:
+ mainWebView.getSettings().setTextZoom(25);
+ return true;
+
+ case R.id.font_size_fifty_percent:
+ mainWebView.getSettings().setTextZoom(50);
+ return true;
+
+ case R.id.font_size_seventy_five_percent:
+ mainWebView.getSettings().setTextZoom(75);
+ return true;
+
+ case R.id.font_size_one_hundred_percent:
+ mainWebView.getSettings().setTextZoom(100);
+ return true;
+
+ case R.id.font_size_one_hundred_twenty_five_percent:
+ mainWebView.getSettings().setTextZoom(125);
+ return true;
+
+ case R.id.font_size_one_hundred_fifty_percent:
+ mainWebView.getSettings().setTextZoom(150);
+ return true;
+
+ case R.id.font_size_one_hundred_seventy_five_percent:
+ mainWebView.getSettings().setTextZoom(175);
+ return true;
+
+ case R.id.font_size_two_hundred_percent:
+ mainWebView.getSettings().setTextZoom(200);
+ return true;
+
+ case R.id.swipe_to_refresh:
+ // Toggle swipe to refresh.
+ swipeRefreshLayout.setEnabled(!swipeRefreshLayout.isEnabled());
+ return true;
+
+ case R.id.display_images:
+ if (mainWebView.getSettings().getLoadsImagesAutomatically()) { // Images are currently loaded automatically.
+ mainWebView.getSettings().setLoadsImagesAutomatically(false);
+ mainWebView.reload();
+ } else { // Images are not currently loaded automatically.
+ mainWebView.getSettings().setLoadsImagesAutomatically(true);
+ }
+
+ // Set `onTheFlyDisplayImagesSet`.
+ onTheFlyDisplayImagesSet = true;
+ return true;
+
+ case R.id.night_mode:
+ // Toggle night mode.
+ nightMode = !nightMode;
+
+ // Enable or disable JavaScript according to night mode, the global preference, and any domain settings.
+ if (nightMode) { // Night mode is enabled. Enable JavaScript.
+ // Update the global variable.
+ javaScriptEnabled = true;
+ } else if (domainSettingsApplied) { // Night mode is disabled and domain settings are applied. Set JavaScript according to the domain settings.
+ // Get the JavaScript preference that was stored the last time domain settings were loaded.
+ javaScriptEnabled = domainSettingsJavaScriptEnabled;
+ } else { // Night mode is disabled and domain settings are not applied. Set JavaScript according to the global preference.
+ // Get a handle for the shared preference.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+ // Get the JavaScript preference.
+ javaScriptEnabled = sharedPreferences.getBoolean("javascript_enabled", false);
+ }
+
+ // Apply the JavaScript setting to the WebView.
+ mainWebView.getSettings().setJavaScriptEnabled(javaScriptEnabled);
+
+ // Update the privacy icons.
+ updatePrivacyIcons(false);
+
+ // Reload the website.
+ mainWebView.reload();
+ return true;
+
+ case R.id.view_source:
+ // Launch the View Source activity.
+ Intent viewSourceIntent = new Intent(this, ViewSourceActivity.class);
+ startActivity(viewSourceIntent);
+ return true;
+