+ case "proxy":
+ // Get current proxy string.
+ String currentProxyString = sharedPreferences.getString("proxy", getString(R.string.proxy_default_value));
+
+ // Update the summary text for the proxy preference.
+ switch (currentProxyString) {
+ case ProxyHelper.NONE:
+ proxyPreference.setSummary(getString(R.string.no_proxy_enabled));
+ break;
+
+ case ProxyHelper.TOR:
+ if (Build.VERSION.SDK_INT == 19) { // Proxying through SOCKS doesn't work on Android KitKat.
+ proxyPreference.setSummary(getString(R.string.tor_enabled_kitkat));
+ } else {
+ proxyPreference.setSummary(getString(R.string.tor_enabled));
+ }
+ break;
+
+ case ProxyHelper.I2P:
+ proxyPreference.setSummary(getString(R.string.i2p_enabled));
+ break;
+
+ case ProxyHelper.CUSTOM:
+ proxyPreference.setSummary(getString(R.string.custom_proxy));
+ break;
+ }
+
+ // Update the status of the custom URL preference.
+ proxyCustomUrlPreference.setEnabled(currentProxyString.equals("Custom"));
+
+ // Update the icons.
+ if (currentProxyString.equals("None")) { // Proxying is disabled.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme.
+ // Set the main proxy icon to be disabled
+ proxyPreference.setIcon(R.drawable.proxy_disabled_night);
+
+ // Set the custom proxy URL icon to be ghosted.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_night);
+ } else { // Light theme.
+ // Set the main proxy icon to be disabled.
+ proxyPreference.setIcon(R.drawable.proxy_disabled_day);
+
+ // Set the custom proxy URL icon to be ghosted.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_day);
+ }
+ } else { // Proxying is enabled.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme.
+ // Set the main proxy icon to be enabled.
+ proxyPreference.setIcon(R.drawable.proxy_enabled_night);
+
+ /// Set the custom proxy URL icon according to its status.
+ if (proxyCustomUrlPreference.isEnabled()) { // Custom proxy is enabled.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled_night);
+ } else { // Custom proxy is disabled.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_night);
+ }
+ } else { // Light theme.
+ // Set the main proxy icon to be enabled.
+ proxyPreference.setIcon(R.drawable.proxy_enabled_day);
+
+ // Set the custom proxy URL icon according to its status.
+ if (proxyCustomUrlPreference.isEnabled()) { // Custom proxy is enabled.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled_day);
+ } else { // Custom proxy is disabled.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted_day);
+ }
+ }
+ }
+ break;
+
+ case "proxy_custom_url":
+ // Set the summary text for the proxy custom URL.
+ proxyCustomUrlPreference.setSummary(sharedPreferences.getString("proxy_custom_url", getString(R.string.proxy_custom_url_default_value)));
+ break;
+