+ // Disable the JavaScript preference if Night Mode is enabled. JavaScript will be enabled for all web pages.
+ javaScriptPreference.setEnabled(!nightMode);
+
+ // Set the JavaScript icon.
+ if (javaScriptEnabled || nightMode) {
+ javaScriptPreference.setIcon(R.drawable.javascript_enabled);
+ } else {
+ javaScriptPreference.setIcon(R.drawable.privacy_mode);
+ }
+
+ // Set the first-party cookies icon.
+ if (firstPartyCookiesEnabled) {
+ firstPartyCookiesPreference.setIcon(R.drawable.cookies_enabled);
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ firstPartyCookiesPreference.setIcon(R.drawable.cookies_disabled_dark);
+ } else {
+ firstPartyCookiesPreference.setIcon(R.drawable.cookies_disabled_light);
+ }
+ }
+
+ // Set the third party cookies icon.
+ if (firstPartyCookiesEnabled && Build.VERSION.SDK_INT >= 21) {
+ if (thirdPartyCookiesEnabled) {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_warning);
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_disabled_dark);
+ } else {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_disabled_light);
+ }
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_ghosted_dark);
+ } else {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_ghosted_light);
+ }
+ }
+
+ // Set the DOM storage icon.
+ if (javaScriptEnabled || nightMode) { // The preference is enabled.
+ if (savedPreferences.getBoolean("dom_storage_enabled", false)) { // DOM storage is enabled.
+ domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
+ } else { // DOM storage is disabled.
+ if (MainWebViewActivity.darkTheme) {
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled_dark);
+ } else {
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled_light);
+ }
+ }
+ } else { // The preference is disabled. The icon should be ghosted.
+ if (MainWebViewActivity.darkTheme) {
+ domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_dark);
+ } else {
+ domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_light);
+ }
+ }
+
+ // Set the save form data icon if API < 26. Save form data has no effect on API >= 26.
+ if (Build.VERSION.SDK_INT < 26) {
+ if (savedPreferences.getBoolean("save_form_data_enabled", false)) {
+ saveFormDataPreference.setIcon(R.drawable.form_data_enabled);
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ saveFormDataPreference.setIcon(R.drawable.form_data_disabled_dark);
+ } else {
+ saveFormDataPreference.setIcon(R.drawable.form_data_disabled_light);
+ }
+ }
+ }
+
+ // Set the custom user agent icon.
+ if (customUserAgentPreference.isEnabled()) {
+ if (MainWebViewActivity.darkTheme) {
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled_dark);
+ } else {
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_dark);
+ } else {
+ customUserAgentPreference.setIcon(R.drawable.custom_user_agent_ghosted_light);
+ }
+ }
+
+ // Set the incognito mode icon.
+ if (savedPreferences.getBoolean("incognito_mode", false)) {
+ if (MainWebViewActivity.darkTheme) {
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled_dark);
+ } else {
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled_dark);
+ } else {
+ incognitoModePreference.setIcon(R.drawable.incognito_mode_disabled_light);
+ }
+ }
+
+ // Set the Do Not Track icon.
+ if (savedPreferences.getBoolean("do_not_track", false)) {
+ if (MainWebViewActivity.darkTheme) {
+ doNotTrackPreference.setIcon(R.drawable.block_tracking_enabled_dark);
+ } else {
+ doNotTrackPreference.setIcon(R.drawable.block_tracking_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ doNotTrackPreference.setIcon(R.drawable.block_tracking_disabled_dark);
+ } else {
+ doNotTrackPreference.setIcon(R.drawable.block_tracking_disabled_light);
+ }
+ }
+
+ // Set the allow screenshots icon.
+ if (savedPreferences.getBoolean("allow_screenshots", false)) {
+ if (MainWebViewActivity.darkTheme) {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_dark);
+ } else {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_dark);
+ } else {
+ allowScreenshotsPreference.setIcon(R.drawable.allow_screenshots_disabled_light);
+ }
+ }
+
+ // Set the EasyList icon.
+ if (savedPreferences.getBoolean("easylist", true)) {
+ if (MainWebViewActivity.darkTheme) {
+ easyListPreference.setIcon(R.drawable.block_ads_enabled_dark);
+ } else {
+ easyListPreference.setIcon(R.drawable.block_ads_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ easyListPreference.setIcon(R.drawable.block_ads_disabled_dark);
+ } else {
+ easyListPreference.setIcon(R.drawable.block_ads_disabled_light);
+ }
+ }
+
+ // Set the EasyPrivacy icon.
+ if (savedPreferences.getBoolean("easyprivacy", true)) {
+ if (MainWebViewActivity.darkTheme) {
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_dark);
+ } else {
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_dark);
+ } else {
+ easyPrivacyPreference.setIcon(R.drawable.block_tracking_disabled_light);
+ }
+ }
+
+ // Set the Fanboy lists icons.
+ if (fanboyAnnoyanceListEnabled) {
+ if (MainWebViewActivity.darkTheme) {
+ // Set the Fanboy annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled_dark);
+
+ // Set the Fanboy social blocking list icon.
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted_dark);
+ } else {
+ // Set the Fanboy annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_enabled_light);
+
+ // Set the Fanboy social blocking list icon.
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_ghosted_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ // Set the Fanboy annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.social_media_disabled_dark);
+
+ // Set the Fanboy social blocking list icon.
+ if (fanboySocialBlockingEnabled) {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_dark);
+ } else {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_dark);
+ }
+ } else {
+ // Set the Fanboy annoyance list icon.
+ fanboyAnnoyanceListPreference.setIcon(R.drawable.block_ads_disabled_light);
+
+ // Set the Fanboy social blocking list icon.
+ if (fanboySocialBlockingEnabled) {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_enabled_light);
+ } else {
+ fanboySocialBlockingListPreference.setIcon(R.drawable.social_media_disabled_light);
+ }
+ }
+ }
+
+ // Set the Tor icons according to the theme.
+ if (proxyThroughOrbot) { // Proxying is enabled.
+ if (MainWebViewActivity.darkTheme) {
+ proxyThroughOrbotPreference.setIcon(R.drawable.orbot_enabled_dark);
+ torHomepagePreference.setIcon(R.drawable.home_enabled_dark);
+ torSearchPreference.setIcon(R.drawable.search_enabled_dark);
+
+ // Set the custom search 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 custom search icon.
+ if (torSearchCustomURLPreference.isEnabled()) {
+ torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_light);
+ } else {
+ torSearchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_light);
+ }
+ }
+ } else { // Proxying is disabled.
+ if (MainWebViewActivity.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);
+ }
+ }
+
+ // Set the search custom URL icon.
+ if (searchCustomURLPreference.isEnabled()) {
+ if (MainWebViewActivity.darkTheme) {
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_dark);
+ } else {
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_url_enabled_light);
+ }
+ } else {
+ if (MainWebViewActivity.darkTheme) {
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_dark);
+ } else {
+ searchCustomURLPreference.setIcon(R.drawable.search_custom_url_ghosted_light);
+ }
+ }
+
+ // Set the full screen browsing mode icons.
+ if (fullScreenBrowsingMode) { // Full screen browsing mode is enabled.
+ // Set the `fullScreenBrowsingModePreference` icon according to the theme.
+ if (MainWebViewActivity.darkTheme) {
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled_dark);
+ } else {
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_enabled_light);
+ }
+
+ if (hideSystemBars) { // `hideSystemBarsBoolean` is `true`.
+ // Set the icons according to the theme.
+ if (MainWebViewActivity.darkTheme) {
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_enabled_dark);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted_dark);
+ } else {
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_enabled_light);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted_light);
+ }
+ } else { // `hideSystemBarsBoolean` is `false`.
+ // Set the `hideSystemBarsPreference` icon according to the theme.
+ if (MainWebViewActivity.darkTheme) {
+ // Set the icon for `hideSystemBarsPreference`.
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_disabled_dark);
+
+ // Set the icon for `translucentNavigationBarPreference`.
+ if (savedPreferences.getBoolean("translucent_navigation_bar", true)) {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_enabled_dark);
+ } else {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_disabled_dark);
+ }
+ } else {
+ // Set the icon for `hideSystemBarsPreference`.
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_disabled_light);
+
+ // Set the icon for `translucentNavigationBarPreference`.
+ if (savedPreferences.getBoolean("translucent_navigation_bar", true)) {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_enabled_light);
+ } else {
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_disabled_light);
+ }
+ }
+ }
+ } else { // Full screen browsing mode is disabled.
+ // Set the icons according to the theme.
+ if (MainWebViewActivity.darkTheme) {
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled_dark);
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_ghosted_dark);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted_dark);
+ } else {
+ fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled_light);
+ hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_ghosted_light);
+ translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted_light);
+ }
+ }
+
+ // Set the clear everything preference icon.
+ if (clearEverything) {
+ if (MainWebViewActivity.darkTheme) {
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_dark);
+ } else {
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled_light);
+ }
+ } else {
+ clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled);
+ }
+
+ // Set the clear cookies preference icon.
+ if (clearEverything || savedPreferences.getBoolean("clear_cookies", true)) {
+ if (MainWebViewActivity.darkTheme) {
+ clearCookiesPreference.setIcon(R.drawable.cookies_cleared_dark);
+ } else {
+ clearCookiesPreference.setIcon(R.drawable.cookies_cleared_light);
+ }
+ } else {
+ clearCookiesPreference.setIcon(R.drawable.cookies_warning);
+ }
+
+ // Set the clear DOM storage preference icon.
+ if (clearEverything || savedPreferences.getBoolean("clear_dom_storage", true)) {
+ if (MainWebViewActivity.darkTheme) {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_dark);
+ } else {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared_light);
+ }
+ } else {
+ clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning);
+ }
+
+ // Set the clear form data preference icon if the API < 26. It has no effect on newer versions of Android.
+ if (Build.VERSION.SDK_INT < 26) {
+ if (clearEverything || savedPreferences.getBoolean("clear_form_data", true)) {
+ if (MainWebViewActivity.darkTheme) {
+ clearFormDataPreference.setIcon(R.drawable.form_data_cleared_dark);
+ } else {
+ clearFormDataPreference.setIcon(R.drawable.form_data_cleared_light);
+ }
+ } else {
+ clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ }
+ }