+ // Set the display website images icon and text view settings. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ switch (displayImagesInt) {
+ case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+ if (defaultDisplayWebpageImages) { // Display webpage images enabled by default.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
+ }
+ } else { // Display webpage images disabled by default.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
+ }
+ }
+
+ // 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(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_night, null));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_enabled_day, null));
+ }
+
+ // 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(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_night, null));
+ } else {
+ displayWebpageImagesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.images_disabled_day, null));
+ }
+
+ // Hide the display images text view.
+ displayImagesTextView.setVisibility(View.GONE);
+ break;
+ }
+
+ // Open the display images spinner when the text view is clicked.
+ displayImagesTextView.setOnClickListener((View view) -> {
+ // Open the user agent spinner.
+ displayWebpageImagesSpinner.performClick();
+ });
+
+ // Set the pinned SSL certificate icon.
+ if (pinnedSslCertificateInt == 1) { // Pinned SSL certificate is enabled. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+ // Check the switch.
+ pinnedSslCertificateSwitch.setChecked(true);
+
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_night, null));
+ } else {
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_enabled_day, null));
+ }
+ } else { // Pinned SSL certificate is disabled.
+ // Uncheck the switch.
+ pinnedSslCertificateSwitch.setChecked(false);
+
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_night, null));
+ } else {
+ pinnedSslCertificateImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ssl_certificate_disabled_day, null));
+ }
+ }
+
+ // Store the current date.
+ Date currentDate = Calendar.getInstance().getTime();
+
+ // Setup the string builders to display the general certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ savedSslIssuedToONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), savedSslIssuedToONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ savedSslIssuedToUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), savedSslIssuedToUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ savedSslIssuedByCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), savedSslIssuedByCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ savedSslIssuedByONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), savedSslIssuedByONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ savedSslIssuedByUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), savedSslIssuedByUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+
+ // Check the certificate Common Name against the domain name.
+ boolean savedSslCommonNameMatchesDomainName = checkDomainNameAgainstCertificate(domainNameString, savedSslIssuedToCNameString);
+
+ // Format the issued to Common Name color. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ if (savedSslCommonNameMatchesDomainName) {
+ savedSslIssuedToCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), savedSslIssuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ } else {
+ savedSslIssuedToCNameStringBuilder.setSpan(redColorSpan, cNameLabel.length(), savedSslIssuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ // Format the start date color. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ if ((savedSslStartDate != null) && savedSslStartDate.after(currentDate)) { // The certificate start date is in the future.
+ savedSslStartDateStringBuilder.setSpan(redColorSpan, startDateLabel.length(), savedSslStartDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ } else { // The certificate start date is in the past.
+ savedSslStartDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), savedSslStartDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ // Format the end date color. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ if ((savedSslEndDate != null) && savedSslEndDate.before(currentDate)) { // The certificate end date is in the past.
+ savedSslEndDateStringBuilder.setSpan(redColorSpan, endDateLabel.length(), savedSslEndDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ } else { // The certificate end date is in the future.
+ savedSslEndDateStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), savedSslEndDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ // Display the saved website SSL certificate strings.
+ savedSslIssuedToCNameTextView.setText(savedSslIssuedToCNameStringBuilder);
+ savedSslIssuedToONameTextView.setText(savedSslIssuedToONameStringBuilder);
+ savedSslIssuedToUNameTextView.setText(savedSslIssuedToUNameStringBuilder);
+ savedSslIssuedByCNameTextView.setText(savedSslIssuedByCNameStringBuilder);
+ savedSslIssuedByONameTextView.setText(savedSslIssuedByONameStringBuilder);
+ savedSslIssuedByUNameTextView.setText(savedSslIssuedByUNameStringBuilder);
+ savedSslStartDateTextView.setText(savedSslStartDateStringBuilder);
+ savedSslEndDateTextView.setText(savedSslEndDateStringBuilder);
+
+ // Populate the current website SSL certificate if there is one.
+ if (DomainsActivity.sslIssuedToCName != null) {
+ // Get dates from the raw long values.
+ Date currentSslStartDate = new Date(DomainsActivity.sslStartDateLong);
+ Date currentSslEndDate = new Date(DomainsActivity.sslEndDateLong);
+
+ // Create a spannable string builder for each text view that needs multiple colors of text.
+ SpannableStringBuilder currentSslIssuedToCNameStringBuilder = new SpannableStringBuilder(cNameLabel + DomainsActivity.sslIssuedToCName);
+ SpannableStringBuilder currentSslIssuedToONameStringBuilder = new SpannableStringBuilder(oNameLabel + DomainsActivity.sslIssuedToOName);
+ SpannableStringBuilder currentSslIssuedToUNameStringBuilder = new SpannableStringBuilder(uNameLabel + DomainsActivity.sslIssuedToUName);
+ SpannableStringBuilder currentSslIssuedByCNameStringBuilder = new SpannableStringBuilder(cNameLabel + DomainsActivity.sslIssuedByCName);
+ SpannableStringBuilder currentSslIssuedByONameStringBuilder = new SpannableStringBuilder(oNameLabel + DomainsActivity.sslIssuedByOName);
+ SpannableStringBuilder currentSslIssuedByUNameStringBuilder = new SpannableStringBuilder(uNameLabel + DomainsActivity.sslIssuedByUName);
+ SpannableStringBuilder currentSslStartDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG)
+ .format(currentSslStartDate));
+ SpannableStringBuilder currentSslEndDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG)
+ .format(currentSslEndDate));
+
+ // Setup the string builders to display the general certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ currentSslIssuedToONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), currentSslIssuedToONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ currentSslIssuedToUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), currentSslIssuedToUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ currentSslIssuedByCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), currentSslIssuedByCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ currentSslIssuedByONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), currentSslIssuedByONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ currentSslIssuedByUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), currentSslIssuedByUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+
+ // Check the certificate Common Name against the domain name.
+ boolean currentSslCommonNameMatchesDomainName = checkDomainNameAgainstCertificate(domainNameString, DomainsActivity.sslIssuedToCName);
+
+ // Format the issued to Common Name color. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ if (currentSslCommonNameMatchesDomainName) {
+ currentSslIssuedToCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), currentSslIssuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ } else {
+ currentSslIssuedToCNameStringBuilder.setSpan(redColorSpan, cNameLabel.length(), currentSslIssuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ // Format the start date color. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ if (currentSslStartDate.after(currentDate)) { // The certificate start date is in the future.
+ currentSslStartDateStringBuilder.setSpan(redColorSpan, startDateLabel.length(), currentSslStartDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ } else { // The certificate start date is in the past.
+ currentSslStartDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), currentSslStartDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ // Format the end date color. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ if (currentSslEndDate.before(currentDate)) { // The certificate end date is in the past.
+ currentSslEndDateStringBuilder.setSpan(redColorSpan, endDateLabel.length(), currentSslEndDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ } else { // The certificate end date is in the future.
+ currentSslEndDateStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), currentSslEndDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ }
+
+ // Display the current website SSL certificate strings.
+ currentSslIssuedToCNameTextView.setText(currentSslIssuedToCNameStringBuilder);
+ currentSslIssuedToONameTextView.setText(currentSslIssuedToONameStringBuilder);
+ currentSslIssuedToUNameTextView.setText(currentSslIssuedToUNameStringBuilder);
+ currentSslIssuedByCNameTextView.setText(currentSslIssuedByCNameStringBuilder);
+ currentSslIssuedByONameTextView.setText(currentSslIssuedByONameStringBuilder);
+ currentSslIssuedByUNameTextView.setText(currentSslIssuedByUNameStringBuilder);
+ currentSslStartDateTextView.setText(currentSslStartDateStringBuilder);
+ currentSslEndDateTextView.setText(currentSslEndDateStringBuilder);
+ }
+
+ // Set the initial display status of the SSL certificates card views.
+ if (pinnedSslCertificateSwitch.isChecked()) { // An SSL certificate is pinned.
+ // Set the visibility of the saved SSL certificate.
+ if (savedSslIssuedToCNameString == null) {
+ savedSslCardView.setVisibility(View.GONE);
+ } else {
+ savedSslCardView.setVisibility(View.VISIBLE);
+ }
+
+ // Set the visibility of the current website SSL certificate.
+ if (DomainsActivity.sslIssuedToCName == null) { // There is no current SSL certificate.
+ // Hide the SSL certificate.
+ currentSslCardView.setVisibility(View.GONE);
+
+ // Show the instruction.
+ noCurrentWebsiteCertificateTextView.setVisibility(View.VISIBLE);
+ } else { // There is a current SSL certificate.
+ // Show the SSL certificate.
+ currentSslCardView.setVisibility(View.VISIBLE);
+
+ // Hide the instruction.
+ noCurrentWebsiteCertificateTextView.setVisibility(View.GONE);
+ }
+
+ // Set the status of the radio buttons and the card view backgrounds.
+ 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);
+
+ // 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);
+ } else {
+ currentWebsiteCertificateLinearLayout.setBackgroundResource(R.color.black_translucent_11);
+ }
+ } 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);
+ } else { // Neither SSL certificate is visible.
+ // Uncheck both radio buttons.
+ savedSslCertificateRadioButton.setChecked(false);
+ currentWebsiteCertificateRadioButton.setChecked(false);
+ }
+ } else { // An SSL certificate is not pinned.
+ // 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);
+ }
+
+ // Set the pinned IP addresses icon.
+ if (pinnedIpAddressesInt == 1) { // Pinned IP addresses is enabled. Once the minimum API >= 21 a selector can be sued as the tint mode instead of specifying different icons.
+ // Check the switch.
+ pinnedIpAddressesSwitch.setChecked(true);
+
+ // 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));
+ }
+ } else { // Pinned IP Addresses is disabled.
+ // Uncheck the switch.
+ pinnedIpAddressesSwitch.setChecked(false);
+
+ // 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));
+ }
+ }
+
+ // Populate the saved and current IP addresses.
+ savedIpAddressesTextView.setText(savedIpAddresses);
+ currentIpAddressesTextView.setText(DomainsActivity.currentIpAddresses);
+
+ // Set the initial display status of the IP addresses card views.
+ if (pinnedIpAddressesSwitch.isChecked()) { // IP addresses are pinned.
+ // Set the visibility of the saved IP addresses.
+ if (savedIpAddresses == null) { // There are no saved IP addresses.
+ savedIpAddressesCardView.setVisibility(View.GONE);
+ } else { // There are saved IP addresses.
+ savedIpAddressesCardView.setVisibility(View.VISIBLE);
+ }
+
+ // Set the visibility of the current IP addresses.
+ currentIpAddressesCardView.setVisibility(View.VISIBLE);
+
+ // Set the status of the radio buttons and the card view backgrounds.
+ if (savedIpAddressesCardView.getVisibility() == View.VISIBLE) { // The saved IP addresses are displayed.
+ // Check the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the current IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(false);
+
+ // 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 hidden.
+ // Check the current IP addresses radio button.
+ currentIpAddressesRadioButton.setChecked(true);
+
+ // Uncheck the saved IP addresses radio button.
+ savedIpAddressesRadioButton.setChecked(false);
+ }
+ } else { // IP addresses are not pinned.
+ // Hide the IP addresses card views.
+ savedIpAddressesCardView.setVisibility(View.GONE);
+ currentIpAddressesCardView.setVisibility(View.GONE);
+
+ // Uncheck the radio buttons.
+ savedIpAddressesRadioButton.setChecked(false);
+ currentIpAddressesRadioButton.setChecked(false);
+ }
+
+
+ // Set the JavaScript switch listener.
+ javaScriptSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ if (isChecked) { // JavaScript is enabled.
+ // Update the JavaScript icon.
+ javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.javascript_enabled, null));
+
+ // Enable the DOM storage `Switch`.
+ domStorageSwitch.setEnabled(true);
+
+ // Update the DOM storage icon.
+ if (domStorageSwitch.isChecked()) { // DOM storage is enabled.
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
+ } else { // DOM storage is disabled.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
+ } else {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
+ }
+ }
+ } else { // JavaScript is disabled.
+ // Update the JavaScript icon.
+ javaScriptImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.privacy_mode, null));
+
+ // Disable the DOM storage `Switch`.
+ domStorageSwitch.setEnabled(false);
+
+ // Set the DOM storage icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_night, null));
+ } else {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_ghosted_day, null));
+ }
+ }
+ });
+
+ // Set the first-party cookies switch listener.
+ firstPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ if (isChecked) { // First-party cookies are enabled.
+ // Update the first-party cookies icon.
+ firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_enabled, null));
+
+ // Enable the third-party cookies switch.
+ thirdPartyCookiesSwitch.setEnabled(true);
+
+ // Update the third-party cookies icon.
+ if (thirdPartyCookiesSwitch.isChecked()) { // Third-party cookies are enabled.
+ // Set the third-party cookies icon to be red.
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_warning, null));
+ } else { // Third-party cookies are disabled.
+ // Set the third-party cookies icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
+ } else {
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
+ }
+ }
+ } else { // First-party cookies are disabled.
+ // Update the first-party cookies icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
+ } else {
+ firstPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
+ }
+
+ // Disable the third-party cookies switch.
+ thirdPartyCookiesSwitch.setEnabled(false);
+
+ // Set the third-party cookies icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_ghosted_night, null));
+ } else {
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_ghosted_day, null));
+ }
+ }
+ });
+
+ // Set the third-party cookies switch listener.
+ thirdPartyCookiesSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) {
+ // Set the third-party cookies icon to be red.
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_warning, null));
+ } else {
+ // Update the third-party cookies icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_night, null));
+ } else {
+ thirdPartyCookiesImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.cookies_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the DOM Storage switch listener.
+ domStorageSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_enabled, null));
+ } else {
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_night, null));
+ } else {
+ domStorageImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.dom_storage_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the form data switch listener. It can be removed once the minimum API >= 26.
+ if (Build.VERSION.SDK_INT < 26) {
+ formDataSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) {
+ formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_enabled, null));
+ } else {
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_night, null));
+ } else {
+ formDataImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.form_data_disabled_day, null));
+ }
+ }
+ });
+ }
+
+ // Set the EasyList switch listener.
+ easyListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // EasyList is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
+ } else {
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
+ }
+ } else { // EasyList is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
+ } else {
+ easyListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the EasyPrivacy switch listener.
+ easyPrivacySwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // EasyPrivacy is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
+ } else {
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
+ }
+ } else { // EasyPrivacy is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
+ } else {
+ easyPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the Fanboy's Annoyance List switch listener.
+ fanboysAnnoyanceListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon and Fanboy's Social Blocking List.
+ if (isChecked) { // Fanboy's Annoyance List is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
+ } else {
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
+ }
+
+ // Disable the Fanboy's Social Blocking List switch.
+ fanboysSocialBlockingListSwitch.setEnabled(false);
+
+ // Update the Fanboy's Social Blocking List icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_night, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_ghosted_day, null));
+ }
+ } else { // Fanboy's Annoyance List is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
+ } else {
+ fanboysAnnoyanceListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
+ }
+
+ // Enable the Fanboy's Social Blocking List switch.
+ fanboysSocialBlockingListSwitch.setEnabled(true);
+
+ // Update the Fanboy's Social Blocking List icon.
+ if (fanboysSocialBlockingListSwitch.isChecked()) { // Fanboy's Social Blocking List is on.
+ // Update the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
+ }
+ } else { // Fanboy's Social Blocking List is off.
+ // Update the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
+ }
+ }
+ }
+
+ });
+
+ // Set the Fanboy's Social Blocking List switch listener.
+ fanboysSocialBlockingListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // Fanboy's Social Blocking List is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_night, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_enabled_day, null));
+ }
+ } else { // Fanboy's Social Blocking List is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_night, null));
+ } else {
+ fanboysSocialBlockingListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.social_media_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the UltraList switch listener.
+ ultraListSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // UltraList is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_night, null));
+ } else {
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_enabled_day, null));
+ }
+ } else { // UltraList is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_night, null));
+ } else {
+ ultraListImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_ads_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the UltraPrivacy switch listener.
+ ultraPrivacySwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // UltraPrivacy is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_night, null));
+ } else {
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_enabled_day, null));
+ }
+ } else { // UltraPrivacy is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_night, null));
+ } else {
+ ultraPrivacyImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_tracking_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the block all third-party requests switch listener.
+ blockAllThirdPartyRequestsSwitch.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
+ // Update the icon.
+ if (isChecked) { // Blocking all third-party requests is on.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_night, null));
+ } else {
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_enabled_day, null));
+ }
+ } else { // Blocking all third-party requests is off.
+ // Set the icon according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_night, null));
+ } else {
+ blockAllThirdPartyRequestsImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.block_all_third_party_requests_disabled_day, null));
+ }
+ }
+ });
+
+ // Set the user agent spinner listener.
+ userAgentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ // Set the new user agent.
+ switch (position) {
+ case MainWebViewActivity.DOMAINS_SYSTEM_DEFAULT_USER_AGENT:
+ // Show the user agent TextView.
+ userAgentTextView.setVisibility(View.VISIBLE);
+
+ // Hide the custom user agent EditText.
+ customUserAgentEditText.setVisibility(View.GONE);
+
+ // Set the user text.
+ switch (defaultUserAgentArrayPosition) {
+ case MainWebViewActivity.UNRECOGNIZED_USER_AGENT: // The default user agent name is not on the canonical list.
+ // This is probably because it was set in an older version of Privacy Browser before the switch to persistent user agent names.
+ userAgentTextView.setText(defaultUserAgentName);
+ break;
+
+ case MainWebViewActivity.SETTINGS_WEBVIEW_DEFAULT_USER_AGENT:
+ // Display the `WebView` default user agent.
+ userAgentTextView.setText(webViewDefaultUserAgentString);
+ break;
+
+ case MainWebViewActivity.SETTINGS_CUSTOM_USER_AGENT:
+ // Display the custom user agent.
+ userAgentTextView.setText(defaultCustomUserAgentString);
+ break;
+
+ default:
+ // Get the user agent string from the user agent data array.
+ userAgentTextView.setText(userAgentDataArray[defaultUserAgentArrayPosition]);
+ }
+ break;
+
+ case MainWebViewActivity.DOMAINS_WEBVIEW_DEFAULT_USER_AGENT:
+ // Show the user agent TextView and set the text.
+ userAgentTextView.setVisibility(View.VISIBLE);
+ userAgentTextView.setText(webViewDefaultUserAgentString);
+
+ // Hide the custom user agent EditTex.
+ customUserAgentEditText.setVisibility(View.GONE);
+ break;
+
+ case MainWebViewActivity.DOMAINS_CUSTOM_USER_AGENT:
+ // Hide the user agent TextView.