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=bd880d44156f3f898fdd9c494c04427da6111c65;hp=614bb374e80278243f42043b5b5adb05f196af1d;hb=f0393ca22075be3e5fe9199c7db87381256236fa;hpb=6b4312dc0c2d6cb059a0fbe6d4e7cd9317db34b6 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 614bb374..bd880d44 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java @@ -28,10 +28,6 @@ import android.net.http.SslCertificate; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.annotation.NonNull; -// `android.support.v4.app.Fragment` must be used until minimum API >= 23. Otherwise `getContext()` does not work. -import android.support.v4.app.Fragment; -import android.support.v7.widget.CardView; import android.text.Editable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -52,7 +48,12 @@ import android.widget.Spinner; import android.widget.Switch; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; +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; +import com.stoutner.privacybrowser.activities.DomainsActivity; import com.stoutner.privacybrowser.activities.MainWebViewActivity; import com.stoutner.privacybrowser.helpers.DomainsDatabaseHelper; @@ -98,6 +99,7 @@ public class DomainSettingsFragment extends Fragment { boolean defaultSwipeToRefresh = sharedPreferences.getBoolean("swipe_to_refresh", true); final boolean defaultNightMode = sharedPreferences.getBoolean("night_mode", false); final boolean defaultDisplayWebpageImages = sharedPreferences.getBoolean("display_webpage_images", true); + boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); // Get handles for the views in the fragment. final EditText domainNameEditText = domainSettingsView.findViewById(R.id.domain_settings_name_edittext); @@ -182,7 +184,7 @@ public class DomainSettingsFragment extends Fragment { String endDateLabel = getString(R.string.end_date) + " "; // Get the current website SSL certificate - final SslCertificate currentWebsiteSslCertificate = MainWebViewActivity.sslCertificate; + final SslCertificate currentWebsiteSslCertificate = DomainsActivity.currentSslCertificate; // Initialize the database handler. The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`. DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(context, null, null, 0); @@ -286,7 +288,7 @@ public class DomainSettingsFragment extends Fragment { final ForegroundColorSpan blueColorSpan; // Set the blue color span according to the theme. The deprecated `resources.getColor` must be used until the minimum API >= 23. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { //noinspection deprecation blueColorSpan = new ForegroundColorSpan(resources.getColor(R.color.blue_400)); } else { @@ -386,7 +388,7 @@ public class DomainSettingsFragment extends Fragment { firstPartyCookiesEnabledSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark)); } else { firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light)); @@ -405,7 +407,7 @@ public class DomainSettingsFragment extends Fragment { thirdPartyCookiesEnabledSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark)); } else { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light)); @@ -423,7 +425,7 @@ public class DomainSettingsFragment extends Fragment { thirdPartyCookiesEnabledSwitch.setEnabled(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_dark)); } else { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_light)); @@ -448,7 +450,7 @@ public class DomainSettingsFragment extends Fragment { domStorageEnabledSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_light)); @@ -466,7 +468,7 @@ public class DomainSettingsFragment extends Fragment { } // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_light)); @@ -486,7 +488,7 @@ public class DomainSettingsFragment extends Fragment { formDataEnabledSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_dark)); } else { formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_light)); @@ -500,7 +502,7 @@ public class DomainSettingsFragment extends Fragment { easyListSwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_dark)); } else { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_light)); @@ -510,7 +512,7 @@ public class DomainSettingsFragment extends Fragment { easyListSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_dark)); } else { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_light)); @@ -523,7 +525,7 @@ public class DomainSettingsFragment extends Fragment { easyPrivacySwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_dark)); } else { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_light)); @@ -533,7 +535,7 @@ public class DomainSettingsFragment extends Fragment { easyPrivacySwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_dark)); } else { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_light)); @@ -546,7 +548,7 @@ public class DomainSettingsFragment extends Fragment { fanboysAnnoyanceListSwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_dark)); } else { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_light)); @@ -556,7 +558,7 @@ public class DomainSettingsFragment extends Fragment { fanboysAnnoyanceListSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark)); } else { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light)); @@ -572,7 +574,7 @@ public class DomainSettingsFragment extends Fragment { fanboysSocialBlockingListSwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_light)); @@ -583,7 +585,7 @@ public class DomainSettingsFragment extends Fragment { fanboysSocialBlockingListSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light)); @@ -602,7 +604,7 @@ public class DomainSettingsFragment extends Fragment { } // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_light)); @@ -615,7 +617,7 @@ public class DomainSettingsFragment extends Fragment { ultraPrivacySwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_dark)); } else { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_light)); @@ -625,7 +627,7 @@ public class DomainSettingsFragment extends Fragment { ultraPrivacySwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_dark)); } else { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_light)); @@ -638,7 +640,7 @@ public class DomainSettingsFragment extends Fragment { blockAllThirdPartyRequestsSwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_dark)); } else { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_light)); @@ -648,7 +650,7 @@ public class DomainSettingsFragment extends Fragment { blockAllThirdPartyRequestsSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_dark)); } else { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_light)); @@ -769,14 +771,14 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.SWIPE_TO_REFRESH_SYSTEM_DEFAULT: if (defaultSwipeToRefresh) { // Swipe to refresh is enabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_light)); } } else { // Swipe to refresh is disabled by default // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_light)); @@ -789,7 +791,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.SWIPE_TO_REFRESH_ENABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_light)); @@ -801,7 +803,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.SWIPE_TO_REFRESH_DISABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_light)); @@ -832,14 +834,14 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.NIGHT_MODE_SYSTEM_DEFAULT: if (defaultNightMode) { // Night mode enabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_light)); } } else { // Night mode disabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_light)); @@ -852,7 +854,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.NIGHT_MODE_ENABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_light)); @@ -864,7 +866,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.NIGHT_MODE_DISABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_light)); @@ -896,14 +898,14 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_SYSTEM_DEFAULT: if (defaultDisplayWebpageImages) { // Display webpage images enabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_light)); } } else { // Display webpage images disabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_light)); @@ -916,7 +918,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_ENABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_light)); @@ -928,7 +930,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_DISABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_light)); @@ -951,7 +953,7 @@ public class DomainSettingsFragment extends Fragment { pinnedSslCertificateSwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_dark)); } else { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_light)); @@ -961,7 +963,7 @@ public class DomainSettingsFragment extends Fragment { pinnedSslCertificateSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_dark)); } else { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_light)); @@ -1111,7 +1113,7 @@ public class DomainSettingsFragment extends Fragment { currentWebsiteCertificateRadioButton.setChecked(false); // Darken the background of the current website SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1144,7 +1146,7 @@ public class DomainSettingsFragment extends Fragment { pinnedIpAddressesSwitch.setChecked(true); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_dark)); } else { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_light)); @@ -1154,7 +1156,7 @@ public class DomainSettingsFragment extends Fragment { pinnedIpAddressesSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_dark)); } else { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_light)); @@ -1163,7 +1165,7 @@ public class DomainSettingsFragment extends Fragment { // Populate the saved and current IP addresses. savedIpAddressesTextView.setText(savedIpAddresses); - currentIpAddressesTextView.setText(MainWebViewActivity.currentHostIpAddresses); + currentIpAddressesTextView.setText(DomainsActivity.currentIpAddresses); // Set the initial display status of the IP addresses card views. if (pinnedIpAddressesSwitch.isChecked()) { // IP addresses are pinned. @@ -1186,7 +1188,7 @@ public class DomainSettingsFragment extends Fragment { currentIpAddressesRadioButton.setChecked(false); // Darken the background of the current IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1223,7 +1225,7 @@ public class DomainSettingsFragment extends Fragment { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_enabled)); } else { // DOM storage is disabled. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_light)); @@ -1237,7 +1239,7 @@ public class DomainSettingsFragment extends Fragment { domStorageEnabledSwitch.setEnabled(false); // Set the DOM storage icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_light)); @@ -1259,7 +1261,7 @@ public class DomainSettingsFragment extends Fragment { 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 (MainWebViewActivity.darkTheme) { + if (darkTheme) { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark)); } else { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light)); @@ -1267,7 +1269,7 @@ public class DomainSettingsFragment extends Fragment { } } else { // First-party cookies are disabled. // Update the first-party cookies icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark)); } else { firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light)); @@ -1277,7 +1279,7 @@ public class DomainSettingsFragment extends Fragment { thirdPartyCookiesEnabledSwitch.setEnabled(false); // Set the third-party cookies icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_dark)); } else { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_light)); @@ -1292,7 +1294,7 @@ public class DomainSettingsFragment extends Fragment { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning)); } else { // Update the third-party cookies icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark)); } else { thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light)); @@ -1307,7 +1309,7 @@ public class DomainSettingsFragment extends Fragment { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_enabled)); } else { // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_light)); @@ -1323,7 +1325,7 @@ public class DomainSettingsFragment extends Fragment { formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_enabled)); } else { // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_dark)); } else { formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_light)); @@ -1337,14 +1339,14 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // EasyList is on. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_dark)); } else { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_enabled_light)); } } else { // EasyList is off. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_dark)); } else { easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_light)); @@ -1357,14 +1359,14 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // EasyPrivacy is on. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_dark)); } else { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_light)); } } else { // EasyPrivacy is off. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_dark)); } else { easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_light)); @@ -1377,7 +1379,7 @@ public class DomainSettingsFragment extends Fragment { // 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 (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_dark)); } else { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_light)); @@ -1387,14 +1389,14 @@ public class DomainSettingsFragment extends Fragment { fanboysSocialBlockingListSwitch.setEnabled(false); // Update the Fanboy's Social Blocking List icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_light)); } } else { // Fanboy's Annoyance List is off. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark)); } else { fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light)); @@ -1406,14 +1408,14 @@ public class DomainSettingsFragment extends Fragment { // 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 (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_light)); } } else { // Fanboy's Social Blocking List is off. // Update the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light)); @@ -1428,14 +1430,14 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // Fanboy's Social Blocking List is on. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_light)); } } else { // Fanboy's Social Blocking List is off. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark)); } else { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light)); @@ -1448,14 +1450,14 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // UltraPrivacy is on. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_dark)); } else { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_light)); } } else { // UltraPrivacy is off. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_dark)); } else { ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_light)); @@ -1468,14 +1470,14 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // Blocking all third-party requests is on. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_dark)); } else { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_enabled_light)); } } else { // Blocking all third-party requests is off. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_dark)); } else { blockAllThirdPartyRequestsImageView.setImageDrawable(resources.getDrawable(R.drawable.block_all_third_party_requests_disabled_light)); @@ -1580,14 +1582,14 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.SWIPE_TO_REFRESH_SYSTEM_DEFAULT: if (defaultSwipeToRefresh) { // Swipe to refresh enabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_light)); } } else { // Swipe to refresh disabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_light)); @@ -1600,7 +1602,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.SWIPE_TO_REFRESH_ENABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_enabled_light)); @@ -1612,7 +1614,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.SWIPE_TO_REFRESH_DISABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_dark)); } else { swipeToRefreshImageView.setImageDrawable(resources.getDrawable(R.drawable.refresh_disabled_light)); @@ -1638,14 +1640,14 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.NIGHT_MODE_SYSTEM_DEFAULT: if (defaultNightMode) { // Night mode enabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_light)); } } else { // Night mode disabled by default. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_light)); @@ -1658,7 +1660,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.NIGHT_MODE_ENABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_light)); @@ -1670,7 +1672,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.NIGHT_MODE_DISABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_dark)); } else { nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_light)); @@ -1712,7 +1714,7 @@ public class DomainSettingsFragment extends Fragment { domStorageEnabledSwitch.setChecked(false); // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_light)); @@ -1730,7 +1732,7 @@ public class DomainSettingsFragment extends Fragment { } // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_dark)); } else { domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_light)); @@ -1753,14 +1755,14 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_SYSTEM_DEFAULT: if (defaultDisplayWebpageImages) { // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_light)); } } else { // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_light)); @@ -1773,7 +1775,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_ENABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_light)); @@ -1785,7 +1787,7 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISPLAY_WEBPAGE_IMAGES_DISABLED: // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_dark)); } else { displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_light)); @@ -1808,7 +1810,7 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // SSL certificate pinning is enabled. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_dark)); } else { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_light)); @@ -1848,7 +1850,7 @@ public class DomainSettingsFragment extends Fragment { savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the current website SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1867,7 +1869,7 @@ public class DomainSettingsFragment extends Fragment { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the saved SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1885,7 +1887,7 @@ public class DomainSettingsFragment extends Fragment { } } else { // SSL certificate pinning is disabled. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_dark)); } else { pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_light)); @@ -1913,7 +1915,7 @@ public class DomainSettingsFragment extends Fragment { savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the current website SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1931,7 +1933,7 @@ public class DomainSettingsFragment extends Fragment { savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the current website SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1949,7 +1951,7 @@ public class DomainSettingsFragment extends Fragment { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the saved SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1967,7 +1969,7 @@ public class DomainSettingsFragment extends Fragment { currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the saved SSL certificate linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -1979,7 +1981,7 @@ public class DomainSettingsFragment extends Fragment { // Update the icon. if (isChecked) { // IP addresses pinning is enabled. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_dark)); } else { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_light)); @@ -2007,7 +2009,7 @@ public class DomainSettingsFragment extends Fragment { savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the current IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -2023,7 +2025,7 @@ public class DomainSettingsFragment extends Fragment { currentIpAddressesLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the saved IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -2034,7 +2036,7 @@ public class DomainSettingsFragment extends Fragment { currentIpAddressesCardView.getParent().requestChildFocus(currentIpAddressesCardView, currentIpAddressesCardView); } else { // IP addresses pinning is disabled. // Set the icon according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_dark)); } else { pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_light)); @@ -2061,7 +2063,7 @@ public class DomainSettingsFragment extends Fragment { savedIpAddressesLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the current IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -2079,7 +2081,7 @@ public class DomainSettingsFragment extends Fragment { savedIpAddressesLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the current IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -2097,7 +2099,7 @@ public class DomainSettingsFragment extends Fragment { currentIpAddressesLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the saved IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -2115,7 +2117,7 @@ public class DomainSettingsFragment extends Fragment { currentIpAddressesLinearLayout.setBackgroundResource(R.color.transparent); // Darken the background of the saved IP addresses linear layout according to the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33); } else { savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11); @@ -2201,4 +2203,4 @@ public class DomainSettingsFragment extends Fragment { return domainNamesMatch; } -} +} \ No newline at end of file