+
+ // Set the pinned SSL certificate switch listener.
+ pinnedSslCertificateSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // SSL certificate pinning is enabled.
+ // Set the icon according to the theme.
+ if (darkTheme) {
+ pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_dark));
+ } else {
+ pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_light));
+ }
+
+ // Update the visibility of the saved SSL certificate.
+ if (savedSslIssuedToCNameString == null) {
+ savedSslCardView.setVisibility(View.GONE);
+ } else {
+ savedSslCardView.setVisibility(View.VISIBLE);
+ }
+
+ // Update the visibility of the current website SSL certificate.
+ if (DomainsActivity.sslIssuedToCName == null) {
+ // Hide the SSL certificate.
+ currentSslCardView.setVisibility(View.GONE);
+
+ // Show the instruction.
+ noCurrentWebsiteCertificateTextView.setVisibility(View.VISIBLE);
+ } else {
+ // Show the SSL certificate.
+ currentSslCardView.setVisibility(View.VISIBLE);
+
+ // Hide the instruction.
+ noCurrentWebsiteCertificateTextView.setVisibility(View.GONE);
+ }
+
+ // Set the status of the radio buttons.
+ if (savedSslCardView.getVisibility() == View.VISIBLE) { // The saved SSL certificate is displayed.
+ // Check the saved SSL certificate radio button.
+ savedSslCertificateRadioButton.setChecked(true);
+
+ // Uncheck the current website SSL certificate radio button.
+ currentWebsiteCertificateRadioButton.setChecked(false);
+
+ // Set the background of the saved SSL certificate linear layout to be transparent.
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the current website SSL certificate linear layout according to the theme.
+ if (darkTheme) {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+
+ // Scroll to the current website SSL certificate card.
+ savedSslCardView.getParent().requestChildFocus(savedSslCardView, savedSslCardView);
+ } else if (currentSslCardView.getVisibility() == View.VISIBLE) { // The saved SSL certificate is hidden but the current website SSL certificate is visible.
+ // Check the current website SSL certificate radio button.
+ currentWebsiteCertificateRadioButton.setChecked(true);
+
+ // Uncheck the saved SSL certificate radio button.
+ savedSslCertificateRadioButton.setChecked(false);
+
+ // Set the background of the current website SSL certificate linear layout to be transparent.
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the saved SSL certificate linear layout according to the theme.
+ if (darkTheme) {
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+
+ // Scroll to the current website SSL certificate card.
+ currentSslCardView.getParent().requestChildFocus(currentSslCardView, currentSslCardView);
+ } else { // Neither SSL certificate is visible.
+ // Uncheck both radio buttons.
+ savedSslCertificateRadioButton.setChecked(false);
+ currentWebsiteCertificateRadioButton.setChecked(false);
+
+ // Scroll to the current website SSL certificate card.
+ noCurrentWebsiteCertificateTextView.getParent().requestChildFocus(noCurrentWebsiteCertificateTextView, noCurrentWebsiteCertificateTextView);
+ }
+ } else { // SSL certificate pinning is disabled.
+ // Set the icon according to the theme.
+ if (darkTheme) {
+ pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_dark));
+ } else {
+ pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_light));
+ }
+
+ // Hide the SSl certificates and instructions.
+ savedSslCardView.setVisibility(View.GONE);
+ currentSslCardView.setVisibility(View.GONE);
+ noCurrentWebsiteCertificateTextView.setVisibility(View.GONE);
+
+ // Uncheck the radio buttons.
+ savedSslCertificateRadioButton.setChecked(false);
+ currentWebsiteCertificateRadioButton.setChecked(false);
+ }
+ });
+
+ savedSslCardView.setOnClickListener((View view) -> {
+ // Check the saved SSL certificate radio button.
+ savedSslCertificateRadioButton.setChecked(true);
+
+ // Uncheck the current website SSL certificate radio button.
+ currentWebsiteCertificateRadioButton.setChecked(false);
+
+ // Set the background of the saved SSL certificate linear layout to be transparent.
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the current website SSL certificate linear layout according to the theme.
+ if (darkTheme) {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ savedSslCertificateRadioButton.setOnClickListener((View view) -> {
+ // Check the saved SSL certificate radio button.
+ savedSslCertificateRadioButton.setChecked(true);
+
+ // Uncheck the current website SSL certificate radio button.
+ currentWebsiteCertificateRadioButton.setChecked(false);
+
+ // Set the background of the saved SSL certificate linear layout to be transparent.
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the current website SSL certificate linear layout according to the theme.
+ if (darkTheme) {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ currentSslCardView.setOnClickListener((View view) -> {
+ // Check the current website SSL certificate radio button.
+ currentWebsiteCertificateRadioButton.setChecked(true);
+
+ // Uncheck the saved SSL certificate radio button.
+ savedSslCertificateRadioButton.setChecked(false);
+
+ // Set the background of the current website SSL certificate linear layout to be transparent.
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the saved SSL certificate linear layout according to the theme.
+ if (darkTheme) {
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ currentWebsiteCertificateRadioButton.setOnClickListener((View view) -> {
+ // Check the current website SSL certificate radio button.
+ currentWebsiteCertificateRadioButton.setChecked(true);
+
+ // Uncheck the saved SSL certificate radio button.
+ savedSslCertificateRadioButton.setChecked(false);
+
+ // Set the background of the current website SSL certificate linear layout to be transparent.
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.transparent);
+
+ // Darken the background of the saved SSL certificate linear layout according to the theme.
+ if (darkTheme) {
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedSslCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });
+
+ // 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 (darkTheme) {
+ pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_dark));
+ } else {
+ pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_light));
+ }
+
+ // 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 (darkTheme) {
+ 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 (darkTheme) {
+ 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 (darkTheme) {
+ pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_dark));
+ } else {
+ pinnedIpAddressesImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_disabled_light));
+ }
+
+ // 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 (darkTheme) {
+ 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 (darkTheme) {
+ 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 (darkTheme) {
+ 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 (darkTheme) {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_33);
+ } else {
+ savedIpAddressesLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ });