- // 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- if (fanboysAnnoyanceListInt == 0) { // Fanboy's Annoyance List is on.
- // Enable Fanboy's Social Blocking List switch.
- 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.
- 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.
- 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);
-
- // Set the status of Fanboy's Social Blocking List.
- fanboysSocialBlockingListSwitch.setChecked(fanboysSocialBlockingListInt == 1);
-
- // 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled, null));
- }
+ // Set the switch positions.
+ easyListSwitch.setChecked(easyListInt == 1);
+ easyPrivacySwitch.setChecked(easyPrivacyInt == 1);
+ fanboysAnnoyanceListSwitch.setChecked(fanboysAnnoyanceListInt == 1);
+ fanboysSocialBlockingListSwitch.setChecked(fanboysSocialBlockingListInt == 1);
+ ultraListSwitch.setChecked(ultraListInt == 1);
+ ultraPrivacySwitch.setChecked(ultraPrivacyInt == 1);
+ blockAllThirdPartyRequestsSwitch.setChecked(blockAllThirdPartyRequestsInt == 1);
+
+ // Set the switch icon colors.
+ easyListImageView.setSelected(easyListInt == 1);
+ easyPrivacyImageView.setSelected(easyPrivacyInt == 1);
+ fanboysAnnoyanceListImageView.setSelected(fanboysAnnoyanceListInt == 1);
+ fanboysSocialBlockingListImageView.setSelected(fanboysSocialBlockingListInt == 1);
+ ultraListImageView.setSelected(ultraListInt == 1);
+ ultraPrivacyImageView.setSelected(ultraPrivacyInt == 1);
+ blockAllThirdPartyRequestsImageView.setSelected(blockAllThirdPartyRequestsInt == 1);
+
+ // Set Fanboy's Social Blocking List switch status based on the Annoyance List status.
+ fanboysSocialBlockingListSwitch.setEnabled(fanboysAnnoyanceListInt == 0);
+
+ // Set the Social Blocking List icon ghosted status based on the Annoyance List status.
+ fanboysSocialBlockingListImageView.setEnabled(fanboysAnnoyanceListInt == 0);