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=1588ad3c2d5bedc6a31365486bcd68f411816e35;hb=1b27ac6f2b7c046945fc97e2aff9adbde8a152ce;hpb=0488649384ddea89d768c1fc1cc5fb71f8af6528 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 1588ad3c..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-2020 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; @@ -44,12 +44,14 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RadioButton; +import android.widget.ScrollView; import android.widget.Spinner; -import android.widget.Switch; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.widget.SwitchCompat; import androidx.cardview.widget.CardView; +import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.Fragment; // The AndroidX fragment must be used until minimum API >= 23. Otherwise `getContext()` does not work. import com.stoutner.privacybrowser.R; @@ -62,12 +64,16 @@ import java.util.Calendar; import java.util.Date; public class DomainSettingsFragment extends Fragment { - // `DATABASE_ID` is used by activities calling this fragment. + // Initialize the public class constants. These are used by activities calling this fragment. public static final String DATABASE_ID = "database_id"; + public static final String SCROLL_Y = "scroll_y"; - // `databaseId` is public static so it can be accessed from `DomainsActivity`. It is also used in `onCreate()` and `onCreateView()`. + // Define the public variables. `databaseId` is public static so it can be accessed from `DomainsActivity`. It is also used in `onCreate()` and `onCreateView()`. public static int databaseId; + // Define the class variables. + private int scrollY; + @Override public void onCreate(Bundle savedInstanceState) { // Run the default commands. @@ -78,6 +84,7 @@ public class DomainSettingsFragment extends Fragment { // Store the database id in `databaseId`. databaseId = getArguments().getInt(DATABASE_ID); + scrollY = getArguments().getInt(SCROLL_Y); } // The deprecated `getDrawable()` must be used until the minimum API >= 21. @@ -86,7 +93,7 @@ public class DomainSettingsFragment extends Fragment { // Inflate `domain_settings_fragment`. `false` does not attach it to the root `container`. View domainSettingsView = inflater.inflate(R.layout.domain_settings_fragment, container, false); - // Get a handle for the context and the resources. + // Get handles for the context and the resources. Context context = getContext(); Resources resources = getResources(); @@ -108,33 +115,31 @@ public class DomainSettingsFragment extends Fragment { boolean defaultWideViewport = sharedPreferences.getBoolean("wide_viewport", true); boolean defaultDisplayWebpageImages = sharedPreferences.getBoolean("display_webpage_images", true); - // Get handles for the views in the fragment. + // Get handles for the views. + ScrollView domainSettingsScrollView = domainSettingsView.findViewById(R.id.domain_settings_scrollview); EditText domainNameEditText = domainSettingsView.findViewById(R.id.domain_settings_name_edittext); ImageView javaScriptImageView = domainSettingsView.findViewById(R.id.javascript_imageview); - Switch javaScriptSwitch = domainSettingsView.findViewById(R.id.javascript_switch); - ImageView firstPartyCookiesImageView = domainSettingsView.findViewById(R.id.first_party_cookies_imageview); - Switch 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); - Switch thirdPartyCookiesSwitch = domainSettingsView.findViewById(R.id.third_party_cookies_switch); + SwitchCompat javaScriptSwitch = domainSettingsView.findViewById(R.id.javascript_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); - Switch domStorageSwitch = domainSettingsView.findViewById(R.id.dom_storage_switch); + 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. - Switch formDataSwitch = domainSettingsView.findViewById(R.id.form_data_switch); // The form data views can be remove once the minimum API >= 26. + SwitchCompat formDataSwitch = domainSettingsView.findViewById(R.id.form_data_switch); // The form data views can be remove once the minimum API >= 26. ImageView easyListImageView = domainSettingsView.findViewById(R.id.easylist_imageview); - Switch easyListSwitch = domainSettingsView.findViewById(R.id.easylist_switch); + SwitchCompat easyListSwitch = domainSettingsView.findViewById(R.id.easylist_switch); ImageView easyPrivacyImageView = domainSettingsView.findViewById(R.id.easyprivacy_imageview); - Switch easyPrivacySwitch = domainSettingsView.findViewById(R.id.easyprivacy_switch); + SwitchCompat easyPrivacySwitch = domainSettingsView.findViewById(R.id.easyprivacy_switch); ImageView fanboysAnnoyanceListImageView = domainSettingsView.findViewById(R.id.fanboys_annoyance_list_imageview); - Switch fanboysAnnoyanceListSwitch = domainSettingsView.findViewById(R.id.fanboys_annoyance_list_switch); + SwitchCompat fanboysAnnoyanceListSwitch = domainSettingsView.findViewById(R.id.fanboys_annoyance_list_switch); ImageView fanboysSocialBlockingListImageView = domainSettingsView.findViewById(R.id.fanboys_social_blocking_list_imageview); - Switch fanboysSocialBlockingListSwitch = domainSettingsView.findViewById(R.id.fanboys_social_blocking_list_switch); + SwitchCompat fanboysSocialBlockingListSwitch = domainSettingsView.findViewById(R.id.fanboys_social_blocking_list_switch); ImageView ultraListImageView = domainSettingsView.findViewById(R.id.ultralist_imageview); - Switch ultraListSwitch = domainSettingsView.findViewById(R.id.ultralist_switch); + SwitchCompat ultraListSwitch = domainSettingsView.findViewById(R.id.ultralist_switch); ImageView ultraPrivacyImageView = domainSettingsView.findViewById(R.id.ultraprivacy_imageview); - Switch ultraPrivacySwitch = domainSettingsView.findViewById(R.id.ultraprivacy_switch); + SwitchCompat ultraPrivacySwitch = domainSettingsView.findViewById(R.id.ultraprivacy_switch); ImageView blockAllThirdPartyRequestsImageView = domainSettingsView.findViewById(R.id.block_all_third_party_requests_imageview); - Switch blockAllThirdPartyRequestsSwitch = domainSettingsView.findViewById(R.id.block_all_third_party_requests_switch); + SwitchCompat blockAllThirdPartyRequestsSwitch = domainSettingsView.findViewById(R.id.block_all_third_party_requests_switch); Spinner userAgentSpinner = domainSettingsView.findViewById(R.id.user_agent_spinner); TextView userAgentTextView = domainSettingsView.findViewById(R.id.user_agent_textview); EditText customUserAgentEditText = domainSettingsView.findViewById(R.id.custom_user_agent_edittext); @@ -154,7 +159,7 @@ public class DomainSettingsFragment extends Fragment { Spinner displayWebpageImagesSpinner = domainSettingsView.findViewById(R.id.display_webpage_images_spinner); TextView displayImagesTextView = domainSettingsView.findViewById(R.id.display_webpage_images_textview); ImageView pinnedSslCertificateImageView = domainSettingsView.findViewById(R.id.pinned_ssl_certificate_imageview); - Switch pinnedSslCertificateSwitch = domainSettingsView.findViewById(R.id.pinned_ssl_certificate_switch); + SwitchCompat pinnedSslCertificateSwitch = domainSettingsView.findViewById(R.id.pinned_ssl_certificate_switch); CardView savedSslCardView = domainSettingsView.findViewById(R.id.saved_ssl_certificate_cardview); LinearLayout savedSslCertificateLinearLayout = domainSettingsView.findViewById(R.id.saved_ssl_certificate_linearlayout); RadioButton savedSslCertificateRadioButton = domainSettingsView.findViewById(R.id.saved_ssl_certificate_radiobutton); @@ -179,7 +184,7 @@ public class DomainSettingsFragment extends Fragment { TextView currentSslEndDateTextView = domainSettingsView.findViewById(R.id.current_website_certificate_end_date); TextView noCurrentWebsiteCertificateTextView = domainSettingsView.findViewById(R.id.no_current_website_certificate); ImageView pinnedIpAddressesImageView = domainSettingsView.findViewById(R.id.pinned_ip_addresses_imageview); - Switch pinnedIpAddressesSwitch = domainSettingsView.findViewById(R.id.pinned_ip_addresses_switch); + SwitchCompat pinnedIpAddressesSwitch = domainSettingsView.findViewById(R.id.pinned_ip_addresses_switch); CardView savedIpAddressesCardView = domainSettingsView.findViewById(R.id.saved_ip_addresses_cardview); LinearLayout savedIpAddressesLinearLayout = domainSettingsView.findViewById(R.id.saved_ip_addresses_linearlayout); RadioButton savedIpAddressesRadioButton = domainSettingsView.findViewById(R.id.saved_ip_addresses_radiobutton); @@ -204,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. @@ -295,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 redColorSpan; - final ForegroundColorSpan blueColorSpan; - - // Set the color spans according to the theme. The deprecated `resources` must be used until the minimum API >= 23. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_900)); - blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.violet_500)); - } else { - redColorSpan = new ForegroundColorSpan(resources.getColor(R.color.red_a700)); - blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_700)); - } + // Create the color spans. + final ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(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); @@ -368,109 +363,54 @@ public class DomainSettingsFragment extends Fragment { // Set the JavaScript switch status. if (javaScriptInt == 1) { // JavaScript is enabled. javaScriptSwitch.setChecked(true); - javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.javascript_enabled)); + javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.javascript_enabled, null)); } else { // JavaScript is disabled. javaScriptSwitch.setChecked(false); - javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.privacy_mode)); + 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(resources.getDrawable(R.drawable.cookies_enabled)); - } else { // First-party cookies are disabled. - firstPartyCookiesSwitch.setChecked(false); - - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_night)); - } else { - firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_day)); - } - } - - // 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(resources.getDrawable(R.drawable.cookies_warning)); - } 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(resources.getDrawable(R.drawable.cookies_disabled_night)); - } else { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_day)); - } - } - } else { // First-party cookies are disabled. - // Set the status of third-party cookies. - if (thirdPartyCookiesInt == 1) { - thirdPartyCookiesSwitch.setChecked(true); - } else { - thirdPartyCookiesSwitch.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. + // 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); - // Disable the third-party cookies switch. - thirdPartyCookiesSwitch.setEnabled(false); + // 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) { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_night)); - } else { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_day)); - } - } - } else { // Third-party cookies cannot be configured for API <= 21. - // Hide the LinearLayout for third-party cookies. - thirdPartyCookiesLinearLayout.setVisibility(View.GONE); + // Set the icon. + cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled, null)); } // 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. + // 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(resources.getDrawable(R.drawable.dom_storage_enabled)); + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null)); } else { // JavaScript is enabled but DOM storage is disabled. // Set the DOM storage switch to off. domStorageSwitch.setChecked(false); - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_night)); - } else { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_day)); - } + // 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. - 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) { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_night)); - } else { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_day)); - } + // 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. @@ -484,87 +424,63 @@ public class DomainSettingsFragment extends Fragment { formDataSwitch.setChecked(true); // Set the form data icon. - formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_enabled)); + formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_enabled, null)); } else { // Form data is off. // Turn the form data switch to off. formDataSwitch.setChecked(false); - // Set the icon according to the theme. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_night)); - } else { - formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_ads_enabled_night)); - } else { - easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_ads_disabled_night)); - } else { - easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_tracking_enabled_night)); - } else { - easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_tracking_disabled_night)); - } else { - easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.social_media_enabled_night)); - } else { - fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.social_media_disabled_night)); - } else { - fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_day)); - } + // 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. @@ -573,115 +489,77 @@ 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(resources.getDrawable(R.drawable.social_media_enabled_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.social_media_disabled_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_day)); - } + // 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. 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) { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_day)); - } + // 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(resources.getDrawable(R.drawable.block_ads_enabled_night)); - } else { - ultraListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_ads_disabled_night)); - } else { - ultraListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_tracking_enabled_night)); - } else { - ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_tracking_disabled_night)); - } else { - ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_night)); - } else { - blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_night)); - } else { - blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_day)); - } + // 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. @@ -808,54 +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(resources.getDrawable(R.drawable.refresh_enabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_day)); - } - } else { // Swipe to refresh is disabled by default - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.refresh_enabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.refresh_disabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_day)); - } + // 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(); @@ -880,101 +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(resources.getDrawable(R.drawable.webview_light_theme_day)); - } else { - // Set the dark theme icon. - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night)); - } - 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(resources.getDrawable(R.drawable.webview_light_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night)); - } - 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(resources.getDrawable(R.drawable.webview_dark_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night)); - } - 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(resources.getDrawable(R.drawable.webview_light_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night)); - } + 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(resources.getDrawable(R.drawable.webview_dark_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night)); - } + 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); @@ -986,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(resources.getDrawable(R.drawable.wide_viewport_enabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_day)); - } + 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(resources.getDrawable(R.drawable.wide_viewport_disabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_day)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); } // Show the wide viewport text view. @@ -1009,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(resources.getDrawable(R.drawable.wide_viewport_enabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_day)); - } + 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(resources.getDrawable(R.drawable.wide_viewport_disabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_day)); - } + // Set the icon. + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); // Hide the wide viewport text view. wideViewportTextView.setVisibility(View.GONE); @@ -1049,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(resources.getDrawable(R.drawable.images_enabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.images_disabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_day)); - } + // Set the icon. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); } // Show the display images text view. @@ -1072,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(resources.getDrawable(R.drawable.images_enabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.images_disabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_day)); - } + // Set the icon. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); // Hide the display images text view. displayImagesTextView.setVisibility(View.GONE); @@ -1104,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(resources.getDrawable(R.drawable.ssl_certificate_enabled_night)); - } else { - pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.ssl_certificate_disabled_night)); - } else { - pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_day)); - } + // Set the icon. + pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); } // Store the current date. @@ -1291,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(resources.getDrawable(R.drawable.ssl_certificate_enabled_night)); - } else { - pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.ssl_certificate_disabled_night)); - } else { - pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_day)); - } + // Set the icon. + pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); } // Populate the saved and current IP addresses. @@ -1364,92 +1160,37 @@ public class DomainSettingsFragment extends Fragment { javaScriptSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> { if (isChecked) { // JavaScript is enabled. // Update the JavaScript icon. - javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.javascript_enabled)); + javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.javascript_enabled, null)); // Enable the DOM storage `Switch`. domStorageSwitch.setEnabled(true); // Update the DOM storage icon. if (domStorageSwitch.isChecked()) { // DOM storage is enabled. - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_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(resources.getDrawable(R.drawable.dom_storage_disabled_night)); - } else { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_day)); - } + // Set the icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null)); } } else { // JavaScript is disabled. // Update the JavaScript icon. - javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.privacy_mode)); + 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(resources.getDrawable(R.drawable.dom_storage_ghosted_night)); - } else { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_day)); - } - } - }); - - // 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(resources.getDrawable(R.drawable.cookies_enabled)); - - // 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(resources.getDrawable(R.drawable.cookies_warning)); - } 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(resources.getDrawable(R.drawable.cookies_disabled_night)); - } else { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_day)); - } - } - } 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(resources.getDrawable(R.drawable.cookies_disabled_night)); - } else { - firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_day)); - } - - // 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(resources.getDrawable(R.drawable.cookies_ghosted_night)); - } else { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_day)); - } + // Set the DOM storage icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted, null)); } }); - // Set the third-party cookies switch listener. - thirdPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> { - // Update the icon. + // Set the cookies switch listener. + cookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> { + // Update the cookies icon. if (isChecked) { - // Set the third-party cookies icon to be red. - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning)); + cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null)); } else { - // Update the third-party cookies icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_night)); - } else { - thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_day)); - } + cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled, null)); } }); @@ -1457,14 +1198,10 @@ public class DomainSettingsFragment extends Fragment { domStorageSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> { // Update the icon. if (isChecked) { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_enabled)); + 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(resources.getDrawable(R.drawable.dom_storage_disabled_night)); - } else { - domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_day)); - } + // Set the icon. + domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled, null)); } }); @@ -1473,14 +1210,10 @@ public class DomainSettingsFragment extends Fragment { formDataSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> { // Update the icon. if (isChecked) { - formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_enabled)); + 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(resources.getDrawable(R.drawable.form_data_disabled_night)); - } else { - formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_day)); - } + // Set the icon. + formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled, null)); } }); } @@ -1488,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(resources.getDrawable(R.drawable.block_ads_enabled_night)); - } else { - easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_day)); - } - } else { // EasyList is off. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_night)); - } else { - easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_day)); - } + 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)); } }); @@ -1509,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(resources.getDrawable(R.drawable.block_tracking_enabled_night)); - } else { - easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_day)); - } - } else { // EasyPrivacy is off. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_night)); - } else { - easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_day)); - } + // 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)); } }); @@ -1529,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(resources.getDrawable(R.drawable.social_media_enabled_night)); - } else { - fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.social_media_ghosted_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_day)); - } + // 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(resources.getDrawable(R.drawable.social_media_disabled_night)); - } else { - fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_day)); - } + // 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(resources.getDrawable(R.drawable.social_media_enabled_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day)); - } - } else { // Fanboy's Social Blocking List is off. - // Update the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_day)); - } + 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(resources.getDrawable(R.drawable.social_media_enabled_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day)); - } - } else { // Fanboy's Social Blocking List is off. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_night)); - } else { - fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_day)); - } + 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(resources.getDrawable(R.drawable.block_ads_enabled_night)); - } else { - ultraListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_day)); - } - } else { // UltraList is off. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - ultraListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_night)); - } else { - ultraListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_day)); - } + 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(resources.getDrawable(R.drawable.block_tracking_enabled_night)); - } else { - ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_day)); - } - } else { // UltraPrivacy is off. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_night)); - } else { - ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_day)); - } + 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(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_night)); - } else { - blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_day)); - } - } else { // Blocking all third-party requests is off. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_night)); - } else { - blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_day)); - } + 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)); } }); @@ -1756,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(resources.getDrawable(R.drawable.refresh_enabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_day)); - } - } else { // Swipe to refresh disabled by default. - // Set the icon according to the theme. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_day)); - } + 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(resources.getDrawable(R.drawable.refresh_enabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.refresh_disabled_night)); - } else { - swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_day)); - } + // 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); } } @@ -1815,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. @@ -1822,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(resources.getDrawable(R.drawable.webview_light_theme_day)); + // Set the light theme icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_light_theme, null)); } else { // Set the dark theme icon. - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night)); + 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(resources.getDrawable(R.drawable.webview_light_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night)); - } + // 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(resources.getDrawable(R.drawable.webview_dark_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night)); - } + // Set the icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); break; } @@ -1854,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(resources.getDrawable(R.drawable.webview_light_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night)); - } + // 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(resources.getDrawable(R.drawable.webview_dark_theme_day)); - } else { - webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night)); - } + // Set the icon. + webViewThemeImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.webview_dark_theme, null)); // Hide the WebView theme text view. webViewThemeTextView.setVisibility(View.GONE); @@ -1892,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(resources.getDrawable(R.drawable.wide_viewport_enabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_day)); - } + 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(resources.getDrawable(R.drawable.wide_viewport_disabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_day)); - } + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); } // Show the wide viewport text view. @@ -1913,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(resources.getDrawable(R.drawable.wide_viewport_enabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_day)); - } + 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(resources.getDrawable(R.drawable.wide_viewport_disabled_night)); - } else { - wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_day)); - } + // Set the icon. + wideViewportImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.wide_viewport_disabled, null)); // Hid ethe wide viewport text view. wideViewportTextView.setVisibility(View.GONE); @@ -1951,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(resources.getDrawable(R.drawable.images_enabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.images_disabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_day)); - } + // Set the icon. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); } // Show the display images text view. @@ -1971,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(resources.getDrawable(R.drawable.images_enabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_day)); - } + // 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(resources.getDrawable(R.drawable.images_disabled_night)); - } else { - displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_day)); - } + // Set the icon. + displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled, null)); // Hide the display images text view. displayImagesTextView.setVisibility(View.GONE); @@ -2006,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(resources.getDrawable(R.drawable.ssl_certificate_enabled_night)); - } else { - pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_day)); - } + // 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) { @@ -2083,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(resources.getDrawable(R.drawable.ssl_certificate_disabled_night)); - } else { - pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_day)); - } + // Set the icon. + pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); // Hide the SSl certificates and instructions. savedSslCardView.setVisibility(View.GONE); @@ -2177,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(resources.getDrawable(R.drawable.ssl_certificate_enabled_night)); - } else { - pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_day)); - } + // 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. @@ -2232,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(resources.getDrawable(R.drawable.ssl_certificate_disabled_night)); - } else { - pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_day)); - } + // Set the icon. + pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled, null)); // Hide the IP addresses card views. savedIpAddressesCardView.setVisibility(View.GONE); @@ -2321,6 +1894,10 @@ public class DomainSettingsFragment extends Fragment { } }); + // Set the scroll Y. + domainSettingsScrollView.post(() -> domainSettingsScrollView.setScrollY(scrollY)); + + // Return the domain settings view. return domainSettingsView; }