+ case "enable_full_screen_browsing_mode":
+ boolean newFullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("enable_full_screen_browsing_mode", false);
+ if (newFullScreenBrowsingModeEnabled) {
+ // Enable `hideSystemBarsPreference`.
+ hideSystemBarsPreference.setEnabled(true);
+
+ // Only enable `transparent_navigation_bar` if `hide_system_bars` is `false`.
+ translucentNavigationBarPreference.setEnabled(!sharedPreferences.getBoolean("hide_system_bars", false));
+ } else {
+ // Disable the full screen options.
+ hideSystemBarsPreference.setEnabled(false);
+ translucentNavigationBarPreference.setEnabled(false);
+ }
+ break;
+
+ case "proxy_through_orbot":
+ // Get current settings.
+ boolean currentProxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
+ String currentTorJavaScriptDisabledSearchString = sharedPreferences.getString("tor_javascript_disabled_search", "https://3g2upl4pq6kufc4m.onion/html/?q=");
+ String currentTorJavaScriptEnabledSearchString = sharedPreferences.getString("tor_javascript_enabled_search", "https://3g2upl4pq6kufc4m.onion/?q=");
+
+ // Enable the Tor preferences only if `proxy_through_orbot` is enabled. The default is `false`.
+ torHomepagePreference.setEnabled(currentProxyThroughOrbot);
+ torJavaScriptDisabledSearchPreference.setEnabled(currentProxyThroughOrbot);
+ torJavaScriptEnabledSearchPreference.setEnabled(currentProxyThroughOrbot);
+
+ // Enable the Tor custom URL search options only if `currentProxyThroughOrbot` is true and the search is set to `Custom URL`.
+ torJavaScriptDisabledSearchCustomURLPreference.setEnabled(currentProxyThroughOrbot && currentTorJavaScriptDisabledSearchString.equals("Custom URL"));
+ torJavaScriptEnabledSearchCustomURLPreference.setEnabled(currentProxyThroughOrbot && currentTorJavaScriptEnabledSearchString.equals("Custom URL"));
+ break;
+
+ case "tor_homepage":
+ // Set the new tor homepage URL as the summary text for the `tor_homepage` preference. The default is DuckDuckGo: `https://3g2upl4pq6kufc4m.onion`.
+ torHomepagePreference.setSummary(sharedPreferences.getString("tor_homepage", "https://3g2upl4pq6kufc4m.onion"));
+ break;
+
+ case "tor_javascript_disabled_search":
+ // Get the present search string.
+ String presentTorJavaScriptDisabledSearchString = sharedPreferences.getString("tor_javascript_disabled_search", "https://3g2upl4pq6kufc4m.onion/html/?q=");
+
+ // Set the summary text for `tor_javascript_disabled_search`.
+ if (presentTorJavaScriptDisabledSearchString.equals("Custom URL")) {
+ // Use R.string.custom_url, which is translated, instead of the array value, which isn't.
+ torJavaScriptDisabledSearchPreference.setSummary(R.string.custom_url);
+ } else {
+ // Set the array value as the summary text.
+ torJavaScriptDisabledSearchPreference.setSummary(presentTorJavaScriptDisabledSearchString);
+ }
+
+ // Set the status of `torJavaScriptDisabledSearchCustomURLPreference`.
+ torJavaScriptDisabledSearchCustomURLPreference.setEnabled(presentTorJavaScriptDisabledSearchString.equals("Custom URL"));
+ break;
+
+ case "tor_javascript_disabled_search_custom_url":
+ // Set the summary text for `tor_javascript_disabled_search_custom_url`.
+ torJavaScriptDisabledSearchCustomURLPreference.setSummary(sharedPreferences.getString("tor_javascript_disabled_search_custom_url", ""));
+ break;
+
+ case "tor_javascript_enabled_search":
+ // Get the present search string.
+ String presentTorJavaScriptEnabledSearchString = sharedPreferences.getString("tor_javascript_enabled_search", "https://3g2upl4pq6kufc4m.onion/?q=");
+
+ // Set the summary text for `tor_javascript_enabled_search`.
+ if (presentTorJavaScriptEnabledSearchString.equals("Custom URL")) {
+ // Use R.string.custom_url, which is translated, instead of the array value, which isn't.
+ torJavaScriptEnabledSearchPreference.setSummary(R.string.custom_url);
+ } else {
+ // Set the array value as the summary text.
+ torJavaScriptEnabledSearchPreference.setSummary(presentTorJavaScriptEnabledSearchString);
+ }
+
+ // Set the status of `torJavaScriptEnabledSearchCustomURLPreference`.
+ torJavaScriptEnabledSearchCustomURLPreference.setEnabled(presentTorJavaScriptEnabledSearchString.equals("Custom URL"));
+ break;
+
+ case "tor_javascript_enabled_search_custom_url":
+ // Set the summary text for `tor_javascript_enabled_search_custom_url`.
+ torJavaScriptEnabledSearchCustomURLPreference.setSummary(sharedPreferences.getString("tor_javascript_enabled_search_custom_url", ""));
+ break;
+