+ public void saveDomainSettings(View view, Resources resources) {
+ // Get handles for the domain settings.
+ EditText domainNameEditText = view.findViewById(R.id.domain_settings_name_edittext);
+ Switch javaScriptSwitch = view.findViewById(R.id.javascript_switch);
+ Switch firstPartyCookiesSwitch = view.findViewById(R.id.first_party_cookies_switch);
+ Switch thirdPartyCookiesSwitch = view.findViewById(R.id.third_party_cookies_switch);
+ Switch domStorageSwitch = view.findViewById(R.id.dom_storage_switch);
+ Switch formDataSwitch = view.findViewById(R.id.form_data_switch); // Form data can be removed once the minimum API >= 26.
+ Switch easyListSwitch = view.findViewById(R.id.easylist_switch);
+ Switch easyPrivacySwitch = view.findViewById(R.id.easyprivacy_switch);
+ Switch fanboysAnnoyanceSwitch = view.findViewById(R.id.fanboys_annoyance_list_switch);
+ Switch fanboysSocialBlockingSwitch = view.findViewById(R.id.fanboys_social_blocking_list_switch);
+ Switch ultraListSwitch = view.findViewById(R.id.ultralist_switch);
+ Switch ultraPrivacySwitch = view.findViewById(R.id.ultraprivacy_switch);
+ Switch blockAllThirdPartyRequestsSwitch = view.findViewById(R.id.block_all_third_party_requests_switch);
+ Spinner userAgentSpinner = view.findViewById(R.id.user_agent_spinner);
+ EditText customUserAgentEditText = view.findViewById(R.id.custom_user_agent_edittext);
+ Spinner fontSizeSpinner = view.findViewById(R.id.font_size_spinner);
+ EditText customFontSizeEditText = view.findViewById(R.id.custom_font_size_edittext);
+ Spinner swipeToRefreshSpinner = view.findViewById(R.id.swipe_to_refresh_spinner);
+ Spinner nightModeSpinner = view.findViewById(R.id.night_mode_spinner);
+ Spinner wideViewportSpinner = view.findViewById(R.id.wide_viewport_spinner);
+ Spinner displayWebpageImagesSpinner = view.findViewById(R.id.display_webpage_images_spinner);
+ Switch pinnedSslCertificateSwitch = view.findViewById(R.id.pinned_ssl_certificate_switch);
+ RadioButton currentWebsiteCertificateRadioButton = view.findViewById(R.id.current_website_certificate_radiobutton);
+ Switch pinnedIpAddressesSwitch = view.findViewById(R.id.pinned_ip_addresses_switch);
+ RadioButton currentIpAddressesRadioButton = view.findViewById(R.id.current_ip_addresses_radiobutton);
+
+ // Extract the data for the domain settings.
+ String domainNameString = domainNameEditText.getText().toString();
+ boolean javaScript = javaScriptSwitch.isChecked();
+ boolean firstPartyCookies = firstPartyCookiesSwitch.isChecked();
+ boolean thirdPartyCookies = thirdPartyCookiesSwitch.isChecked();
+ boolean domStorage = domStorageSwitch.isChecked();
+ boolean formData = formDataSwitch.isChecked(); // Form data can be removed once the minimum API >= 26.
+ boolean easyList = easyListSwitch.isChecked();
+ boolean easyPrivacy = easyPrivacySwitch.isChecked();
+ boolean fanboysAnnoyance = fanboysAnnoyanceSwitch.isChecked();
+ boolean fanboysSocialBlocking = fanboysSocialBlockingSwitch.isChecked();
+ boolean ultraList = ultraListSwitch.isChecked();
+ boolean ultraPrivacy = ultraPrivacySwitch.isChecked();
+ boolean blockAllThirdPartyRequests = blockAllThirdPartyRequestsSwitch.isChecked();
+ int userAgentSwitchPosition = userAgentSpinner.getSelectedItemPosition();
+ int fontSizeSwitchPosition = fontSizeSpinner.getSelectedItemPosition();
+ int swipeToRefreshInt = swipeToRefreshSpinner.getSelectedItemPosition();
+ int nightModeInt = nightModeSpinner.getSelectedItemPosition();
+ int wideViewportInt = wideViewportSpinner.getSelectedItemPosition();
+ int displayWebpageImagesInt = displayWebpageImagesSpinner.getSelectedItemPosition();
+ boolean pinnedSslCertificate = pinnedSslCertificateSwitch.isChecked();
+ boolean pinnedIpAddress = pinnedIpAddressesSwitch.isChecked();
+
+ // Initialize the user agent name string.
+ String userAgentName;
+
+ // Set the user agent name.
+ switch (userAgentSwitchPosition) {
+ case MainWebViewActivity.DOMAINS_SYSTEM_DEFAULT_USER_AGENT:
+ // Set the user agent name to be `System default user agent`.
+ userAgentName = resources.getString(R.string.system_default_user_agent);
+ break;
+
+ case MainWebViewActivity.DOMAINS_CUSTOM_USER_AGENT:
+ // Set the user agent name to be the custom user agent.
+ userAgentName = customUserAgentEditText.getText().toString();
+ break;