X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FDomainSettingsFragment.java;h=1ce0e3cccd5a7668b52f85738652ec8692f344a7;hp=d2809b541097aa2ea3cf538ce2920faeb5083e33;hb=1b27ac6f2b7c046945fc97e2aff9adbde8a152ce;hpb=4c00dd29a0a8592dff337d8b01870f06134c070b diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java index d2809b54..1ce0e3cc 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java @@ -1,20 +1,20 @@ /* - * Copyright © 2017-2021 Soren Stoutner . + * Copyright © 2017-2022 Soren Stoutner . * - * This file is part of Privacy Browser . + * This file is part of 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 . + * along with Privacy Browser Android. If not, see . */ package com.stoutner.privacybrowser.fragments; @@ -209,45 +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 cookiesInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.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. @@ -299,18 +299,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 blueColorSpan; - final ForegroundColorSpan redColorSpan; - - // Set the color spans according to the theme. The deprecated `getColor()` must be used until the minimum API >= 23. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_700)); - redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_a700)); - } else { - blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.violet_700)); - redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_900)); - } + // Create the color spans. + final ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(context.getColor(R.color.blue_text)); + final ForegroundColorSpan redColorSpan = new ForegroundColorSpan(context.getColor(R.color.red_text)); // Set the domain name from the the database cursor. domainNameEditText.setText(domainNameString); @@ -379,6 +370,7 @@ public class DomainSettingsFragment extends Fragment { } // Set the cookies switch status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. if (cookiesInt == 1) { // Cookies are enabled. // Turn the switch on. cookiesSwitch.setChecked(true); @@ -389,12 +381,8 @@ public class DomainSettingsFragment extends Fragment { // Turn the switch off cookiesSwitch.setChecked(false); - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null)); - } else { - cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null)); - } + // Set the icon. + cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled, null)); } // Only enable DOM storage if JavaScript is enabled. @@ -403,6 +391,7 @@ public class DomainSettingsFragment extends Fragment { 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. + // Doing this makes no sense until it can also be done with the preferences. if (domStorageInt == 1) { // Both JavaScript and DOM storage are enabled. domStorageSwitch.setChecked(true); domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null)); @@ -410,26 +399,18 @@ public class DomainSettingsFragment extends Fragment { // 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)); - } + // Set the icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null)); } } else { // JavaScript is disabled. - // Disable the DOM storage `Switch`. + // Disable the DOM storage switch. domStorageSwitch.setEnabled(false); // Set the checked status of DOM storage. domStorageSwitch.setChecked(domStorageInt == 1); - // 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 icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted, null)); } // Set the form data visibility. Form data can be removed once the minimum API >= 26. @@ -448,82 +429,58 @@ public class DomainSettingsFragment extends Fragment { // 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 icon. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. + formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled, null)); } } // Set the EasyList status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, 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 icon. + easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null)); } // Set the EasyPrivacy status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, 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 icon. + easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, 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. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, 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)); - } + // Set the icon. + fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null)); } // Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off. @@ -532,26 +489,19 @@ public class DomainSettingsFragment extends Fragment { 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. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, 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)); - } + // Set the icon. + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null)); } } else { // Fanboy's Annoyance List is on. // Disable Fanboy's Social Blocking List switch. @@ -560,81 +510,56 @@ public class DomainSettingsFragment extends Fragment { // 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) { - 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 icon. + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted, null)); } // Set the UltraList status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, 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 icon. + ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null)); } // Set the UltraPrivacy status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, 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 icon. + ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, 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. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled, null)); } else { // Blocking all third-party requests is off. // Turn the switch off. blockAllThirdPartyRequestsSwitch.setChecked(false); - // 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 icon. + blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled, null)); } // Inflated a WebView to get the default user agent. @@ -761,55 +686,40 @@ public class DomainSettingsFragment extends Fragment { 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. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. 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. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null)); + } else { + // Set the icon. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null)); } - // 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. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null)); - // 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. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null)); - // 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(); @@ -834,100 +744,77 @@ 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. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. + 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 theme icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null)); + } else { + // Set the dark theme icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); + } + 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. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, 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)); - } + case DomainsDatabaseHelper.DARK_THEME: // the default WebView theme is dark. + // Set the icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); + 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. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null)); - // 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. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); + + // 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); @@ -939,21 +826,14 @@ public class DomainSettingsFragment extends Fragment { } // 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. + // Doing this makes no sense until it can also be done with the preferences. switch (wideViewportInt) { case DomainsDatabaseHelper.SYSTEM_DEFAULT: + // Set the icon. 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)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, 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)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); } // Show the wide viewport text view. @@ -962,23 +842,15 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, null)); // 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. + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); // Hide the wide viewport text view. wideViewportTextView.setVisibility(View.GONE); @@ -1002,22 +874,15 @@ public class DomainSettingsFragment extends Fragment { } // 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. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + // Set the icon. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, 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. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); } // Show the display images text view. @@ -1025,24 +890,16 @@ public class DomainSettingsFragment extends Fragment { 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. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, null)); // 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. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); // Hide the display images text view. displayImagesTextView.setVisibility(View.GONE); @@ -1057,25 +914,18 @@ public class DomainSettingsFragment extends Fragment { // 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. + // Doing this makes no sense until it can also be done with the preferences. // 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)); - } + // Set the icon. + pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, 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)); - } + // Set the icon. + pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); } // Store the current date. @@ -1244,25 +1094,18 @@ public class DomainSettingsFragment extends Fragment { // 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. + // Doing this makes no sense until it can also be done with the preferences. // 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)); - } + // Set the icon. + pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, 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)); - } + // Set the icon. + pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); } // Populate the saved and current IP addresses. @@ -1326,41 +1169,28 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null)); } } else { // JavaScript is disabled. // Update the JavaScript icon. javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.privacy_mode, null)); - // Disable the DOM storage `Switch`. + // 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 DOM storage icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted, null)); } }); // Set the cookies switch listener. cookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> { - if (isChecked) { // Cookies are enabled. - // Update the cookies icon. + // Update the cookies icon. + if (isChecked) { 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 { - cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null)); - } + } else { + cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled, null)); } }); @@ -1370,12 +1200,8 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null)); } }); @@ -1386,12 +1212,8 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled, null)); } }); } @@ -1399,20 +1221,10 @@ public class DomainSettingsFragment extends Fragment { // 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)); - } + if (isChecked) { + easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, null)); + } else { + easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null)); } }); @@ -1420,19 +1232,10 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, null)); + } else { + easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, null)); } }); @@ -1440,130 +1243,67 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null)); // 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)); - } + // Update the Fanboy's Social Blocking List icon. + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted, 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)); - } + // Set the icon. + fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, 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)); - } + if (fanboysSocialBlockingListSwitch.isChecked()) { + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null)); + } else { + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null)); } } - }); // 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)); - } + if (isChecked) { + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled, null)); + } else { + fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled, null)); } }); // 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)); - } + if (isChecked) { + ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled, null)); + } else { + ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled, null)); } }); // 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)); - } + if (isChecked) { + ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled, null)); + } else { + ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled, null)); } }); // 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)); - } + if (isChecked) { + blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled, null)); + } else { + blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled, null)); } }); @@ -1667,50 +1407,35 @@ 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 night mode text view. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Doing this makes no sense until it can also be done with the preferences. 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)); - } + if (defaultSwipeToRefresh) { + // Set the icon. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null)); + } else { + // Set the icon. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null)); } - // 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. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_enabled, null)); - // 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. + swipeToRefreshImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.refresh_disabled, null)); - // Hide the swipe to refresh TextView. + // Hide the swipe to refresh text view. swipeToRefreshTextView.setVisibility(View.GONE); } } @@ -1726,6 +1451,7 @@ public class DomainSettingsFragment extends Fragment { @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. + // Doing this makes no sense until it can also be done with the preferences. switch (position) { case DomainsDatabaseHelper.SYSTEM_DEFAULT: // the domain WebView theme is system default. // Set the icon according to the app WebView theme. @@ -1733,30 +1459,22 @@ public class DomainSettingsFragment extends Fragment { 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)); + // Set the light theme icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null)); } else { // Set the dark theme icon. - webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme_night, null)); + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, 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)); - } + // Set the icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, 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)); - } + // Set the icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); break; } @@ -1765,24 +1483,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. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null)); // 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. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); // Hide the WebView theme text view. webViewThemeTextView.setVisibility(View.GONE); @@ -1803,19 +1513,11 @@ public class DomainSettingsFragment extends Fragment { // Update the icon and the visibility of the wide viewport text view. switch (position) { case DomainsDatabaseHelper.SYSTEM_DEFAULT: + // Set the icon. 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)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, 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)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); } // Show the wide viewport text view. @@ -1824,23 +1526,15 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_enabled, null)); // 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. + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); // Hid ethe wide viewport text view. wideViewportTextView.setVisibility(View.GONE); @@ -1862,19 +1556,11 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, 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. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); } // Show the display images text view. @@ -1882,24 +1568,16 @@ public class DomainSettingsFragment extends Fragment { 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. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled, null)); // 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. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); // Hide the display images text view. displayImagesTextView.setVisibility(View.GONE); @@ -1917,12 +1595,8 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, null)); // Update the visibility of the saved SSL certificate. if (savedSslIssuedToCNameString == null) { @@ -1994,12 +1668,8 @@ 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)); - } + // Set the icon. + pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); // Hide the SSl certificates and instructions. savedSslCardView.setVisibility(View.GONE); @@ -2088,12 +1758,8 @@ public class DomainSettingsFragment extends Fragment { 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)); - } + // Set the icon. + pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled, null)); // Update the visibility of the saved IP addresses card view. if (savedIpAddresses == null) { // There are no saved IP addresses. @@ -2143,12 +1809,8 @@ 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)); - } + // Set the icon. + pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); // Hide the IP addresses card views. savedIpAddressesCardView.setVisibility(View.GONE);