+ // Set the saved form data initial status. The default is false.
+ saveFormDataEnabled = sharedPreferences.getBoolean("save_form_data_enabled", false);
+ mainWebView.getSettings().setSaveFormData(saveFormDataEnabled);
+
+ // Set the user agent initial status.
+ String userAgentString = sharedPreferences.getString("user_agent", "Default user agent");
+ switch (userAgentString) {
+ case "Default user agent":
+ // Do nothing.
+ break;
+
+ case "Custom user agent":
+ // Set the custom user agent on mainWebView, The default is "PrivacyBrowser/1.0".
+ mainWebView.getSettings().setUserAgentString(sharedPreferences.getString("custom_user_agent", "PrivacyBrowser/1.0"));
+ break;
+
+ default:
+ // Set the selected user agent on mainWebView. The default is "PrivacyBrowser/1.0".
+ mainWebView.getSettings().setUserAgentString(sharedPreferences.getString("user_agent", "PrivacyBrowser/1.0"));
+ break;
+ }
+
+ // Set the initial string for JavaScript disabled search.
+ if (sharedPreferences.getString("javascript_disabled_search", "https://duckduckgo.com/html/?q=").equals("Custom URL")) {
+ // Get the custom URL string. The default is "".
+ javaScriptDisabledSearchURL = sharedPreferences.getString("javascript_disabled_search_custom_url", "");
+ } else {
+ // Use the string from javascript_disabled_search.
+ javaScriptDisabledSearchURL = sharedPreferences.getString("javascript_disabled_search", "https://duckduckgo.com/html/?q=");
+ }
+
+ // Set the initial string for JavaScript enabled search.
+ if (sharedPreferences.getString("javascript_enabled_search", "https://duckduckgo.com/?q=").equals("Custom URL")) {
+ // Get the custom URL string. The default is "".
+ javaScriptEnabledSearchURL = sharedPreferences.getString("javascript_enabled_search_custom_url", "");
+ } else {
+ // Use the string from javascript_enabled_search.
+ javaScriptEnabledSearchURL = sharedPreferences.getString("javascript_enabled_search", "https://duckduckgo.com/?q=");
+ }
+
+
+ // Set the homepage initial status. The default value is `https://www.duckduckgo.com`.
+ homepage = sharedPreferences.getString("homepage", "https://www.duckduckgo.com");
+
+ // Set the font size initial status. the default value is `100`.
+ String defaultFontSizeString = sharedPreferences.getString("default_font_size", "100");
+ mainWebView.getSettings().setTextZoom(Integer.valueOf(defaultFontSizeString));
+
+ // Set the swipe to refresh initial status. The default is `true`.
+ swipeToRefreshEnabled = sharedPreferences.getBoolean("swipe_to_refresh_enabled", true);
+ swipeToRefresh.setEnabled(swipeToRefreshEnabled);
+
+
+ // Replace the header that `WebView` creates for `X-Requested-With` with a null value. The default value is the application ID (com.stoutner.privacybrowser.standard).
+ customHeaders.put("X-Requested-With", "");
+
+ // Set Do Not Track. The default is true.
+ if (sharedPreferences.getBoolean("do_not_track", true)) {
+ customHeaders.put("DNT", "1");
+ }
+