+ } else { // The JavaScript preference is disabled.
+ // Update the icon for the JavaScript preference.
+ javaScriptPreference.setIcon(R.drawable.privacy_mode);
+
+ // Update the status of the DOM storage preference.
+ domStoragePreference.setEnabled(false);
+
+ // Set the icon for DOM storage preference to be ghosted.
+ domStoragePreference.setIcon(R.drawable.dom_storage_ghosted);
+ }
+ break;
+
+ case "cookies":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(context.getString(R.string.cookies_key), false)) {
+ cookiesPreference.setIcon(R.drawable.cookies_enabled);
+ } else {
+ cookiesPreference.setIcon(R.drawable.cookies_disabled);
+ }
+ break;
+
+ case "dom_storage":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("dom_storage", false)) {
+ domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
+ } else {
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled);
+ }
+ break;
+
+ // Save form data can be removed once the minimum API >= 26.
+ case "save_form_data":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("save_form_data", false)) {
+ formDataPreference.setIcon(R.drawable.form_data_enabled);
+ } else {
+ formDataPreference.setIcon(R.drawable.form_data_disabled);
+ }
+ break;
+
+ case "user_agent":
+ // Get the new user agent name.
+ String newUserAgentName = sharedPreferences.getString(context.getString(R.string.user_agent_key), context.getString(R.string.user_agent_default_value));
+
+ // Get the array position for the new user agent name.
+ int newUserAgentArrayPosition = userAgentNamesArray.getPosition(newUserAgentName);
+
+ // Get the translated new user agent name.
+ String translatedNewUserAgentName = translatedUserAgentNamesArray[newUserAgentArrayPosition];
+
+ // Populate the user agent summary.
+ switch (newUserAgentArrayPosition) {
+ case MainWebViewActivity.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT:
+ // Get the user agent text from the webview (which changes based on the version of Android and WebView installed).
+ userAgentPreference.setSummary(translatedNewUserAgentName + ":\n" + defaultUserAgent);
+
+ // Disable the custom user agent preference.
+ customUserAgentPreference.setEnabled(false);
+
+ // Set the custom user agent preference icon.
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted);
+ break;
+
+ case MainWebViewActivity.SETTINGS_CUSTOM_USER_AGENT:
+ // Set the summary text.
+ userAgentPreference.setSummary(R.string.custom_user_agent);
+
+ // Enable the custom user agent preference.
+ customUserAgentPreference.setEnabled(true);
+
+ // Set the custom user agent preference icon.
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled);
+ break;
+
+ default:
+ // Get the user agent summary from the user agent data array.
+ userAgentPreference.setSummary(translatedNewUserAgentName + ":\n" + userAgentDataArray[newUserAgentArrayPosition]);
+
+ // Disable the custom user agent preference.
+ customUserAgentPreference.setEnabled(false);
+
+ // Set the custom user agent preference icon.
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted);
+ }
+ break;
+
+ case "custom_user_agent":
+ // Set the new custom user agent as the summary text for the preference.
+ customUserAgentPreference.setSummary(sharedPreferences.getString(context.getString(R.string.custom_user_agent_key), context.getString(R.string.custom_user_agent_default_value)));
+ break;
+
+ case "x_requested_with_header":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(context.getString(R.string.x_requested_with_header_key), true))
+ xRequestedWithHeaderPreference.setIcon(R.drawable.x_requested_with_header_enabled);
+ else
+ xRequestedWithHeaderPreference.setIcon(R.drawable.x_requested_with_header_disabled);
+
+ // Restart Privacy Browser.
+ restartPrivacyBrowser();
+ break;
+
+ case "incognito_mode":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("incognito_mode", false))
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled);
+ else
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled);
+ break;
+
+ case "allow_screenshots":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(context.getString(R.string.allow_screenshots_key), false))
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled);
+ else
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled);
+
+ // Restart Privacy Browser.
+ restartPrivacyBrowser();
+ break;
+
+ case "easylist":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("easylist", true))
+ easyListPreference.setIcon(R.drawable.block_ads_enabled);
+ else
+ easyListPreference.setIcon(R.drawable.block_ads_disabled);
+ break;
+
+ case "easyprivacy":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("easyprivacy", true))
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled);
+ else
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled);
+ break;
+
+ case "fanboys_annoyance_list":
+ boolean currentFanboyAnnoyanceList = sharedPreferences.getBoolean("fanboys_annoyance_list", true);
+ boolean currentFanboySocialBlockingList = sharedPreferences.getBoolean("fanboys_social_blocking_list", true);
+
+ // Update the Fanboy icons.
+ if (currentFanboyAnnoyanceList) { // Fanboy's annoyance list is enabled.
+ // Update the Fanboy's annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled);
+
+ // Update the Fanboy's social blocking list icon.
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted);
+ } else { // Fanboy's annoyance list is disabled.
+ // Update the Fanboy's annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled);
+
+ // Update the Fanboy's social blocking list icon.
+ if (currentFanboySocialBlockingList) {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled);
+ } else {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled);
+ }
+ }
+
+ // Only enable Fanboy's social blocking list preference if Fanboy's annoyance list preference is disabled.
+ fanboySocialBlockingListPreference.setEnabled(!currentFanboyAnnoyanceList);
+ break;
+
+ case "fanboys_social_blocking_list":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("fanboys_social_blocking_list", true)) {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled);
+ } else {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled);
+ }
+ break;
+
+ case "ultralist":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("ultralist", true)) {
+ ultraListPreference.setIcon(R.drawable.block_ads_enabled);
+ } else {
+ ultraListPreference.setIcon(R.drawable.block_ads_disabled);
+ }
+ break;
+
+ case "ultraprivacy":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("ultraprivacy", true)) {
+ ultraPrivacyPreference.setIcon(R.drawable.block_tracking_enabled);
+ } else {
+ ultraPrivacyPreference.setIcon(R.drawable.block_tracking_disabled);
+ }
+ break;
+
+ case "block_all_third_party_requests":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("block_all_third_party_requests", false)) {
+ blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_enabled);
+ } else {
+ blockAllThirdPartyRequestsPreference.setIcon(R.drawable.block_all_third_party_requests_disabled);
+ }
+ break;
+
+ case "tracking_queries":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(context.getString(R.string.tracking_queries_key), true)) {
+ trackingQueriesPreference.setIcon(R.drawable.modify_url_enabled);
+ } else {
+ trackingQueriesPreference.setIcon(R.drawable.modify_url_disabled);
+ }
+ break;
+
+ case "amp_redirects":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(context.getString(R.string.amp_redirects_key), true)) {
+ ampRedirectsPreference.setIcon(R.drawable.modify_url_enabled);
+ } else {
+ ampRedirectsPreference.setIcon(R.drawable.modify_url_disabled);
+ }
+ break;
+
+ case "search":
+ // Store the new search string.
+ String newSearchString = sharedPreferences.getString("search", context.getString(R.string.search_default_value));
+
+ // Update the search and search custom URL preferences.
+ 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);
+
+ // Enable the search custom URL preference.
+ searchCustomURLPreference.setEnabled(true);
+
+ // Set the search custom URL preference icon.
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_enabled);
+ } else { // `Custom URL` is not selected.
+ // Set the summary text to `newSearchString`.
+ searchPreference.setSummary(newSearchString);
+
+ // Disable `searchCustomURLPreference`.
+ searchCustomURLPreference.setEnabled(false);
+
+ // Set the search custom URL preference icon.
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_ghosted);
+ }
+ break;
+
+ case "search_custom_url":
+ // Set the new search custom URL as the summary text for the preference.
+ searchCustomURLPreference.setSummary(sharedPreferences.getString("search_custom_url", context.getString(R.string.search_custom_url_default_value)));
+ break;
+
+ case "proxy":
+ // Get current proxy string.
+ String currentProxyString = sharedPreferences.getString("proxy", context.getString(R.string.proxy_default_value));
+
+ // Update the summary text for the proxy preference.
+ switch (currentProxyString) {
+ case ProxyHelper.NONE:
+ proxyPreference.setSummary(context.getString(R.string.no_proxy_enabled));
+ break;
+
+ case ProxyHelper.TOR:
+ proxyPreference.setSummary(context.getString(R.string.tor_enabled));
+ break;
+
+ case ProxyHelper.I2P:
+ proxyPreference.setSummary(context.getString(R.string.i2p_enabled));
+ break;
+
+ case ProxyHelper.CUSTOM:
+ proxyPreference.setSummary(context.getString(R.string.custom_proxy));
+ break;
+ }
+
+ // Update the status of the custom URL preference.
+ proxyCustomUrlPreference.setEnabled(currentProxyString.equals(ProxyHelper.CUSTOM));
+
+ // Update the icons.
+ if (currentProxyString.equals(ProxyHelper.NONE)) { // Proxying is disabled.
+ // Set the main proxy icon to be disabled
+ proxyPreference.setIcon(R.drawable.proxy_disabled);
+
+ // Set the custom proxy URL icon to be ghosted.
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted);
+ } else { // Proxying is enabled.
+ // Set the main proxy icon to be enabled.
+ proxyPreference.setIcon(R.drawable.proxy_enabled);
+
+ /// Set the custom proxy URL icon according to its status.
+ if (proxyCustomUrlPreference.isEnabled()) {
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_enabled);
+ } else {
+ proxyCustomUrlPreference.setIcon(R.drawable.proxy_ghosted);
+ }
+ }
+ break;
+
+ case "proxy_custom_url":
+ // Set the summary text for the proxy custom URL.
+ proxyCustomUrlPreference.setSummary(sharedPreferences.getString(context.getString(R.string.proxy_custom_url_key), context.getString(R.string.proxy_custom_url_default_value)));
+ break;
+
+ case "full_screen_browsing_mode":
+ if (sharedPreferences.getBoolean("full_screen_browsing_mode", false)) { // Full screen browsing is enabled.
+ // Set the full screen browsing mode preference icon.
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled);
+
+ // Set the hide app bar preference icon.
+ if (sharedPreferences.getBoolean("hide_app_bar", true)) {
+ hideAppBarPreference.setIcon(R.drawable.app_bar_enabled);