+ // Set the pinned IP addresses switch listener.
+ pinnedIpAddressesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // IP addresses pinning is enabled.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
+ } else {
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
+ }
+
+ // Update the visibility of the saved IP addresses card view.
+ if (savedIpAddresses == null) { // There are no saved IP addresses.
+ savedIpAddressesCardView.setVisibility(View.GONE);
+ } else { // There are saved IP addresses.
+ savedIpAddressesCardView.setVisibility(View.VISIBLE);
+ }
+
+ // Show the current IP addresses card view.
+ currentIpAddressesCardView.setVisibility(View.VISIBLE);
+
+ // Set the status of the radio buttons.
+ if (savedIpAddressesCardView.getVisibility() == View.VISIBLE) { // The saved IP addresses are visible.
+ // Check the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the current IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(false);
+
+ // Set the background of the saved IP addresses linear layout to be transparent.
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the current IP addresses linear layout according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ } else { // The saved IP addresses are not visible.
+ // Check the current IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(false);
+
+ // Set the background of the current IP addresses linear layout to be transparent.
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the saved IP addresses linear layout according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ }
+
+ // Scroll to the bottom of the card views.
+ currentIpAddressesCardView.getParent().requestChildFocus(currentIpAddressesCardView, currentIpAddressesCardView);
+ } else { // IP addresses pinning is disabled.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
+ } else {
+ pinnedIpAddressesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
+ }
+
+ // Hide the IP addresses card views.
+ savedIpAddressesCardView.setVisibility(View.GONE);
+ currentIpAddressesCardView.setVisibility(View.GONE);
+
+ // Uncheck the radio buttons.
+ savedIpAddressesRadioButton.setChecked(false);
+ currentIpAddressesRadioButton.setChecked(false);
+ }
+ });
+
+ savedIpAddressesCardView.setOnClickListener((View view) -> {
+ // Check the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the current website IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(false);
+
+ // Set the background of the saved IP addresses linear layout to be transparent.
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the current IP addresses linear layout according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ savedIpAddressesRadioButton.setOnClickListener((View view) -> {
+ // Check the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the current website IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(false);
+
+ // Set the background of the saved IP addresses linear layout to be transparent.
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the current IP addresses linear layout according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ currentIpAddressesCardView.setOnClickListener((View view) -> {
+ // Check the current IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(false);
+
+ // Set the background of the current IP addresses linear layout to be transparent.
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the saved IP addresses linear layout according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ currentIpAddressesRadioButton.setOnClickListener((View view) -> {
+ // Check the current IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(false);
+
+ // Set the background of the current IP addresses linear layout to be transparent.
+ currentIpAddressesLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the saved IP addresses linear layout according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ // Set the scroll Y.
+ domainSettingsScrollView.post(() -> domainSettingsScrollView.setScrollY(scrollY));
+
+ // Return the domain settings view.