- case "proxy_through_orbot":
- // Get current settings.
- boolean currentProxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
- String currentTorSearchString = sharedPreferences.getString("tor_search", getString(R.string.tor_search_default_value));
-
- // Enable the Tor custom URL search option only if `currentProxyThroughOrbot` is true and the search is set to `Custom URL`.
- torSearchCustomURLPreference.setEnabled(currentProxyThroughOrbot && currentTorSearchString.equals("Custom URL"));
-
- // Update the icons.
- if (currentProxyThroughOrbot) {
- // Set the Tor icons according to the theme.
- if (darkTheme) {
- proxyThroughOrbotPreference.setIcon(R.drawable.orbot_enabled_dark);
- torHomepagePreference.setIcon(R.drawable.home_enabled_dark);
- torSearchPreference.setIcon(R.drawable.search_enabled_dark);
-
- // Set the `torSearchCustomURLPreference` icon.
- if (torSearchCustomURLPreference.isEnabled()) {
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_dark);
- } else {
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_dark);
- }
- } else {
- proxyThroughOrbotPreference.setIcon(R.drawable.orbot_enabled_light);
- torHomepagePreference.setIcon(R.drawable.home_enabled_light);
- torSearchPreference.setIcon(R.drawable.search_enabled_light);
-
- // Set the `torSearchCustomURLPreference` icon.
- if (torSearchCustomURLPreference.isEnabled()) {
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_light);
- } else {
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_light);
- }
- }
- } else { // Proxy through Orbot is disabled.
- if (darkTheme) {
- proxyThroughOrbotPreference.setIcon(R.drawable.orbot_disabled_dark);
- torHomepagePreference.setIcon(R.drawable.home_ghosted_dark);
- torSearchPreference.setIcon(R.drawable.search_ghosted_dark);
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_dark);
- } else {
- proxyThroughOrbotPreference.setIcon(R.drawable.orbot_disabled_light);
- torHomepagePreference.setIcon(R.drawable.home_ghosted_light);
- torSearchPreference.setIcon(R.drawable.search_ghosted_light);
- torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_light);
- }
- }
- break;
-
- case "tor_homepage":
- // Set the new tor homepage URL as the summary text for the `tor_homepage` preference. The default is Searx: `http://ulrn6sryqaifefld.onion/`.
- torHomepagePreference.setSummary(sharedPreferences.getString("tor_homepage", getString(R.string.tor_homepage_default_value)));
- break;
-
- case "tor_search":
- // Get the present search string.
- String presentTorSearchString = sharedPreferences.getString("tor_search", getString(R.string.tor_search_default_value));
-
- // 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);
-
- // Enable `torSearchCustomURLPreference`.
- torSearchCustomURLPreference.setEnabled(true);
-
- // Update the `torSearchCustomURLPreference` icon.