+ public void saveDomainSettings(View view, Resources resources) {
+ // Get handles for the domain settings.
+ EditText domainNameEditText = view.findViewById(R.id.domain_settings_name_edittext);
+ SwitchCompat javaScriptSwitch = view.findViewById(R.id.javascript_switch);
+ SwitchCompat cookiesSwitch = view.findViewById(R.id.cookies_switch);
+ SwitchCompat domStorageSwitch = view.findViewById(R.id.dom_storage_switch);
+ SwitchCompat formDataSwitch = view.findViewById(R.id.form_data_switch); // Form data can be removed once the minimum API >= 26.
+ SwitchCompat easyListSwitch = view.findViewById(R.id.easylist_switch);
+ SwitchCompat easyPrivacySwitch = view.findViewById(R.id.easyprivacy_switch);
+ SwitchCompat fanboysAnnoyanceSwitch = view.findViewById(R.id.fanboys_annoyance_list_switch);
+ SwitchCompat fanboysSocialBlockingSwitch = view.findViewById(R.id.fanboys_social_blocking_list_switch);
+ SwitchCompat ultraListSwitch = view.findViewById(R.id.ultralist_switch);
+ SwitchCompat ultraPrivacySwitch = view.findViewById(R.id.ultraprivacy_switch);
+ SwitchCompat 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 xRequestedWithHeaderSpinner = view.findViewById(R.id.x_requested_with_header_spinner);
+ 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 webViewThemeSpinner = view.findViewById(R.id.webview_theme_spinner);
+ Spinner wideViewportSpinner = view.findViewById(R.id.wide_viewport_spinner);
+ Spinner displayWebpageImagesSpinner = view.findViewById(R.id.display_webpage_images_spinner);
+ SwitchCompat pinnedSslCertificateSwitch = view.findViewById(R.id.pinned_ssl_certificate_switch);
+ RadioButton currentWebsiteCertificateRadioButton = view.findViewById(R.id.current_website_certificate_radiobutton);
+ SwitchCompat 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 cookies = cookiesSwitch.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 xRequestedWithHeaderSwitchInt = xRequestedWithHeaderSpinner.getSelectedItemPosition();
+ int fontSizeSwitchPosition = fontSizeSpinner.getSelectedItemPosition();
+ int swipeToRefreshInt = swipeToRefreshSpinner.getSelectedItemPosition();
+ int webViewThemeInt = webViewThemeSpinner.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;
+
+ default:
+ // Get the array of user agent names.
+ String[] userAgentNameArray = resources.getStringArray(R.array.user_agent_names);
+
+ // Set the user agent name from the array. The domain spinner has one more entry than the name array, so the position must be decremented.
+ userAgentName = userAgentNameArray[userAgentSwitchPosition - 1];
+ }
+
+ // Initialize the font size integer. `0` indicates the system default font size.
+ int fontSizeInt = 0;
+
+ // Use a custom font size if it is selected.
+ if (fontSizeSwitchPosition == 1) { // A custom font size is specified.
+ // Get the custom font size from the edit text.
+ fontSizeInt = Integer.parseInt(customFontSizeEditText.getText().toString());
+ }
+
+ // Save the domain settings.
+ domainsDatabaseHelper.updateDomain(DomainsActivity.currentDomainDatabaseId, domainNameString, javaScript, cookies, domStorage, formData, easyList, easyPrivacy,
+ fanboysAnnoyance, fanboysSocialBlocking, ultraList, ultraPrivacy, blockAllThirdPartyRequests, userAgentName, xRequestedWithHeaderSwitchInt, fontSizeInt, swipeToRefreshInt, webViewThemeInt,
+ wideViewportInt, displayWebpageImagesInt, pinnedSslCertificate, pinnedIpAddress);
+
+ // Update the pinned SSL certificate if a new one is checked.
+ if (currentWebsiteCertificateRadioButton.isChecked()) {
+ // Update the database.
+ domainsDatabaseHelper.updatePinnedSslCertificate(currentDomainDatabaseId, sslIssuedToCName, sslIssuedToOName, sslIssuedToUName, sslIssuedByCName, sslIssuedByOName, sslIssuedByUName,
+ sslStartDateLong, sslEndDateLong);
+ }
+
+ // Update the pinned IP addresses if new ones are checked.
+ if (currentIpAddressesRadioButton.isChecked()) {
+ // Update the database.
+ domainsDatabaseHelper.updatePinnedIpAddresses(currentDomainDatabaseId, currentIpAddresses);
+ }
+ }
+
+ private void populateDomainsListView(final int highlightedDomainDatabaseId, int domainsListViewPosition) {
+ // get a handle for the current `domains_listview`.
+ domainsListView = findViewById(R.id.domains_listview);
+