+ // Update the icons for `first_party_cookies_enabled` and `third_party_cookies_enabled`.
+ if (sharedPreferences.getBoolean("first_party_cookies_enabled", false)) {
+ // Set the icon for `first_party_cookies_enabled`.
+ firstPartyCookiesPreference.setIcon(R.drawable.cookies_enabled);
+
+ // Update the icon for `third_party_cookies_enabled`.
+ if (Build.VERSION.SDK_INT >= 21) {
+ if (sharedPreferences.getBoolean("third_party_cookies_enabled", false)) {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_warning);
+ } else {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_disabled);
+ }
+ } else {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_ghosted);
+ }
+ } else { // `first_party_cookies_enabled` is `false`.
+ // Update the icon for `first_party_cookies_enabled`.
+ firstPartyCookiesPreference.setIcon(R.drawable.cookies_disabled);
+
+ // Set the icon for `third_party_cookies_enabled` to be ghosted.
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_ghosted);
+ }
+
+ // Enable `third_party_cookies_enabled` if `first_party_cookies_enabled` is `true` and API >= 21.
+ thirdPartyCookiesPreference.setEnabled(sharedPreferences.getBoolean("first_party_cookies_enabled", false) && (Build.VERSION.SDK_INT >= 21));
+ break;
+
+ case "third_party_cookies_enabled":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("third_party_cookies_enabled", false)) {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_warning);
+ } else {
+ thirdPartyCookiesPreference.setIcon(R.drawable.cookies_disabled);
+ }
+ break;
+
+ case "dom_storage_enabled":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("dom_storage_enabled", false)) {
+ domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
+ } else {
+ domStoragePreference.setIcon(R.drawable.dom_storage_disabled);
+ }