+ case "tor_search":
+ // Get the present search string.
+ String presentTorSearchString = sharedPreferences.getString("tor_search", "https://3g2upl4pq6kufc4m.onion/html/?q=");
+
+ // Update the preferences.
+ if (presentTorSearchString.equals("Custom URL")) {
+ // Use `R.string.custom_url`, which is translated, as the summary instead of the array value, which isn't.
+ torSearchPreference.setSummary(R.string.custom_url);
+
+ // Update `torSearchCustomURLPreference`.
+ torSearchCustomURLPreference.setEnabled(true);
+ torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled);
+ } else {
+ // Set the array value as the summary text.
+ torSearchPreference.setSummary(presentTorSearchString);
+
+ // Update `torSearchCustomURLPreference`.
+ torSearchCustomURLPreference.setEnabled(false);
+ torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_disabled);
+ }
+ break;
+
+ case "tor_search_custom_url":
+ // Set the summary text for `tor_search_custom_url`.
+ torSearchCustomURLPreference.setSummary(sharedPreferences.getString("tor_search_custom_url", ""));
+ break;
+
+ case "search":
+ // Store the new search string.
+ String newSearchString = sharedPreferences.getString("search", "https://duckduckgo.com/html/?q=");
+
+ // Update `searchPreference` and `searchCustomURLPreference`.
+ if (newSearchString.equals("Custom URL")) { // `Custom URL` is selected.
+ // Set the summary text to `R.string.custom_url`, which is translated.
+ searchPreference.setSummary(R.string.custom_url);
+
+ // Update `searchCustomURLPreference`.
+ searchCustomURLPreference.setEnabled(true);
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled);
+ } else { // `Custom URL` is not selected.
+ // Set the summary text to `newSearchString`.
+ searchPreference.setSummary(newSearchString);
+
+ // Update `searchCustomURLPreference`.
+ searchCustomURLPreference.setEnabled(false);
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted);
+ }
+ break;
+
+ case "search_custom_url":
+ // Set the new custom search URL as the summary text for `search_custom_url`. The default is `""`.
+ searchCustomURLPreference.setSummary(sharedPreferences.getString("search_custom_url", ""));
+ break;
+
+ case "full_screen_browsing_mode":
+ if (sharedPreferences.getBoolean("full_screen_browsing_mode", false)) {
+ // Set `fullScreenBrowsingModePreference` to use the enabled icon.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled);
+
+ if (sharedPreferences.getBoolean("hide_system_bars", false)) {
+ // Set `hideSystemBarsPreference` to use the enabled icon.
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_enabled);
+
+ // Update `translucentNavigationBarPreference`.
+ translucentNavigationBarPreference.setEnabled(false);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted);
+ } else { // `hide_system_bars` is false.
+ // Set `hideSystemBarsPreference` to use the disabled icon.
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_disabled);
+
+ // Update `translucentNavigationBarPreference`.
+ translucentNavigationBarPreference.setEnabled(true);
+ if (sharedPreferences.getBoolean("translucent_navigation_bar", true)) {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_enabled);
+ } else {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_disabled);
+ }
+ }
+ } else { // `full_screen_browsing_mode` is false.
+ // Disable `translucentNavigationBarPreference`.
+ translucentNavigationBarPreference.setEnabled(false);
+
+ // Update the icons.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled);
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_ghosted);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted);
+ }
+ break;
+
+ case "hide_system_bars":
+ if (sharedPreferences.getBoolean("hide_system_bars", false)) {
+ // Set `hideSystemBarsPreference` to use the enabled icon.
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_enabled);
+
+ // Update `translucentNavigationBarPreference`.
+ translucentNavigationBarPreference.setEnabled(false);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted);
+ } else { // `hide_system_bars` is false.
+ // Set `hideSystemBarsPreference` to use the disabled icon.
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_disabled);
+
+ // Update `translucentNavigationBarPreference`.
+ translucentNavigationBarPreference.setEnabled(true);
+ if (sharedPreferences.getBoolean("translucent_navigation_bar", true)) {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_enabled);
+ } else {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_disabled);
+ }
+ }
+ break;
+
+ case "translucent_navigation_bar":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("translucent_navigation_bar", true)) {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_enabled);
+ } else {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_disabled);
+ }
+ break;
+
+ case "clear_everything":
+ // Store the new `clear_everything` status
+ boolean newClearEverythingBoolean = sharedPreferences.getBoolean("clear_everything", true);
+
+ // Update the status of the `Clear and Exit` preferences.
+ clearCookiesPreference.setEnabled(!newClearEverythingBoolean);
+ clearDomStoragePreference.setEnabled(!newClearEverythingBoolean);
+ clearFormDataPreference.setEnabled(!newClearEverythingBoolean);
+ clearCachePreference.setEnabled(!newClearEverythingBoolean);
+
+ // Update the `clearEverythingPreference` icon.
+ if (newClearEverythingBoolean) {
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled);
+ } else {
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled);
+ }
+
+ // Update the `clearCookiesPreference` icon.
+ if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cookies", true)) {
+ clearCookiesPreference.setIcon(R.drawable.cookies_cleared);
+ } else {
+ clearCookiesPreference.setIcon(R.drawable.cookies_warning);
+ }
+
+ // Update the `clearDomStoragePreference` icon.
+ if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_dom_storage", true)) {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared);
+ } else {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning);
+ }
+
+ // Update the `clearFormDataPreference` icon.
+ if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_form_data", true)) {
+ clearFormDataPreference.setIcon(R.drawable.form_data_cleared);
+ } else {
+ clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ }
+
+ // Update the `clearCachePreference` icon.
+ if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cache", true)) {
+ clearCachePreference.setIcon(R.drawable.cache_cleared);
+ } else {
+ clearCachePreference.setIcon(R.drawable.cache_warning);
+ }
+ break;
+
+ case "clear_cookies":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("clear_cookies", true)) {
+ clearCookiesPreference.setIcon(R.drawable.cookies_cleared);
+ } else {
+ clearCookiesPreference.setIcon(R.drawable.cookies_warning);
+ }
+ break;
+
+ case "clear_dom_storage":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("clear_dom_storage", true)) {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared);
+ } else {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning);
+ }
+ break;
+
+ case "clear_form_data":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("clear_form_data", true)) {
+ clearFormDataPreference.setIcon(R.drawable.form_data_cleared);
+ } else {
+ clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ }
+ break;
+
+ case "clear_cache":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("clear_cache", true)) {
+ clearCachePreference.setIcon(R.drawable.cache_cleared);
+ } else {
+ clearCachePreference.setIcon(R.drawable.cache_warning);
+ }