- } else { // Proxy through Orbot is disabled.
- proxyThroughOrbotPreference.setIcon(R.drawable.orbot_disabled);
- torHomepagePreference.setIcon(R.drawable.home_ghosted);
- torSearchPreference.setIcon(R.drawable.search_ghosted);
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted);
- }
- 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_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);