+ // Set a green background on `urlTextBox` to indicate that custom domain settings are being used. We have to use the deprecated `.getDrawable()` until the minimum API >= 21.
+ urlAppBarRelativeLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_green));
+ } else { // The URL we are loading does not have custom domain settings. Load the defaults.
+ // Get the shared preference values. `this` references the current context.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+ // Store the values from `sharedPreferences` in variables.
+ javaScriptEnabled = sharedPreferences.getBoolean("javascript_enabled", false);
+ firstPartyCookiesEnabled = sharedPreferences.getBoolean("first_party_cookies_enabled", false);
+ thirdPartyCookiesEnabled = sharedPreferences.getBoolean("third_party_cookies_enabled", false);
+ domStorageEnabled = sharedPreferences.getBoolean("dom_storage_enabled", false);
+ saveFormDataEnabled = sharedPreferences.getBoolean("save_form_data_enabled", false);
+ String userAgentString = sharedPreferences.getString("user_agent", "PrivacyBrowser/1.0");
+ String customUserAgentString = sharedPreferences.getString("custom_user_agent", "PrivacyBrowser/1.0");
+ String defaultFontSizeString = sharedPreferences.getString("default_font_size", "100");
+
+ // Apply the default settings.
+ mainWebView.getSettings().setJavaScriptEnabled(javaScriptEnabled);
+ cookieManager.setAcceptCookie(firstPartyCookiesEnabled);
+ mainWebView.getSettings().setDomStorageEnabled(domStorageEnabled);
+ mainWebView.getSettings().setSaveFormData(saveFormDataEnabled);
+ mainWebView.getSettings().setTextZoom(Integer.valueOf(defaultFontSizeString));
+
+ // Set third-party cookies status if API >= 21.
+ if (Build.VERSION.SDK_INT >= 21) {
+ cookieManager.setAcceptThirdPartyCookies(mainWebView, thirdPartyCookiesEnabled);
+ }