+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ // Update the icon and the visibility of the wide viewport text view.
+ switch (position) {
+ case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+ if (defaultWideViewport) { // Wide viewport is enabled by default.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_night));
+ } else {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_day));
+ }
+ } else { // Wide viewport is disabled by default.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_night));
+ } else {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_day));
+ }
+ }
+
+ // Show the wide viewport text view.
+ wideViewportTextView.setVisibility(View.VISIBLE);
+ break;
+
+ case DomainsDatabaseHelper.ENABLED:
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_night));
+ } else {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_enabled_day));
+ }
+
+ // Hide the wide viewport text view.
+ wideViewportTextView.setVisibility(View.GONE);
+ break;
+
+ case DomainsDatabaseHelper.DISABLED:
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_night));
+ } else {
+ wideViewportImageView.setImageDrawable(resources.getDrawable(R.drawable.wide_viewport_disabled_day));
+ }
+
+ // Hid ethe wide viewport text view.
+ wideViewportTextView.setVisibility(View.GONE);
+ break;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Do nothing.
+ }
+ });
+
+ // Set the display webpage images spinner listener.
+ displayWebpageImagesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ // Update the icon and the visibility of the display images text view.
+ switch (position) {
+ case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+ if (defaultDisplayWebpageImages) { // Display webpage images is enabled by default.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_night));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_day));
+ }
+ } else { // Display webpage images is disabled by default.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_night));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_day));
+ }
+ }
+
+ // Show the display images text view.
+ displayImagesTextView.setVisibility(View.VISIBLE);
+ break;
+
+ case DomainsDatabaseHelper.ENABLED:
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_night));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_enabled_day));
+ }
+
+ // Hide the display images text view.
+ displayImagesTextView.setVisibility(View.GONE);
+ break;
+
+ case DomainsDatabaseHelper.DISABLED:
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_night));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(resources.getDrawable(R.drawable.images_disabled_day));
+ }
+
+ // Hide the display images text view.
+ displayImagesTextView.setVisibility(View.GONE);
+ break;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Do nothing.
+ }
+ });
+
+ // 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 (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_night));
+ } else {
+ pinnedSslCertificateImageView.setImageDrawable(resources.getDrawable(R.drawable.ssl_certificate_enabled_day));
+ }
+
+ // 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 (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_33);