- // 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 third-party cookies switch listener.
- thirdPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
- // Update the icon.
- if (isChecked) {
- // Set the third-party cookies icon to be red.
- thirdPartyCookiesImageView.setImageDrawable(resources.getDrawable(R.drawable.cookies_warning));
- } 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));
+ // Set the cookies switch listener.
+ cookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ if (isChecked) { // Cookies are enabled.
+ // Update the cookies icon.
+ cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
+ } else { // Cookies are disabled.
+ // Update the cookies icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ cookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));