]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
Bump the minimum API to 23. https://redmine.stoutner.com/issues/793
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / DomainSettingsFragment.java
index 35d626935039f0c5a151df734ba148bf83d53c58..4ae52c94c00698e7498cb394a68f76d48f579dfd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2021 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -120,11 +120,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.
@@ -212,46 +209,45 @@ public class DomainSettingsFragment extends Fragment {
         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 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.
@@ -304,16 +300,16 @@ public class DomainSettingsFragment extends Fragment {
         }
 
         // Create the foreground color spans.
-        final ForegroundColorSpan redColorSpan;
         final ForegroundColorSpan blueColorSpan;
+        final ForegroundColorSpan redColorSpan;
 
-        // 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));
+        // Set the color spans according to the theme.
+        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+            blueColorSpan = new ForegroundColorSpan(context.getColor(R.color.blue_700));
+            redColorSpan = new ForegroundColorSpan(context.getColor(R.color.red_a700));
         } else {
-            redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_a700));
-            blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_700));
+            blueColorSpan = new ForegroundColorSpan(context.getColor(R.color.violet_700));
+            redColorSpan = new ForegroundColorSpan(context.getColor(R.color.red_900));
         }
 
         // Set the domain name from the the database cursor.
@@ -382,69 +378,28 @@ public class DomainSettingsFragment extends Fragment {
             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 cookies switch status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+        if (cookiesInt == 1) {  // Cookies are enabled.
+            // Turn the switch on.
+            cookiesSwitch.setChecked(true);
+
+            // Set the icon.
+            cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
+        } else {  // Cookies are disabled.
+            // Turn the switch off
+            cookiesSwitch.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));
+            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
             } else {
-                firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
+                cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, 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);
-        }
-
         // Only enable DOM storage if JavaScript is enabled.
         if (javaScriptInt == 1) {  // JavaScript is enabled.
-            // Enable the DOM storage `Switch`.
+            // 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.
@@ -467,11 +422,7 @@ public class DomainSettingsFragment extends Fragment {
             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);
-            }
+            domStorageSwitch.setChecked(domStorageInt == 1);
 
             // Set the icon according to the theme.
             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
@@ -606,14 +557,8 @@ public class DomainSettingsFragment extends Fragment {
             // 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 status of Fanboy's Social Blocking List.
+            fanboysSocialBlockingListSwitch.setChecked(fanboysSocialBlockingListInt == 1);
 
             // Set the icon according to the theme.
             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
@@ -889,100 +834,91 @@ 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);
+        // 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;
+        // 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]);
+        }
 
-                        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;
+        // 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.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;
-                    }
+                    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;
 
-                    // Show the WebView theme text view.
-                    webViewThemeTextView.setVisibility(View.VISIBLE);
-                    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;
+                }
 
-                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));
-                    }
+                // Show the WebView theme text view.
+                webViewThemeTextView.setVisibility(View.VISIBLE);
+                break;
 
-                    // Hide the WebView theme text view.
-                    webViewThemeTextView.setVisibility(View.GONE);
-                    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 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));
-                    }
+                // Hide the WebView theme text view.
+                webViewThemeTextView.setVisibility(View.GONE);
+                break;
 
-                    // 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));
+                }
 
-            // Open the WebView theme spinner when the text view is clicked.
-            webViewThemeTextView.setOnClickListener((View v) -> {
-                // Open the WebView theme spinner.
-                webViewThemeSpinner.performClick();
-            });
+                // 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);
 
@@ -1404,59 +1340,17 @@ public class DomainSettingsFragment extends Fragment {
             }
         });
 
-        // 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 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 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));
+        // Set the cookies switch listener.
+        cookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+            if (isChecked) {  // Cookies are enabled.
+                // Update the cookies icon.
+                cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
+            } else {  // Cookies are disabled.
+                // Update the cookies icon according to the theme.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                    cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
                 } else {
-                    thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
+                    cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
                 }
             }
         });