- // Get handles for the preferences we need to modify.
- final Preference javaScriptPreference = findPreference("javascript_enabled");
- final Preference firstPartyCookiesPreference = findPreference("first_party_cookies_enabled");
- final Preference thirdPartyCookiesPreference = findPreference("third_party_cookies_enabled");
- final Preference domStoragePreference = findPreference("dom_storage_enabled");
- final Preference saveFormDataPreference = findPreference("save_form_data_enabled"); // The form data preference can be removed once the minimum API >= 26.
- final Preference userAgentPreference = findPreference("user_agent");
- final Preference customUserAgentPreference = findPreference("custom_user_agent");
- final Preference incognitoModePreference = findPreference("incognito_mode");
- final Preference doNotTrackPreference = findPreference("do_not_track");
- final Preference allowScreenshotsPreference = findPreference("allow_screenshots");
- final Preference easyListPreference = findPreference("easylist");
- final Preference easyPrivacyPreference = findPreference("easyprivacy");
- final Preference fanboyAnnoyanceListPreference = findPreference("fanboy_annoyance_list");
- final Preference fanboySocialBlockingListPreference = findPreference("fanboy_social_blocking_list");
- final Preference proxyThroughOrbotPreference = findPreference("proxy_through_orbot");
- final Preference torHomepagePreference = findPreference("tor_homepage");
- final Preference torSearchPreference = findPreference("tor_search");
- final Preference torSearchCustomURLPreference = findPreference("tor_search_custom_url");
- final Preference searchPreference = findPreference("search");
- final Preference searchCustomURLPreference = findPreference("search_custom_url");
- final Preference fullScreenBrowsingModePreference = findPreference("full_screen_browsing_mode");
- final Preference hideSystemBarsPreference = findPreference("hide_system_bars");
- final Preference translucentNavigationBarPreference = findPreference("translucent_navigation_bar");
- final Preference clearEverythingPreference = findPreference("clear_everything");
- final Preference clearCookiesPreference = findPreference("clear_cookies");
- final Preference clearDomStoragePreference = findPreference("clear_dom_storage");
- final Preference clearFormDataPreference = findPreference("clear_form_data"); // The clear form data preference can be removed once the minimum API >= 26.
- final Preference clearCachePreference = findPreference("clear_cache");
- final Preference homepagePreference = findPreference("homepage");
- final Preference defaultFontSizePreference = findPreference("default_font_size");
- final Preference swipeToRefreshPreference = findPreference("swipe_to_refresh");
- final Preference displayAdditionalAppBarIconsPreference = findPreference("display_additional_app_bar_icons");
- final Preference darkThemePreference = findPreference("dark_theme");
- final Preference nightModePreference = findPreference("night_mode");
- final Preference displayWebpageImagesPreference = findPreference("display_webpage_images");
-
- // Set dependencies.
- torHomepagePreference.setDependency("proxy_through_orbot");
- torSearchPreference.setDependency("proxy_through_orbot");
- hideSystemBarsPreference.setDependency("full_screen_browsing_mode");
-
- // Get Strings from the preferences.
- String torSearchString = savedPreferences.getString("tor_search", "https://3g2upl4pq6kufc4m.onion/html/?q=");
- String searchString = savedPreferences.getString("search", "https://duckduckgo.com/html/?q=");
+ // Get handles for the preferences.
+ Preference javaScriptPreference = findPreference("javascript");
+ Preference firstPartyCookiesPreference = findPreference("first_party_cookies");
+ Preference thirdPartyCookiesPreference = findPreference("third_party_cookies");
+ Preference domStoragePreference = findPreference("dom_storage");
+ Preference formDataPreference = findPreference("save_form_data"); // The form data preference can be removed once the minimum API >= 26.
+ Preference userAgentPreference = findPreference("user_agent");
+ Preference customUserAgentPreference = findPreference("custom_user_agent");
+ Preference incognitoModePreference = findPreference("incognito_mode");
+ Preference doNotTrackPreference = findPreference("do_not_track");
+ Preference allowScreenshotsPreference = findPreference("allow_screenshots");
+ Preference easyListPreference = findPreference("easylist");
+ Preference easyPrivacyPreference = findPreference("easyprivacy");
+ Preference fanboyAnnoyanceListPreference = findPreference("fanboys_annoyance_list");
+ Preference fanboySocialBlockingListPreference = findPreference("fanboys_social_blocking_list");
+ Preference ultraListPreference = findPreference("ultralist");
+ Preference ultraPrivacyPreference = findPreference("ultraprivacy");
+ Preference blockAllThirdPartyRequestsPreference = findPreference("block_all_third_party_requests");
+ Preference googleAnalyticsPreference = findPreference("google_analytics");
+ Preference facebookClickIdsPreference = findPreference("facebook_click_ids");
+ Preference twitterAmpRedirectsPreference = findPreference("twitter_amp_redirects");
+ Preference searchPreference = findPreference("search");
+ Preference searchCustomURLPreference = findPreference("search_custom_url");
+ Preference proxyPreference = findPreference("proxy");
+ Preference proxyCustomUrlPreference = findPreference("proxy_custom_url");
+ Preference fullScreenBrowsingModePreference = findPreference("full_screen_browsing_mode");
+ Preference hideAppBarPreference = findPreference("hide_app_bar");
+ Preference clearEverythingPreference = findPreference("clear_everything");
+ Preference clearCookiesPreference = findPreference("clear_cookies");
+ Preference clearDomStoragePreference = findPreference("clear_dom_storage");
+ Preference clearFormDataPreference = findPreference("clear_form_data"); // The clear form data preference can be removed once the minimum API >= 26.
+ Preference clearCachePreference = findPreference("clear_cache");
+ Preference homepagePreference = findPreference("homepage");
+ Preference downloadLocationPreference = findPreference("download_location");
+ Preference downloadCustomLocationPreference = findPreference("download_custom_location");
+ Preference fontSizePreference = findPreference("font_size");
+ Preference openIntentsInNewTabPreference = findPreference("open_intents_in_new_tab");
+ Preference swipeToRefreshPreference = findPreference("swipe_to_refresh");
+ Preference scrollAppBarPreference = findPreference("scroll_app_bar");
+ Preference displayAdditionalAppBarIconsPreference = findPreference("display_additional_app_bar_icons");
+ Preference appThemePreference = findPreference("app_theme");
+ Preference webViewThemePreference = findPreference("webview_theme");
+ Preference wideViewportPreference = findPreference("wide_viewport");
+ Preference displayWebpageImagesPreference = findPreference("display_webpage_images");
+
+ // Remove the lint warnings below that the preferences might be null.
+ assert javaScriptPreference != null;
+ assert firstPartyCookiesPreference != null;
+ assert thirdPartyCookiesPreference != null;
+ assert domStoragePreference != null;
+ assert formDataPreference != null;
+ assert userAgentPreference != null;
+ assert customUserAgentPreference != null;
+ assert incognitoModePreference != null;
+ assert doNotTrackPreference != null;
+ assert allowScreenshotsPreference != null;
+ assert easyListPreference != null;
+ assert easyPrivacyPreference != null;
+ assert fanboyAnnoyanceListPreference != null;
+ assert fanboySocialBlockingListPreference != null;
+ assert ultraListPreference != null;
+ assert ultraPrivacyPreference != null;
+ assert blockAllThirdPartyRequestsPreference != null;
+ assert googleAnalyticsPreference != null;
+ assert facebookClickIdsPreference != null;
+ assert twitterAmpRedirectsPreference != null;
+ assert searchPreference != null;
+ assert searchCustomURLPreference != null;
+ assert proxyPreference != null;
+ assert proxyCustomUrlPreference != null;
+ assert fullScreenBrowsingModePreference != null;
+ assert hideAppBarPreference != null;
+ assert clearEverythingPreference != null;
+ assert clearCookiesPreference != null;
+ assert clearDomStoragePreference != null;
+ assert clearFormDataPreference != null;
+ assert clearCachePreference != null;
+ assert homepagePreference != null;
+ assert downloadLocationPreference != null;
+ assert downloadCustomLocationPreference != null;
+ assert fontSizePreference != null;
+ assert openIntentsInNewTabPreference != null;
+ assert swipeToRefreshPreference != null;
+ assert scrollAppBarPreference != null;
+ assert displayAdditionalAppBarIconsPreference != null;
+ assert appThemePreference != null;
+ assert webViewThemePreference != null;
+ assert wideViewportPreference != null;
+ assert displayWebpageImagesPreference != null;
+
+ // Set the preference dependencies.
+ hideAppBarPreference.setDependency("full_screen_browsing_mode");
+ domStoragePreference.setDependency("javascript");
+
+ // Get strings from the preferences.
+ String userAgentName = savedPreferences.getString("user_agent", getString(R.string.user_agent_default_value));
+ String searchString = savedPreferences.getString("search", getString(R.string.search_default_value));
+ String proxyString = savedPreferences.getString("proxy", getString(R.string.proxy_default_value));
+ String downloadLocationString = savedPreferences.getString("download_location", getString(R.string.download_location_default_value));