+ hideAppBarPreference.setDependency("full_screen_browsing_mode");
+
+ // Get strings from the preferences.
+ String torSearchString = savedPreferences.getString("tor_search", getString(R.string.tor_search_default_value));
+ String searchString = savedPreferences.getString("search", getString(R.string.search_default_value));
+
+ // Get booleans that are used in multiple places from the preferences.
+ final boolean javaScriptEnabled = savedPreferences.getBoolean("javascript", false);
+ boolean firstPartyCookiesEnabled = savedPreferences.getBoolean("first_party_cookies", false);
+ boolean thirdPartyCookiesEnabled = savedPreferences.getBoolean("third_party_cookies", false);
+ boolean fanboyAnnoyanceListEnabled = savedPreferences.getBoolean("fanboys_annoyance_list", true);
+ boolean fanboySocialBlockingEnabled = savedPreferences.getBoolean("fanboys_social_blocking_list", true);
+ boolean proxyThroughOrbot = savedPreferences.getBoolean("proxy_through_orbot", false);
+ boolean fullScreenBrowsingMode = savedPreferences.getBoolean("full_screen_browsing_mode", false);
+ boolean clearEverything = savedPreferences.getBoolean("clear_everything", true);
+ final boolean nightMode = savedPreferences.getBoolean("night_mode", false);
+
+ // Only enable the third-party cookies preference if first-party cookies are enabled and API >= 21.
+ thirdPartyCookiesPreference.setEnabled(firstPartyCookiesEnabled && (Build.VERSION.SDK_INT >= 21));
+
+ // Only enable the DOM storage preference if either JavaScript or Night Mode is enabled.
+ domStoragePreference.setEnabled(javaScriptEnabled || nightMode);
+
+ // Remove the form data preferences if the API is >= 26 as they no longer do anything.
+ if (Build.VERSION.SDK_INT >= 26) {
+ // Get the categories.
+ PreferenceCategory privacyCategory = (PreferenceCategory) findPreference("privacy");
+ PreferenceCategory clearAndExitCategory = (PreferenceCategory) findPreference("clear_and_exit");
+
+ // Remove the form data preferences.
+ privacyCategory.removePreference(saveFormDataPreference);
+ clearAndExitCategory.removePreference(clearFormDataPreference);
+ }