- // 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 (firstPartyCookiesEnabledInt == 1) { // First-party cookies are enabled.
- firstPartyCookiesEnabledSwitch.setChecked(true);
- firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_enabled));
- } else { // First-party cookies are disabled.
- firstPartyCookiesEnabledSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark));
- } else {
- firstPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light));
- }
- }
-
- // 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 (firstPartyCookiesEnabledInt == 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 (thirdPartyCookiesEnabledInt == 1) { // Both first-party and third-party cookies are enabled.
- thirdPartyCookiesEnabledSwitch.setChecked(true);
- thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning));
- } else { // First party cookies are enabled but third-party cookies are disabled.
- thirdPartyCookiesEnabledSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_dark));
- } else {
- thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_disabled_light));
- }
- }
- } else { // First-party cookies are disabled.
- // Set the status of third-party cookies.
- if (thirdPartyCookiesEnabledInt == 1) {
- thirdPartyCookiesEnabledSwitch.setChecked(true);
- } else {
- thirdPartyCookiesEnabledSwitch.setChecked(false);
- }
-
- // Disable the third-party cookies switch.
- thirdPartyCookiesEnabledSwitch.setEnabled(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_dark));
- } else {
- thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_ghosted_light));
- }
- }
- } else { // Third-party cookies cannot be configured for API <= 21.
- // Hide the LinearLayout for third-party cookies.
- thirdPartyCookiesLinearLayout.setVisibility(View.GONE);
- }
-
- // Only enable DOM storage if JavaScript is enabled.
- if ((javaScriptEnabledInt == 1) || nightModeEnabled) { // JavaScript is enabled.
- // Enable the DOM storage `Switch`.
- domStorageEnabledSwitch.setEnabled(true);
-
- // Set the DOM storage status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (domStorageEnabledInt == 1) { // Both JavaScript and DOM storage are enabled.
- domStorageEnabledSwitch.setChecked(true);
- domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_enabled));
- } else { // JavaScript is enabled but DOM storage is disabled.
- // Set the DOM storage switch to off.
- domStorageEnabledSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_dark));
- } else {
- domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_light));
- }
- }
- } else { // JavaScript is disabled.
- // Disable the DOM storage `Switch`.
- domStorageEnabledSwitch.setEnabled(false);
-
- // Set the checked status of DOM storage.
- if (domStorageEnabledInt == 1) { // DOM storage is enabled but JavaScript is disabled.
- domStorageEnabledSwitch.setChecked(true);
- } else { // Both JavaScript and DOM storage are disabled.
- domStorageEnabledSwitch.setChecked(false);
- }
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_dark));
- } else {
- domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_light));
- }
- }
-
- // Set the form data status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. Form data can be removed once the minimum API >= 26.
- if (Build.VERSION.SDK_INT >= 26) { // Form data no longer applies to newer versions of Android.
- // Hide the form data switch.
- formDataEnabledSwitch.setVisibility(View.GONE);
- } else { // Form data should be displayed because this is an older version of Android.
- if (formDataEnabledInt == 1) { // Form data is on.
- formDataEnabledSwitch.setChecked(true);
- formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_enabled));
- } else { // Form data is off.
- // Turn the form data switch to off.
- formDataEnabledSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_dark));
- } else {
- formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_light));
- }
- }
- }
-
- // Set the EasyList status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (easyListEnabledInt == 1) { // EasyList is on.
- // Turn the switch on.
- easyListSwitch.setChecked(true);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.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.
- // Turn the switch off.
- easyListSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_dark));
- } else {
- easyListImageView.setImageDrawable(resources.getDrawable(R.drawable.block_ads_disabled_light));
- }
- }
-
- // Set the EasyPrivacy status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (easyPrivacyEnabledInt == 1) { // EasyPrivacy is on.
- // Turn the switch on.
- easyPrivacySwitch.setChecked(true);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.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.
- // Turn the switch off.
- easyPrivacySwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_dark));
- } else {
- easyPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_light));
- }
- }
-
- // Set the Fanboy's Annoyance List status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (fanboysAnnoyanceListInt == 1) { // Fanboy's Annoyance List is on.
- // Turn the switch on.
- fanboysAnnoyanceListSwitch.setChecked(true);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_dark));
- } else {
- fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_light));
- }
- } else { // Fanboy's Annoyance List is off.
- // Turn the switch off.
- fanboysAnnoyanceListSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark));
- } else {
- fanboysAnnoyanceListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light));
- }
- }
-
- // Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off.
- if (fanboysAnnoyanceListInt == 0) { // Fanboy's Annoyance List is on.
- // Enable Fanboy's Social Blocking List. 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.
- // Enable the switch and turn it on.
- fanboysSocialBlockingListSwitch.setEnabled(true);
- fanboysSocialBlockingListSwitch.setChecked(true);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.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.
- // Enable the switch but turn it off.
- fanboysSocialBlockingListSwitch.setEnabled(true);
- fanboysSocialBlockingListSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_dark));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_disabled_light));
- }
- }
- } else { // Fanboy's Annoyance List is on.
- // Disable 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.
- // Disable the switch but turn it on.
- fanboysSocialBlockingListSwitch.setEnabled(false);
- fanboysSocialBlockingListSwitch.setChecked(true);
- } else { // Fanboy's Social Blocking List is off.
- // Disable the switch and turn it off.
- fanboysSocialBlockingListSwitch.setEnabled(false);
- fanboysSocialBlockingListSwitch.setChecked(false);
- }
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_dark));
- } else {
- fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_ghosted_light));
- }
- }
-
- // Set the UltraPrivacy status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (ultraPrivacyEnabledInt == 1) { // UltraPrivacy is on.
- // Turn the switch on.
- ultraPrivacySwitch.setChecked(true);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_dark));
- } else {
- ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_enabled_light));
- }
- } else { // EasyPrivacy is off.
- // Turn the switch off.
- ultraPrivacySwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
- ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_dark));
- } else {
- ultraPrivacyImageView.setImageDrawable(resources.getDrawable(R.drawable.block_tracking_disabled_light));
- }
- }
-
- // Set the third-party resource blocking status. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
- if (blockAllThirdPartyRequestsInt == 1) { // Blocking all third-party requests is on.
- // Turn the switch on.
- blockAllThirdPartyRequestsSwitch.setChecked(true);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.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.
- // Turn the switch off.
- blockAllThirdPartyRequestsSwitch.setChecked(false);
-
- // Set the icon according to the theme.
- if (MainWebViewActivity.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));
- }
- }