X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FUrlHelper.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FUrlHelper.kt;h=a375e0a99e3496a7717f36cad19ad881833f2574;hp=44a2be8cc5c4238890aae134fc25c0abe4cc3f20;hb=8cb28870438dccf6d1d62e97be48b5523ed003b3;hpb=2eecbd37661b76d1bcd4020d6218ea6641917527 diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/UrlHelper.kt b/app/src/main/java/com/stoutner/privacybrowser/helpers/UrlHelper.kt index 44a2be8c..a375e0a9 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/UrlHelper.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/UrlHelper.kt @@ -227,12 +227,24 @@ object UrlHelper { // De-emphasize subdomains. if (penultimateDotIndex > 0) // There is more than one subdomain in the domain name. urlEditText.text.setSpan(initialGrayColorSpan, 7, penultimateDotIndex + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE) - } else if (urlString.startsWith("https://")) { // The protocol is encrypted. + } else if (urlString.startsWith("https://") || urlString.startsWith("view-source:https://")) { // The protocol is encrypted. // De-emphasize the protocol of connections that are encrypted. if (penultimateDotIndex > 0) // There is more than one subdomain in the domain name. De-emphasize the protocol and the additional subdomains. urlEditText.text.setSpan(initialGrayColorSpan, 0, penultimateDotIndex + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE) else // There is only one subdomain in the domain name. De-emphasize only the protocol. urlEditText.text.setSpan(initialGrayColorSpan, 0, 8, Spanned.SPAN_INCLUSIVE_INCLUSIVE) + } else if (urlString.startsWith("view-source:http://")) { // An insecure source is being viewed. + // Check to see if subdomains should be de-emphasized. + if (penultimateDotIndex > 0) { // There are subdomains that should be de-emphasized. + // De-emphasize the `view-source:` text. + urlEditText.text.setSpan(initialGrayColorSpan, 0, penultimateDotIndex + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE) + } else { // There are no subdomains that need to be de-emphasized. + // De-emphasize the `view-source:` text. + urlEditText.text.setSpan(initialGrayColorSpan, 0, 11, Spanned.SPAN_INCLUSIVE_INCLUSIVE) + } + + // Highlight the protocol in red. + urlEditText.text.setSpan(redColorSpan, 12, 19, Spanned.SPAN_INCLUSIVE_INCLUSIVE) } // De-emphasize the text after the domain name.