]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
Reenable dark WebViews on API 33. https://redmine.stoutner.com/issues/903
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / DomainSettingsFragment.java
index 35d626935039f0c5a151df734ba148bf83d53c58..3a216eb164d588105f9560bbe94036c00c54da23 100644 (file)
@@ -1,26 +1,25 @@
 /*
- * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2022 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
- * Privacy Browser is free software: you can redistribute it and/or modify
+ * Privacy Browser Android is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
- * Privacy Browser is distributed in the hope that it will be useful,
+ * Privacy Browser Android is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ * along with Privacy Browser Android.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.stoutner.privacybrowser.fragments;
 
 import android.annotation.SuppressLint;
-import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.content.res.Resources;
@@ -52,7 +51,7 @@ import androidx.annotation.NonNull;
 import androidx.appcompat.widget.SwitchCompat;
 import androidx.cardview.widget.CardView;
 import androidx.core.content.res.ResourcesCompat;
-import androidx.fragment.app.Fragment;  // The AndroidX fragment must be used until minimum API >= 23.  Otherwise `getContext()` does not work.
+import androidx.fragment.app.Fragment;
 
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.activities.DomainsActivity;
@@ -64,14 +63,14 @@ import java.util.Calendar;
 import java.util.Date;
 
 public class DomainSettingsFragment extends Fragment {
-    // Initialize the public class constants.  These are used by activities calling this fragment.
+    // Initialize the public class constants.
     public static final String DATABASE_ID = "database_id";
     public static final String SCROLL_Y = "scroll_y";
 
-    // Define the public variables.  `databaseId` is public static so it can be accessed from `DomainsActivity`. It is also used in `onCreate()` and `onCreateView()`.
+    // Declare the public variables.  `databaseId` is public static so it can be accessed from `DomainsActivity`.
     public static int databaseId;
 
-    // Define the class variables.
+    // Declare the class variables.
     private int scrollY;
 
     @Override
@@ -87,28 +86,24 @@ public class DomainSettingsFragment extends Fragment {
         scrollY = getArguments().getInt(SCROLL_Y);
     }
 
-    // The deprecated `getDrawable()` must be used until the minimum API >= 21.
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         // Inflate `domain_settings_fragment`.  `false` does not attach it to the root `container`.
         View domainSettingsView = inflater.inflate(R.layout.domain_settings_fragment, container, false);
 
         // Get handles for the context and the resources.
-        Context context = getContext();
         Resources resources = getResources();
 
-        // Remove the error below that the context might be null.
-        assert context != null;
-
         // Get the current theme status.
         int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
 
         // Get a handle for the shared preference.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext());
 
         // Store the default settings.
         String defaultUserAgentName = sharedPreferences.getString("user_agent", getString(R.string.user_agent_default_value));
         String defaultCustomUserAgentString = sharedPreferences.getString("custom_user_agent", getString(R.string.custom_user_agent_default_value));
+        boolean defaultXRequestedWithHeader = sharedPreferences.getBoolean(getString(R.string.x_requested_with_header_key), true);
         String defaultFontSizeString = sharedPreferences.getString("font_size", getString(R.string.font_size_default_value));
         boolean defaultSwipeToRefresh = sharedPreferences.getBoolean("swipe_to_refresh", true);
         String defaultWebViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
@@ -120,11 +115,8 @@ public class DomainSettingsFragment extends Fragment {
         EditText domainNameEditText = domainSettingsView.findViewById(R.id.domain_settings_name_edittext);
         ImageView javaScriptImageView = domainSettingsView.findViewById(R.id.javascript_imageview);
         SwitchCompat javaScriptSwitch = domainSettingsView.findViewById(R.id.javascript_switch);
-        ImageView firstPartyCookiesImageView = domainSettingsView.findViewById(R.id.first_party_cookies_imageview);
-        SwitchCompat firstPartyCookiesSwitch = domainSettingsView.findViewById(R.id.first_party_cookies_switch);
-        LinearLayout thirdPartyCookiesLinearLayout = domainSettingsView.findViewById(R.id.third_party_cookies_linearlayout);
-        ImageView thirdPartyCookiesImageView = domainSettingsView.findViewById(R.id.third_party_cookies_imageview);
-        SwitchCompat thirdPartyCookiesSwitch = domainSettingsView.findViewById(R.id.third_party_cookies_switch);
+        ImageView cookiesImageView = domainSettingsView.findViewById(R.id.cookies_imageview);
+        SwitchCompat cookiesSwitch = domainSettingsView.findViewById(R.id.cookies_switch);
         ImageView domStorageImageView = domainSettingsView.findViewById(R.id.dom_storage_imageview);
         SwitchCompat domStorageSwitch = domainSettingsView.findViewById(R.id.dom_storage_switch);
         ImageView formDataImageView = domainSettingsView.findViewById(R.id.form_data_imageview);  // The form data views can be remove once the minimum API >= 26.
@@ -146,6 +138,10 @@ public class DomainSettingsFragment extends Fragment {
         Spinner userAgentSpinner = domainSettingsView.findViewById(R.id.user_agent_spinner);
         TextView userAgentTextView = domainSettingsView.findViewById(R.id.user_agent_textview);
         EditText customUserAgentEditText = domainSettingsView.findViewById(R.id.custom_user_agent_edittext);
+        ImageView xRequestedWithHeaderImageView = domainSettingsView.findViewById(R.id.x_requested_with_header_imageview);
+        Spinner xRequestedWithHeaderSpinner = domainSettingsView.findViewById(R.id.x_requested_with_header_spinner);
+        TextView xRequestedWithHeaderTextView = domainSettingsView.findViewById(R.id.x_requested_with_header_textview);
+        TextView xRequestedWithHeaderExplanationTextView = domainSettingsView.findViewById(R.id.x_requested_with_header_explanation_textview);
         Spinner fontSizeSpinner = domainSettingsView.findViewById(R.id.font_size_spinner);
         TextView defaultFontSizeTextView = domainSettingsView.findViewById(R.id.default_font_size_textview);
         EditText customFontSizeEditText = domainSettingsView.findViewById(R.id.custom_font_size_edittext);
@@ -204,66 +200,68 @@ public class DomainSettingsFragment extends Fragment {
         String startDateLabel = getString(R.string.start_date) + "  ";
         String endDateLabel = getString(R.string.end_date) + "  ";
 
-        // Initialize the database handler.  The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`.
-        DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(context, null, null, 0);
+        // Initialize the database handler.
+        DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(requireContext());
 
         // Get the database cursor for this ID and move it to the first row.
         Cursor domainCursor = domainsDatabaseHelper.getCursorForId(databaseId);
         domainCursor.moveToFirst();
 
         // Save the cursor entries as variables.
-        String domainNameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.DOMAIN_NAME));
-        int javaScriptInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_JAVASCRIPT));
-        int firstPartyCookiesInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_FIRST_PARTY_COOKIES));
-        int thirdPartyCookiesInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_THIRD_PARTY_COOKIES));
-        int domStorageInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_DOM_STORAGE));
-        int formDataInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_FORM_DATA));  // Form data can be remove once the minimum API >= 26.
-        int easyListInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_EASYLIST));
-        int easyPrivacyInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_EASYPRIVACY));
-        int fanboysAnnoyanceListInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_FANBOYS_ANNOYANCE_LIST));
-        int fanboysSocialBlockingListInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST));
-        int ultraListInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ULTRALIST));
-        int ultraPrivacyInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_ULTRAPRIVACY));
-        int blockAllThirdPartyRequestsInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.BLOCK_ALL_THIRD_PARTY_REQUESTS));
-        String currentUserAgentName = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.USER_AGENT));
-        int fontSizeInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.FONT_SIZE));
-        int swipeToRefreshInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.SWIPE_TO_REFRESH));
-        int webViewThemeInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.WEBVIEW_THEME));
-        int wideViewportInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.WIDE_VIEWPORT));
-        int displayImagesInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.DISPLAY_IMAGES));
-        int pinnedSslCertificateInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE));
-        String savedSslIssuedToCNameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_ISSUED_TO_COMMON_NAME));
-        String savedSslIssuedToONameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_ISSUED_TO_ORGANIZATION));
-        String savedSslIssuedToUNameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_ISSUED_TO_ORGANIZATIONAL_UNIT));
-        String savedSslIssuedByCNameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_ISSUED_BY_COMMON_NAME));
-        String savedSslIssuedByONameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_ISSUED_BY_ORGANIZATION));
-        String savedSslIssuedByUNameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_ISSUED_BY_ORGANIZATIONAL_UNIT));
-        int pinnedIpAddressesInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.PINNED_IP_ADDRESSES));
-        String savedIpAddresses = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.IP_ADDRESSES));
+        String domainNameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.DOMAIN_NAME));
+        int javaScriptInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_JAVASCRIPT));
+        int cookiesInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.COOKIES));
+        int domStorageInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_DOM_STORAGE));
+        int formDataInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_FORM_DATA));  // Form data can be remove once the minimum API >= 26.
+        int easyListInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_EASYLIST));
+        int easyPrivacyInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_EASYPRIVACY));
+        int fanboysAnnoyanceListInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_FANBOYS_ANNOYANCE_LIST));
+        int fanboysSocialBlockingListInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST));
+        int ultraListInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ULTRALIST));
+        int ultraPrivacyInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_ULTRAPRIVACY));
+        int blockAllThirdPartyRequestsInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.BLOCK_ALL_THIRD_PARTY_REQUESTS));
+        String currentUserAgentName = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.USER_AGENT));
+        int xRequestedWithHeaderInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.X_REQUESTED_WITH_HEADER));
+        int fontSizeInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.FONT_SIZE));
+        int swipeToRefreshInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SWIPE_TO_REFRESH));
+        int webViewThemeInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.WEBVIEW_THEME));
+        int wideViewportInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.WIDE_VIEWPORT));
+        int displayImagesInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.DISPLAY_IMAGES));
+        int pinnedSslCertificateInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE));
+        String savedSslIssuedToCNameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_ISSUED_TO_COMMON_NAME));
+        String savedSslIssuedToONameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_ISSUED_TO_ORGANIZATION));
+        String savedSslIssuedToUNameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_ISSUED_TO_ORGANIZATIONAL_UNIT));
+        String savedSslIssuedByCNameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_ISSUED_BY_COMMON_NAME));
+        String savedSslIssuedByONameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_ISSUED_BY_ORGANIZATION));
+        String savedSslIssuedByUNameString = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_ISSUED_BY_ORGANIZATIONAL_UNIT));
+        int pinnedIpAddressesInt = domainCursor.getInt(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.PINNED_IP_ADDRESSES));
+        String savedIpAddresses = domainCursor.getString(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.IP_ADDRESSES));
 
         // Initialize the saved SSL certificate date variables.
         Date savedSslStartDate = null;
         Date savedSslEndDate = null;
 
         // Only get the saved SSL certificate dates from the cursor if they are not set to `0`.
-        if (domainCursor.getLong(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_START_DATE)) != 0) {
-            savedSslStartDate = new Date(domainCursor.getLong(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_START_DATE)));
+        if (domainCursor.getLong(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_START_DATE)) != 0) {
+            savedSslStartDate = new Date(domainCursor.getLong(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_START_DATE)));
         }
 
-        if (domainCursor.getLong(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_END_DATE)) != 0) {
-            savedSslEndDate = new Date(domainCursor.getLong(domainCursor.getColumnIndex(DomainsDatabaseHelper.SSL_END_DATE)));
+        if (domainCursor.getLong(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_END_DATE)) != 0) {
+            savedSslEndDate = new Date(domainCursor.getLong(domainCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SSL_END_DATE)));
         }
 
         // Create array adapters for the spinners.
-        ArrayAdapter<CharSequence> translatedUserAgentArrayAdapter = ArrayAdapter.createFromResource(context, R.array.translated_domain_settings_user_agent_names, R.layout.spinner_item);
-        ArrayAdapter<CharSequence> fontSizeArrayAdapter = ArrayAdapter.createFromResource(context, R.array.font_size_array, R.layout.spinner_item);
-        ArrayAdapter<CharSequence> swipeToRefreshArrayAdapter = ArrayAdapter.createFromResource(context, R.array.swipe_to_refresh_array, R.layout.spinner_item);
-        ArrayAdapter<CharSequence> webViewThemeArrayAdapter = ArrayAdapter.createFromResource(context, R.array.webview_theme_array, R.layout.spinner_item);
-        ArrayAdapter<CharSequence> wideViewportArrayAdapter = ArrayAdapter.createFromResource(context, R.array.wide_viewport_array, R.layout.spinner_item);
-        ArrayAdapter<CharSequence> displayImagesArrayAdapter = ArrayAdapter.createFromResource(context, R.array.display_webpage_images_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> translatedUserAgentArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.translated_domain_settings_user_agent_names, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> xRequestedWithHeaderArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.x_requested_with_header_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> fontSizeArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.font_size_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> swipeToRefreshArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.swipe_to_refresh_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> webViewThemeArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.webview_theme_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> wideViewportArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.wide_viewport_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> displayImagesArrayAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.display_webpage_images_array, R.layout.spinner_item);
 
         // Set the drop down view resource on the spinners.
         translatedUserAgentArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
+        xRequestedWithHeaderArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         fontSizeArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         swipeToRefreshArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         webViewThemeArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
@@ -272,6 +270,7 @@ public class DomainSettingsFragment extends Fragment {
 
         // Set the array adapters for the spinners.
         userAgentSpinner.setAdapter(translatedUserAgentArrayAdapter);
+        xRequestedWithHeaderSpinner.setAdapter(xRequestedWithHeaderArrayAdapter);
         fontSizeSpinner.setAdapter(fontSizeArrayAdapter);
         swipeToRefreshSpinner.setAdapter(swipeToRefreshArrayAdapter);
         webViewThemeSpinner.setAdapter(webViewThemeArrayAdapter);
@@ -303,18 +302,9 @@ public class DomainSettingsFragment extends Fragment {
             savedSslEndDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(savedSslEndDate));
         }
 
-        // Create the foreground color spans.
-        final ForegroundColorSpan redColorSpan;
-        final ForegroundColorSpan blueColorSpan;
-
-        // Set the color spans according to the theme.  The deprecated `resources` must be used until the minimum API >= 23.
-        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-            redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_900));
-            blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.violet_500));
-        } else {
-            redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_a700));
-            blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_700));
-        }
+        // Create the color spans.
+        final ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(requireContext().getColor(R.color.alt_blue_text));
+        final ForegroundColorSpan redColorSpan = new ForegroundColorSpan(requireContext().getColor(R.color.red_text));
 
         // Set the domain name from the the database cursor.
         domainNameEditText.setText(domainNameString);
@@ -373,324 +363,59 @@ public class DomainSettingsFragment extends Fragment {
             }
         });
 
-        // Set the JavaScript switch status.
-        if (javaScriptInt == 1) {  // JavaScript is enabled.
-            javaScriptSwitch.setChecked(true);
+        // Set the switch positions.
+        javaScriptSwitch.setChecked(javaScriptInt == 1);
+        cookiesSwitch.setChecked(cookiesInt == 1);
+        domStorageSwitch.setChecked(domStorageInt == 1);
+        formDataSwitch.setChecked(formDataInt == 1);  // Form data can be removed once the minimum API >= 26.
+        easyListSwitch.setChecked(easyListInt == 1);
+        easyPrivacySwitch.setChecked(easyPrivacyInt == 1);
+        fanboysAnnoyanceListSwitch.setChecked(fanboysAnnoyanceListInt == 1);
+        fanboysSocialBlockingListSwitch.setChecked(fanboysSocialBlockingListInt == 1);
+        ultraListSwitch.setChecked(ultraListInt == 1);
+        ultraPrivacySwitch.setChecked(ultraPrivacyInt == 1);
+        blockAllThirdPartyRequestsSwitch.setChecked(blockAllThirdPartyRequestsInt == 1);
+        pinnedSslCertificateSwitch.setChecked(pinnedSslCertificateInt == 1);
+        pinnedIpAddressesSwitch.setChecked(pinnedIpAddressesInt == 1);
+
+        // Set the switch icon colors.
+        cookiesImageView.setSelected(cookiesInt == 1);
+        domStorageImageView.setSelected(domStorageInt == 1);
+        formDataImageView.setSelected(formDataInt == 1);  // Form data can be removed once the minimum API >= 26.
+        easyListImageView.setSelected(easyListInt == 1);
+        easyPrivacyImageView.setSelected(easyPrivacyInt == 1);
+        fanboysAnnoyanceListImageView.setSelected(fanboysAnnoyanceListInt == 1);
+        fanboysSocialBlockingListImageView.setSelected(fanboysSocialBlockingListInt == 1);
+        ultraListImageView.setSelected(ultraListInt == 1);
+        ultraPrivacyImageView.setSelected(ultraPrivacyInt == 1);
+        blockAllThirdPartyRequestsImageView.setSelected(blockAllThirdPartyRequestsInt == 1);
+        pinnedSslCertificateImageView.setSelected(pinnedSslCertificateInt == 1);
+        pinnedIpAddressesImageView.setSelected(pinnedIpAddressesInt == 1);
+
+        // Set the JavaScript icon.
+        if (javaScriptInt == 1)
             javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.javascript_enabled, null));
-        } else {  // JavaScript is disabled.
-            javaScriptSwitch.setChecked(false);
+        else
             javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.privacy_mode, null));
-        }
-
-        // Set the first-party cookies status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (firstPartyCookiesInt == 1) {  // First-party cookies are enabled.
-            firstPartyCookiesSwitch.setChecked(true);
-            firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
-        } else {  // First-party cookies are disabled.
-            firstPartyCookiesSwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
-            } else {
-                firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
-            }
-        }
-
-        // Only display third-party cookies if SDK_INT >= 21.
-        if (Build.VERSION.SDK_INT >= 21) {  // Third-party cookies can be configured for API >= 21.
-            // Only enable third-party-cookies if first-party cookies are enabled.
-            if (firstPartyCookiesInt == 1) {  // First-party cookies are enabled.
-                // Set the third-party cookies status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-                if (thirdPartyCookiesInt == 1) {  // Both first-party and third-party cookies are enabled.
-                    // Set the third-party cookies switch to be checked.
-                    thirdPartyCookiesSwitch.setChecked(true);
-
-                    // Set the icon to be red.
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_warning, null));
-                } else {  // First party cookies are enabled but third-party cookies are disabled.
-                    // Set the third-party cookies switch to be checked.
-                    thirdPartyCookiesSwitch.setChecked(false);
-
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
-                    } else {
-                        thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
-                    }
-                }
-            } else {  // First-party cookies are disabled.
-                // Set the status of third-party cookies.
-                if (thirdPartyCookiesInt == 1) {
-                    thirdPartyCookiesSwitch.setChecked(true);
-                } else {
-                    thirdPartyCookiesSwitch.setChecked(false);
-                }
 
-                // Disable the third-party cookies switch.
-                thirdPartyCookiesSwitch.setEnabled(false);
-
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_ghosted_night, null));
-                } else {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_ghosted_day, null));
-                }
-            }
-        } else {  // Third-party cookies cannot be configured for API <= 21.
-            // Hide the LinearLayout for third-party cookies.
-            thirdPartyCookiesLinearLayout.setVisibility(View.GONE);
-        }
+        // Set the DOM storage switch status based on the JavaScript status.
+        domStorageSwitch.setEnabled(javaScriptInt == 1);
 
-        // Only enable DOM storage if JavaScript is enabled.
-        if (javaScriptInt == 1) {  // JavaScript is enabled.
-            // Enable the DOM storage `Switch`.
-            domStorageSwitch.setEnabled(true);
-
-            // Set the DOM storage status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-            if (domStorageInt == 1) {  // Both JavaScript and DOM storage are enabled.
-                domStorageSwitch.setChecked(true);
-                domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
-            } else {  // JavaScript is enabled but DOM storage is disabled.
-                // Set the DOM storage switch to off.
-                domStorageSwitch.setChecked(false);
-
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
-                } else {
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
-                }
-            }
-        } else {  // JavaScript is disabled.
-            // Disable the DOM storage `Switch`.
-            domStorageSwitch.setEnabled(false);
-
-            // Set the checked status of DOM storage.
-            if (domStorageInt == 1) {  // DOM storage is enabled but JavaScript is disabled.
-                domStorageSwitch.setChecked(true);
-            } else {  // Both JavaScript and DOM storage are disabled.
-                domStorageSwitch.setChecked(false);
-            }
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_night, null));
-            } else {
-                domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_day, null));
-            }
-        }
+        // Set the DOM storage icon ghosted status based on the JavaScript status.
+        domStorageImageView.setEnabled(javaScriptInt == 1);
 
         // Set the form data visibility.  Form data can be removed once the minimum API >= 26.
-        if (Build.VERSION.SDK_INT >= 26) {  // Form data no longer applies to newer versions of Android.
+        if (Build.VERSION.SDK_INT >= 26) {
             // Hide the form data image view and switch.
             formDataImageView.setVisibility(View.GONE);
             formDataSwitch.setVisibility(View.GONE);
-        } else {  // Form data should be displayed because this is an older version of Android.
-            if (formDataInt == 1) {  // Form data is on.
-                // Turn the form data switch on.
-                formDataSwitch.setChecked(true);
-
-                // Set the form data icon.
-                formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_enabled, null));
-            } else {  // Form data is off.
-                // Turn the form data switch to off.
-                formDataSwitch.setChecked(false);
-
-                // Set the icon according to the theme.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_night, null));
-                } else {
-                    formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_day, null));
-                }
-            }
-        }
-
-        // Set the EasyList status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (easyListInt == 1) {  // EasyList is on.
-            // Turn the switch on.
-            easyListSwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
-            } else {
-                easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
-            }
-        } else {  // EasyList is off.
-            // Turn the switch off.
-            easyListSwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
-            } else {
-                easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
-            }
-        }
-
-        // Set the EasyPrivacy status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (easyPrivacyInt == 1) {  // EasyPrivacy is on.
-            // Turn the switch on.
-            easyPrivacySwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
-            } else {
-                easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
-            }
-        } else {  // EasyPrivacy is off.
-            // Turn the switch off.
-            easyPrivacySwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
-            } else {
-                easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
-            }
-        }
-
-        // Set the Fanboy's Annoyance List status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (fanboysAnnoyanceListInt == 1) {  // Fanboy's Annoyance List is on.
-            // Turn the switch on.
-            fanboysAnnoyanceListSwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
-            } else {
-                fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
-            }
-        } else {  // Fanboy's Annoyance List is off.
-            // Turn the switch off.
-            fanboysAnnoyanceListSwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
-            } else {
-                fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
-            }
-        }
-
-        // Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off.
-        if (fanboysAnnoyanceListInt == 0) {  // Fanboy's Annoyance List is on.
-            // Enable Fanboy's Social Blocking List switch.
-            fanboysSocialBlockingListSwitch.setEnabled(true);
-
-            // Enable Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-            if (fanboysSocialBlockingListInt == 1) {  // Fanboy's Social Blocking List is on.
-                // Turn on Fanboy's Social Blocking List switch.
-                fanboysSocialBlockingListSwitch.setChecked(true);
-
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
-                } else {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
-                }
-            } else {  // Fanboy's Social Blocking List is off.
-                // Turn off Fanboy's Social Blocking List switch.
-                fanboysSocialBlockingListSwitch.setChecked(false);
-
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
-                } else {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
-                }
-            }
-        } else {  // Fanboy's Annoyance List is on.
-            // Disable Fanboy's Social Blocking List switch.
-            fanboysSocialBlockingListSwitch.setEnabled(false);
-
-            // Handle the status of Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-            if (fanboysSocialBlockingListInt == 1) {  // Fanboy's Social Blocking List is on.
-                // Turn on Fanboy's Social Blocking List switch.
-                fanboysSocialBlockingListSwitch.setChecked(true);
-            } else {  // Fanboy's Social Blocking List is off.
-                // Turn off Fanboy's Social Blocking List switch.
-                fanboysSocialBlockingListSwitch.setChecked(false);
-            }
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_night, null));
-            } else {
-                fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_day, null));
-            }
-        }
-
-        // Set the UltraList status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (ultraListInt == 1) {  // UltraList is on.
-            // Turn the switch on.
-            ultraListSwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
-            } else {
-                ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
-            }
-        } else {  // UltraList is off.
-            // Turn the switch off.
-            ultraListSwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
-            } else {
-                ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
-            }
-        }
-
-        // Set the UltraPrivacy status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (ultraPrivacyInt == 1) {  // UltraPrivacy is on.
-            // Turn the switch on.
-            ultraPrivacySwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
-            } else {
-                ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
-            }
-        } else {  // EasyPrivacy is off.
-            // Turn the switch off.
-            ultraPrivacySwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
-            } else {
-                ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
-            }
         }
 
-        // Set the third-party resource blocking status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        if (blockAllThirdPartyRequestsInt == 1) {  // Blocking all third-party requests is on.
-            // Turn the switch on.
-            blockAllThirdPartyRequestsSwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_night, null));
-            } else {
-                blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_day, null));
-            }
-        } else {  // Blocking all third-party requests is off.
-            // Turn the switch off.
-            blockAllThirdPartyRequestsSwitch.setChecked(false);
+        // Set Fanboy's Social Blocking List switch status based on the Annoyance List status.
+        fanboysSocialBlockingListSwitch.setEnabled(fanboysAnnoyanceListInt == 0);
 
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_night, null));
-            } else {
-                blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_day, null));
-            }
-        }
+        // Set the Social Blocking List icon ghosted status based on the Annoyance List status.
+        fanboysSocialBlockingListImageView.setEnabled(fanboysAnnoyanceListInt == 0);
 
         // Inflated a WebView to get the default user agent.
         // `@SuppressLint("InflateParams")` removes the warning about using `null` as the `ViewGroup`, which in this case makes sense because the bare WebView should not be displayed on the screen.
@@ -699,7 +424,7 @@ public class DomainSettingsFragment extends Fragment {
         final String webViewDefaultUserAgentString = bareWebView.getSettings().getUserAgentString();
 
         // Get a handle for the user agent array adapter.  This array does not contain the `System default` entry.
-        ArrayAdapter<CharSequence> userAgentNamesArray = ArrayAdapter.createFromResource(context, R.array.user_agent_names, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> userAgentNamesArray = ArrayAdapter.createFromResource(requireContext(), R.array.user_agent_names, R.layout.spinner_item);
 
         // Get the positions of the user agent and the default user agent.
         int userAgentArrayPosition = userAgentNamesArray.getPosition(currentUserAgentName);
@@ -731,7 +456,8 @@ public class DomainSettingsFragment extends Fragment {
                     // Get the user agent string from the user agent data array.
                     userAgentTextView.setText(userAgentDataArray[defaultUserAgentArrayPosition]);
             }
-        } else if (userAgentArrayPosition == MainWebViewActivity.UNRECOGNIZED_USER_AGENT) {  // A custom user agent is stored in the current user agent name.
+        } else if (userAgentArrayPosition == MainWebViewActivity.UNRECOGNIZED_USER_AGENT || currentUserAgentName.equals(getString(R.string.custom_user_agent))) {
+            // A custom user agent is stored in the current user agent name.  The second check is necessary in case the user did not change the default custom text.
             // Set the user agent spinner to `Custom user agent`.
             userAgentSpinner.setSelection(MainWebViewActivity.DOMAINS_CUSTOM_USER_AGENT);
 
@@ -767,6 +493,54 @@ public class DomainSettingsFragment extends Fragment {
             userAgentSpinner.performClick();
         });
 
+        // Select the X-Requested-With header selection in the spinner.
+        xRequestedWithHeaderSpinner.setSelection(xRequestedWithHeaderInt);
+
+        // Set the X-Requested-With header text.
+        if (defaultXRequestedWithHeader)
+            xRequestedWithHeaderTextView.setText(xRequestedWithHeaderArrayAdapter.getItem(DomainsDatabaseHelper.ENABLED));
+        else
+            xRequestedWithHeaderTextView.setText(xRequestedWithHeaderArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED));
+
+        // Set the X-Requested-With header icon and text view settings.
+        switch (xRequestedWithHeaderInt) {
+            case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+                // Set the icon color.
+                xRequestedWithHeaderImageView.setSelected(defaultXRequestedWithHeader);
+
+                // Show the X-Requested-With header text view.
+                xRequestedWithHeaderTextView.setVisibility(View.VISIBLE);
+                break;
+
+            case DomainsDatabaseHelper.ENABLED:
+                // Set the icon color.
+                xRequestedWithHeaderImageView.setSelected(true);
+
+                // Hide the X-Requested-With header text view.
+                xRequestedWithHeaderTextView.setVisibility(View.GONE);
+                break;
+
+            case DomainsDatabaseHelper.DISABLED:
+                // Set the icon color.
+                xRequestedWithHeaderImageView.setSelected(false);
+
+                // Hide the X-Requested-With header text view.
+                xRequestedWithHeaderTextView.setVisibility(View.GONE);
+                break;
+        }
+
+        // Open the X-Requested-With header spinner when the text view is clicked.
+        xRequestedWithHeaderTextView.setOnClickListener((View v) -> {
+            // Open the X-Requested-With header spinner.
+            xRequestedWithHeaderSpinner.performClick();
+        });
+
+        // Open the X-Requested-With header spinner when the explanation text view is clicked.
+        xRequestedWithHeaderExplanationTextView.setOnClickListener((View v) -> {
+            // Open the X-Requested header spinner.
+            xRequestedWithHeaderSpinner.performClick();
+        });
+
         // Display the font size settings.
         if (fontSizeInt == 0) {  // `0` is the code for system default font size.
             // Set the font size to the system default
@@ -810,61 +584,39 @@ public class DomainSettingsFragment extends Fragment {
         swipeToRefreshSpinner.setSelection(swipeToRefreshInt);
 
         // Set the swipe to refresh text.
-        if (defaultSwipeToRefresh) {
+        if (defaultSwipeToRefresh)
             swipeToRefreshTextView.setText(swipeToRefreshArrayAdapter.getItem(DomainsDatabaseHelper.ENABLED));
-        } else {
+        else
             swipeToRefreshTextView.setText(swipeToRefreshArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED));
-        }
 
-        // Set the swipe to refresh icon and TextView settings.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+        // Set the swipe to refresh icon and text view settings.
         switch (swipeToRefreshInt) {
             case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                if (defaultSwipeToRefresh) {  // Swipe to refresh is enabled by default.
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
-                    } else {
-                        swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
-                    }
-                } else {  // Swipe to refresh is disabled by default
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
-                    } else {
-                        swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
-                    }
-                }
+                // Set the icon color.
+                swipeToRefreshImageView.setSelected(defaultSwipeToRefresh);
 
-                // Show the swipe to refresh TextView.
+                // Show the swipe to refresh text view.
                 swipeToRefreshTextView.setVisibility(View.VISIBLE);
                 break;
 
             case DomainsDatabaseHelper.ENABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
-                } else {
-                    swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
-                }
+                // Set the icon color.
+                swipeToRefreshImageView.setSelected(true);
 
-                // Hide the swipe to refresh TextView.`
+                // Hide the swipe to refresh text view.
                 swipeToRefreshTextView.setVisibility(View.GONE);
                 break;
 
             case DomainsDatabaseHelper.DISABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
-                } else {
-                    swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
-                }
+                // Set the icon color.
+                swipeToRefreshImageView.setSelected(false);
 
-                // Hide the swipe to refresh TextView.
+                // Hide the swipe to refresh text view.
                 swipeToRefreshTextView.setVisibility(View.GONE);
                 break;
         }
 
-        // Open the swipe to refresh spinner when the TextView is clicked.
+        // Open the swipe to refresh spinner when the text view is clicked.
         swipeToRefreshTextView.setOnClickListener((View v) -> {
             // Open the swipe to refresh spinner.
             swipeToRefreshSpinner.performClick();
@@ -889,151 +641,100 @@ public class DomainSettingsFragment extends Fragment {
             appWebViewThemeEntryNumber = 0;
         }
 
-        // Set the WebView theme visibility.
-        if (Build.VERSION.SDK_INT < 21) {  // The WebView theme cannot be set on API 19.
-            // Get a handle for the webView theme linear layout.
-            LinearLayout webViewThemeLinearLayout = domainSettingsView.findViewById(R.id.webview_theme_linearlayout);
-
-            // Hide the WebView theme linear layout.
-            webViewThemeLinearLayout.setVisibility(View.GONE);
-        } else {  // The WebView theme can be set on API >= 21.
-            // Select the WebView theme in the spinner.
-            webViewThemeSpinner.setSelection(webViewThemeInt);
-
-            // Set the WebView theme text.
-            if (appWebViewThemeEntryNumber == DomainsDatabaseHelper.SYSTEM_DEFAULT) {  // The app WebView theme is system default.
-                // Set the text according to the current UI theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                    webViewThemeTextView.setText(webViewThemeStringArray[DomainsDatabaseHelper.LIGHT_THEME]);
-                } else {
-                    webViewThemeTextView.setText(webViewThemeStringArray[DomainsDatabaseHelper.DARK_THEME]);
-                }
-            } else {  // The app WebView theme is not system default.
-                // Set the text according to the app WebView theme.
-                webViewThemeTextView.setText(webViewThemeStringArray[appWebViewThemeEntryNumber]);
+        // Select the WebView theme in the spinner.
+        webViewThemeSpinner.setSelection(webViewThemeInt);
+
+        // Set the WebView theme text.
+        if (appWebViewThemeEntryNumber == DomainsDatabaseHelper.SYSTEM_DEFAULT) {  // The app WebView theme is system default.
+            // Set the text according to the current UI theme.
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                webViewThemeTextView.setText(webViewThemeStringArray[DomainsDatabaseHelper.LIGHT_THEME]);
+            } else {
+                webViewThemeTextView.setText(webViewThemeStringArray[DomainsDatabaseHelper.DARK_THEME]);
             }
+        } else {  // The app WebView theme is not system default.
+            // Set the text according to the app WebView theme.
+            webViewThemeTextView.setText(webViewThemeStringArray[appWebViewThemeEntryNumber]);
+        }
 
-            // Set the WebView theme icon and text visibility.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-            switch (webViewThemeInt) {
-                case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The domain WebView theme is system default.
-                    // Set the icon according to the app WebView theme.
-                    switch (appWebViewThemeEntryNumber) {
-                        case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The default WebView theme is system default.
-                            // Set the icon according to the app theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                                // Set the light mode icon.
-                                webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
-                            } else {
-                                // Set the dark theme icon.
-                                webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
-                            }
-                            break;
-
-                        case DomainsDatabaseHelper.LIGHT_THEME:  // the default WebView theme is light.
-                            // Set the icon according to the app theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                                webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
-                            } else {
-                                webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
-                            }
-                            break;
-
-                        case DomainsDatabaseHelper.DARK_THEME:  // the default WebView theme is dark.
-                            // Set the icon according to the app theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                                webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
-                            } else {
-                                webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));                            }
-                            break;
-                    }
+        // Set the WebView theme icon and text visibility.
+        switch (webViewThemeInt) {
+            case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The domain WebView theme is system default.
+                // Set the icon according to the app WebView theme.
+                switch (appWebViewThemeEntryNumber) {
+                    case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The default WebView theme is system default.
+                        // Set the icon color.
+                        webViewThemeImageView.setSelected(currentThemeStatus == Configuration.UI_MODE_NIGHT_NO);
+                        break;
 
-                    // Show the WebView theme text view.
-                    webViewThemeTextView.setVisibility(View.VISIBLE);
-                    break;
+                    case DomainsDatabaseHelper.LIGHT_THEME:  // the default WebView theme is light.
+                        // Set the icon color.
+                        webViewThemeImageView.setSelected(true);
+                        break;
 
-                case DomainsDatabaseHelper.LIGHT_THEME:  // The domain WebView theme is light.
-                    // Set the icon according to the app theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                        webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
-                    } else {
-                        webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
-                    }
+                    case DomainsDatabaseHelper.DARK_THEME:  // the default WebView theme is dark.
+                        // Set the icon color.
+                        webViewThemeImageView.setSelected(false);
+                        break;
+                }
 
-                    // Hide the WebView theme text view.
-                    webViewThemeTextView.setVisibility(View.GONE);
-                    break;
+                // Show the WebView theme text view.
+                webViewThemeTextView.setVisibility(View.VISIBLE);
+                break;
 
-                case DomainsDatabaseHelper.DARK_THEME:  // The domain WebView theme is dark.
-                    // Set the icon according to the app theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                        webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
-                    } else {
-                        webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
-                    }
+            case DomainsDatabaseHelper.LIGHT_THEME:  // The domain WebView theme is light.
+                // Set the icon color.
+                webViewThemeImageView.setSelected(true);
 
-                    // Hide the WebView theme text view.
-                    webViewThemeTextView.setVisibility(View.GONE);
-                    break;
-            }
+                // Hide the WebView theme text view.
+                webViewThemeTextView.setVisibility(View.GONE);
+                break;
 
-            // Open the WebView theme spinner when the text view is clicked.
-            webViewThemeTextView.setOnClickListener((View v) -> {
-                // Open the WebView theme spinner.
-                webViewThemeSpinner.performClick();
-            });
+            case DomainsDatabaseHelper.DARK_THEME:  // The domain WebView theme is dark.
+                // Set the icon color.
+                webViewThemeImageView.setSelected(false);
+
+                // Hide the WebView theme text view.
+                webViewThemeTextView.setVisibility(View.GONE);
+                break;
         }
 
+        // Open the WebView theme spinner when the text view is clicked.
+        webViewThemeTextView.setOnClickListener((View v) -> {
+            // Open the WebView theme spinner.
+            webViewThemeSpinner.performClick();
+        });
+
         // Select the wide viewport in the spinner.
         wideViewportSpinner.setSelection(wideViewportInt);
 
         // Set the default wide viewport text.
-        if (defaultWideViewport) {
+        if (defaultWideViewport)
             wideViewportTextView.setText(wideViewportArrayAdapter.getItem(DomainsDatabaseHelper.ENABLED));
-        } else {
+        else
             wideViewportTextView.setText(wideViewportArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED));
-        }
 
-        // Set the wide viewport icon and text view settings.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+        // Set the wide viewport icon and text view settings.
         switch (wideViewportInt) {
             case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                if (defaultWideViewport) {  // Wide viewport enabled by default.
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
-                    } else {
-                        wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
-                    }
-                } else {  // Wide viewport disabled by default.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
-                    } else {
-                        wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
-                    }
-                }
+                // Set the icon color.
+                wideViewportImageView.setSelected(defaultWideViewport);
 
                 // Show the wide viewport text view.
                 wideViewportTextView.setVisibility(View.VISIBLE);
                 break;
 
             case DomainsDatabaseHelper.ENABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
-                } else {
-                    wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
-                }
+                // Set the icon color.
+                wideViewportImageView.setSelected(true);
 
                 // Hide the wide viewport text view.
                 wideViewportTextView.setVisibility(View.GONE);
                 break;
 
             case DomainsDatabaseHelper.DISABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
-                } else {
-                    wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
-                }
+                // Set the icon color.
+                wideViewportImageView.setSelected(false);
 
                 // Hide the wide viewport text view.
                 wideViewportTextView.setVisibility(View.GONE);
@@ -1056,48 +757,27 @@ public class DomainSettingsFragment extends Fragment {
             displayImagesTextView.setText(displayImagesArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED));
         }
 
-        // Set the display website images icon and text view settings.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+        // Set the display website images icon and text view settings.
         switch (displayImagesInt) {
             case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                if (defaultDisplayWebpageImages) {  // Display webpage images enabled by default.
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
-                    } else {
-                        displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
-                    }
-                } else {  // Display webpage images disabled by default.
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
-                    } else {
-                        displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
-                    }
-                }
+                // Set the icon color.
+                displayWebpageImagesImageView.setSelected(defaultDisplayWebpageImages);
 
                 // Show the display images text view.
                 displayImagesTextView.setVisibility(View.VISIBLE);
                 break;
 
             case DomainsDatabaseHelper.ENABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
-                } else {
-                    displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
-                }
+                // Set the icon color.
+                displayWebpageImagesImageView.setSelected(true);
 
                 // Hide the display images text view.
                 displayImagesTextView.setVisibility(View.GONE);
                 break;
 
             case DomainsDatabaseHelper.DISABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
-                } else {
-                    displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
-                }
+                // Set the icon color.
+                displayWebpageImagesImageView.setSelected(false);
 
                 // Hide the display images text view.
                 displayImagesTextView.setVisibility(View.GONE);
@@ -1109,29 +789,6 @@ public class DomainSettingsFragment extends Fragment {
             // Open the user agent spinner.
             displayWebpageImagesSpinner.performClick();
         });
-        
-        // Set the pinned SSL certificate icon.
-        if (pinnedSslCertificateInt == 1) {  // Pinned SSL certificate is enabled.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-            // Check the switch.
-            pinnedSslCertificateSwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
-            } else {
-                pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
-            }
-        } else {  // Pinned SSL certificate is disabled.
-            // Uncheck the switch.
-            pinnedSslCertificateSwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
-            } else {
-                pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
-            }
-        }
 
         // Store the current date.
         Date currentDate = Calendar.getInstance().getTime();
@@ -1297,29 +954,6 @@ public class DomainSettingsFragment extends Fragment {
             currentWebsiteCertificateRadioButton.setChecked(false);
         }
 
-        // Set the pinned IP addresses icon.
-        if (pinnedIpAddressesInt == 1) {  // Pinned IP addresses is enabled.  Once the minimum API >= 21 a selector can be sued as the tint mode instead of specifying different icons.
-            // Check the switch.
-            pinnedIpAddressesSwitch.setChecked(true);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
-            } else {
-                pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
-            }
-        } else {  // Pinned IP Addresses is disabled.
-            // Uncheck the switch.
-            pinnedIpAddressesSwitch.setChecked(false);
-
-            // Set the icon according to the theme.
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
-            } else {
-                pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
-            }
-        }
-
         // Populate the saved and current IP addresses.
         savedIpAddressesTextView.setText(savedIpAddresses);
         currentIpAddressesTextView.setText(DomainsActivity.currentIpAddresses);
@@ -1370,298 +1004,86 @@ public class DomainSettingsFragment extends Fragment {
 
         // Set the JavaScript switch listener.
         javaScriptSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            if (isChecked) {  // JavaScript is enabled.
-                // Update the JavaScript icon.
+            // Update the JavaScript icon.
+            if (isChecked)
                 javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.javascript_enabled, null));
-
-                // Enable the DOM storage `Switch`.
-                domStorageSwitch.setEnabled(true);
-
-                // Update the DOM storage icon.
-                if (domStorageSwitch.isChecked()) {  // DOM storage is enabled.
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
-                } else {  // DOM storage is disabled.
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
-                    } else {
-                        domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
-                    }
-                }
-            } else {  // JavaScript is disabled.
-                // Update the JavaScript icon.
+            else
                 javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.privacy_mode, null));
 
-                // Disable the DOM storage `Switch`.
-                domStorageSwitch.setEnabled(false);
-
-                // Set the DOM storage icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_night, null));
-                } else {
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_day, null));
-                }
-            }
-        });
-
-        // Set the first-party cookies switch listener.
-        firstPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            if (isChecked) {  // First-party cookies are enabled.
-                // Update the first-party cookies icon.
-                firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
-
-                // Enable the third-party cookies switch.
-                thirdPartyCookiesSwitch.setEnabled(true);
-
-                // Update the third-party cookies icon.
-                if (thirdPartyCookiesSwitch.isChecked()) {  // Third-party cookies are enabled.
-                    // Set the third-party cookies icon to be red.
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_warning, null));
-                } else {  // Third-party cookies are disabled.
-                    // Set the third-party cookies icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
-                    } else {
-                        thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
-                    }
-                }
-            } else {  // First-party cookies are disabled.
-                // Update the first-party cookies icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
-                } else {
-                    firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
-                }
-
-                // Disable the third-party cookies switch.
-                thirdPartyCookiesSwitch.setEnabled(false);
+            // Set the DOM storage switch status.
+            domStorageSwitch.setEnabled(isChecked);
 
-                // Set the third-party cookies icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_ghosted_night, null));
-                } else {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_ghosted_day, null));
-                }
-            }
+            // Set the DOM storage ghosted icon status.
+            domStorageImageView.setEnabled(isChecked);
         });
 
-        // Set the third-party cookies switch listener.
-        thirdPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {
-                // Set the third-party cookies icon to be red.
-                thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_warning, null));
-            } else {
-                // Update the third-party cookies icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
-                } else {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
-                }
-            }
+        // Set the cookies switch listener.
+        cookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+            // Update the icon color.
+            cookiesImageView.setSelected(isChecked);
         });
 
         // Set the DOM Storage switch listener.
         domStorageSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {
-                domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
-            } else {
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
-                } else {
-                    domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            domStorageImageView.setSelected(isChecked);
         });
 
         // Set the form data switch listener.  It can be removed once the minimum API >= 26.
         if (Build.VERSION.SDK_INT < 26) {
             formDataSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-                // Update the icon.
-                if (isChecked) {
-                    formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_enabled, null));
-                } else {
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_night, null));
-                    } else {
-                        formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_day, null));
-                    }
-                }
+                // Update the icon color.
+                formDataImageView.setSelected(isChecked);
             });
         }
 
         // Set the EasyList switch listener.
         easyListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // EasyList is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
-                } else {
-                    easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
-                }
-            } else {  // EasyList is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
-                } else {
-                    easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            easyListImageView.setSelected(isChecked);
         });
 
         // Set the EasyPrivacy switch listener.
         easyPrivacySwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // EasyPrivacy is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
-                } else {
-                    easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
-                }
-            } else {  // EasyPrivacy is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
-                } else {
-                    easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            easyPrivacyImageView.setSelected(isChecked);
         });
 
         // Set the Fanboy's Annoyance List switch listener.
         fanboysAnnoyanceListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon and Fanboy's Social Blocking List.
-            if (isChecked) {  // Fanboy's Annoyance List is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
-                } else {
-                    fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
-                }
+            // Update the icon color.
+            fanboysAnnoyanceListImageView.setSelected(isChecked);
 
-                // Disable the Fanboy's Social Blocking List switch.
-                fanboysSocialBlockingListSwitch.setEnabled(false);
 
-                // Update the Fanboy's Social Blocking List icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_night, null));
-                } else {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_day, null));
-                }
-            } else {  // Fanboy's Annoyance List is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
-                } else {
-                    fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
-                }
-
-                // Enable the Fanboy's Social Blocking List switch.
-                fanboysSocialBlockingListSwitch.setEnabled(true);
-
-                // Update the Fanboy's Social Blocking List icon.
-                if (fanboysSocialBlockingListSwitch.isChecked()) {  // Fanboy's Social Blocking List is on.
-                    // Update the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
-                    } else {
-                        fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
-                    }
-                } else {  // Fanboy's Social Blocking List is off.
-                    // Update the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
-                    } else {
-                        fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
-                    }
-                }
-            }
+            // Set Fanboy's Social Blocking List switch position.
+            fanboysSocialBlockingListSwitch.setEnabled(!isChecked);
 
+            // Set the Social Blocking List icon ghosted status.
+            fanboysSocialBlockingListImageView.setEnabled(!isChecked);
         });
 
         // Set the Fanboy's Social Blocking List switch listener.
         fanboysSocialBlockingListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // Fanboy's Social Blocking List is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
-                } else {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
-                }
-            } else {  // Fanboy's Social Blocking List is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
-                } else {
-                    fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            fanboysSocialBlockingListImageView.setSelected(isChecked);
         });
 
         // Set the UltraList switch listener.
         ultraListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // UltraList is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
-                } else {
-                    ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
-                }
-            } else {  // UltraList is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
-                } else {
-                    ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            ultraListImageView.setSelected(isChecked);
         });
 
         // Set the UltraPrivacy switch listener.
         ultraPrivacySwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // UltraPrivacy is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
-                } else {
-                    ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
-                }
-            } else {  // UltraPrivacy is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
-                } else {
-                    ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            ultraPrivacyImageView.setSelected(isChecked);
         });
 
         // Set the block all third-party requests switch listener.
         blockAllThirdPartyRequestsSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // Blocking all third-party requests is on.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_night, null));
-                } else {
-                    blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_day, null));
-                }
-            } else {  // Blocking all third-party requests is off.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_night, null));
-                } else {
-                    blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_day, null));
-                }
-            }
+            // Update the icon color.
+            blockAllThirdPartyRequestsImageView.setSelected(isChecked);
         });
 
         // Set the user agent spinner listener.
@@ -1734,6 +1156,44 @@ public class DomainSettingsFragment extends Fragment {
             }
         });
 
+        // Set the X-Requested-With header spinner listener.
+        xRequestedWithHeaderSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                // Update the icon and the visibility of the text view.
+                switch (position) {
+                    case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+                        // Set the icon color.
+                        xRequestedWithHeaderImageView.setSelected(defaultXRequestedWithHeader);
+
+                        // Show the X-Requested-With header text view.
+                        xRequestedWithHeaderTextView.setVisibility(View.VISIBLE);
+                        break;
+
+                    case DomainsDatabaseHelper.ENABLED:
+                        // Set the icon color.
+                        xRequestedWithHeaderImageView.setSelected(true);
+
+                        // Hide the X-Requested-With header text view.
+                        xRequestedWithHeaderTextView.setVisibility(View.GONE);
+                        break;
+
+                    case DomainsDatabaseHelper.DISABLED:
+                        // Set the icon color.
+                        xRequestedWithHeaderImageView.setSelected(false);
+
+                        // Hide the X-Requested-With header text view.
+                        xRequestedWithHeaderTextView.setVisibility(View.GONE);
+                        break;
+                }
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+                // Do nothing.
+            }
+        });
+
         // Set the font size spinner listener.
         fontSizeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
@@ -1764,50 +1224,29 @@ public class DomainSettingsFragment extends Fragment {
         swipeToRefreshSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                // Update the icon and the visibility of `nightModeTextView`.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+                // Update the icon and the visibility of the text view.
                 switch (position) {
                     case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                        if (defaultSwipeToRefresh) {  // Swipe to refresh enabled by default.
-                            // Set the icon according to the theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
-                            } else {
-                                swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
-                            }
-                        } else {  // Swipe to refresh disabled by default.
-                            // Set the icon according to the theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
-                            } else {
-                                swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
-                            }
-                        }
+                        // Set the icon color.
+                        swipeToRefreshImageView.setSelected(defaultSwipeToRefresh);
 
-                        // Show the swipe to refresh TextView.
+                        // Show the swipe to refresh text view.
                         swipeToRefreshTextView.setVisibility(View.VISIBLE);
                         break;
 
                     case DomainsDatabaseHelper.ENABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_night, null));
-                        } else {
-                            swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled_day, null));
-                        }
+                        // Set the icon color.
+                        swipeToRefreshImageView.setSelected(true);
 
-                        // Hide the swipe to refresh TextView.
+                        // Hide the swipe to refresh text view.
                         swipeToRefreshTextView.setVisibility(View.GONE);
                         break;
 
                     case DomainsDatabaseHelper.DISABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_night, null));
-                        } else {
-                            swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled_day, null));
-                        }
+                        // Set the icon color.
+                        swipeToRefreshImageView.setSelected(false);
 
-                        // Hide the swipe to refresh TextView.
+                        // Hide the swipe to refresh text view.
                         swipeToRefreshTextView.setVisibility(View.GONE);
                 }
             }
@@ -1822,38 +1261,24 @@ public class DomainSettingsFragment extends Fragment {
         webViewThemeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                // Update the icon and the visibility of the WebView theme text view.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+                // Update the icon and the visibility of the WebView theme text view.
                 switch (position) {
                     case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // the domain WebView theme is system default.
                         // Set the icon according to the app WebView theme.
                         switch (appWebViewThemeEntryNumber) {
                             case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The default WebView theme is system default.
-                                // Set the icon according to the app theme.
-                                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                                    // Set the light mode icon.
-                                    webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
-                                } else {
-                                    // Set the dark theme icon.
-                                    webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
-                                }
+                                // Set the icon color.
+                                webViewThemeImageView.setSelected(currentThemeStatus == Configuration.UI_MODE_NIGHT_NO);
                                 break;
 
                             case DomainsDatabaseHelper.LIGHT_THEME:  // The default WebView theme is light.
-                                // Set the icon according to the app theme.
-                                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                                    webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
-                                } else {
-                                    webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
-                                }
+                                // Set the icon color.
+                                webViewThemeImageView.setSelected(true);
                                 break;
 
                             case DomainsDatabaseHelper.DARK_THEME:  // The default WebView theme is dark.
-                                // Set the icon according to the app theme.
-                                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                                    webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
-                                } else {
-                                    webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
-                                }
+                                // Set the icon.
+                                webViewThemeImageView.setSelected(false);
                                 break;
                         }
 
@@ -1862,24 +1287,16 @@ public class DomainSettingsFragment extends Fragment {
                         break;
 
                     case DomainsDatabaseHelper.LIGHT_THEME:  // The domain WebView theme is light.
-                        // Set the icon according to the app theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                            webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_day, null));
-                        } else {
-                            webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme_night, null));
-                        }
+                        // Set the icon color.
+                        webViewThemeImageView.setSelected(true);
 
                         // Hide the WebView theme text view.
                         webViewThemeTextView.setVisibility(View.GONE);
                         break;
 
                     case DomainsDatabaseHelper.DARK_THEME:  // The domain WebView theme is dark.
-                        // Set the icon according to the app theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                            webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_day, null));
-                        } else {
-                            webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null));
-                        }
+                        // Set the icon color.
+                        webViewThemeImageView.setSelected(false);
 
                         // Hide the WebView theme text view.
                         webViewThemeTextView.setVisibility(View.GONE);
@@ -1900,44 +1317,24 @@ public class DomainSettingsFragment extends Fragment {
                 // Update the icon and the visibility of the wide viewport text view.
                 switch (position) {
                     case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                        if (defaultWideViewport) {  // Wide viewport is enabled by default.
-                            // Set the icon according to the theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
-                            } else {
-                                wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
-                            }
-                        } else {  // Wide viewport is disabled by default.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
-                            } else {
-                                wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
-                            }
-                        }
+                        // Set the icon color.
+                        wideViewportImageView.setSelected(defaultWideViewport);
 
                         // Show the wide viewport text view.
                         wideViewportTextView.setVisibility(View.VISIBLE);
                         break;
 
                     case DomainsDatabaseHelper.ENABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_night, null));
-                        } else {
-                            wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled_day, null));
-                        }
+                        // Set the icon color.
+                        wideViewportImageView.setSelected(true);
 
                         // Hide the wide viewport text view.
                         wideViewportTextView.setVisibility(View.GONE);
                         break;
 
                     case DomainsDatabaseHelper.DISABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_night, null));
-                        } else {
-                            wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled_day, null));
-                        }
+                        // Set the icon color.
+                        wideViewportImageView.setSelected(false);
 
                         // Hid ethe wide viewport text view.
                         wideViewportTextView.setVisibility(View.GONE);
@@ -1958,45 +1355,24 @@ public class DomainSettingsFragment extends Fragment {
                 // Update the icon and the visibility of the display images text view.
                 switch (position) {
                     case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                        if (defaultDisplayWebpageImages) {  // Display webpage images is enabled by default.
-                            // Set the icon according to the theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
-                            } else {
-                                displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
-                            }
-                        } else {  // Display webpage images is disabled by default.
-                            // Set the icon according to the theme.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
-                            } else {
-                                displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
-                            }
-                        }
+                        // Set the icon color.
+                        displayWebpageImagesImageView.setSelected(defaultDisplayWebpageImages);
 
                         // Show the display images text view.
                         displayImagesTextView.setVisibility(View.VISIBLE);
                         break;
 
                     case DomainsDatabaseHelper.ENABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
-                        } else {
-                            displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
-                        }
+                        // Set the icon color.
+                        displayWebpageImagesImageView.setSelected(true);
 
                         // Hide the display images text view.
                         displayImagesTextView.setVisibility(View.GONE);
                         break;
 
                     case DomainsDatabaseHelper.DISABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
-                        } else {
-                            displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
-                        }
+                        // Set the icon color.
+                        displayWebpageImagesImageView.setSelected(false);
 
                         // Hide the display images text view.
                         displayImagesTextView.setVisibility(View.GONE);
@@ -2012,15 +1388,11 @@ public class DomainSettingsFragment extends Fragment {
         
         // Set the pinned SSL certificate switch listener.
         pinnedSslCertificateSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // SSL certificate pinning is enabled.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
-                } else {
-                    pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
-                }
+            // Update the icon color.
+            pinnedSslCertificateImageView.setSelected(isChecked);
 
+            // Update the views.
+            if (isChecked) {  // SSL certificate pinning is enabled.
                 // Update the visibility of the saved SSL certificate.
                 if (savedSslIssuedToCNameString == null) {
                     savedSslCardView.setVisibility(View.GONE);
@@ -2091,13 +1463,6 @@ public class DomainSettingsFragment extends Fragment {
                     noCurrentWebsiteCertificateTextView.getParent().requestChildFocus(noCurrentWebsiteCertificateTextView, noCurrentWebsiteCertificateTextView);
                 }
             } else {  // SSL certificate pinning is disabled.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
-                } else {
-                    pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
-                }
-
                 // Hide the SSl certificates and instructions.
                 savedSslCardView.setVisibility(View.GONE);
                 currentSslCardView.setVisibility(View.GONE);
@@ -2183,15 +1548,11 @@ public class DomainSettingsFragment extends Fragment {
 
         // Set the pinned IP addresses switch listener.
         pinnedIpAddressesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
-            // Update the icon.
-            if (isChecked) {  // IP addresses pinning is enabled.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
-                } else {
-                    pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
-                }
+            // Update the icon color.
+            pinnedIpAddressesImageView.setSelected(isChecked);
 
+            // Update the views.
+            if (isChecked) {  // IP addresses pinning is enabled.
                 // Update the visibility of the saved IP addresses card view.
                 if (savedIpAddresses == null) {  // There are no saved IP addresses.
                     savedIpAddressesCardView.setVisibility(View.GONE);
@@ -2240,13 +1601,6 @@ public class DomainSettingsFragment extends Fragment {
                 // Scroll to the bottom of the card views.
                 currentIpAddressesCardView.getParent().requestChildFocus(currentIpAddressesCardView, currentIpAddressesCardView);
             } else {  // IP addresses pinning is disabled.
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
-                } else {
-                    pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
-                }
-
                 // Hide the IP addresses card views.
                 savedIpAddressesCardView.setVisibility(View.GONE);
                 currentIpAddressesCardView.setVisibility(View.GONE);