Bug 1272340 - ToolbarDisplayLayout: Handle about:reader URLs. r=margaret draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 13 May 2016 10:57:57 +0200
changeset 366763 d23c2d2d2392be9ae6e9fdaf8d560d5af07f387d
parent 366761 943ca7ad1ea35e01a6ba6bfa0a4f3896f1150e15
child 520850 dabe56ed80ad75fd92d713410c8a7b8544a33e3f
push id18066
push users.kaspari@gmail.com
push dateFri, 13 May 2016 09:32:34 +0000
reviewersmargaret
bugs1272340
milestone49.0a1
Bug 1272340 - ToolbarDisplayLayout: Handle about:reader URLs. r=margaret This patch changes two things: * Check if the URL is http/https after stripping the about:reader URL. * Always call updateAndColorTitleFromFullURL() as fallback for URL formatting (like in previous versions) MozReview-Commit-ID: 1Zgf12FsOQe
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -260,43 +260,41 @@ public class ToolbarDisplayLayout extend
             final SpannableStringBuilder builder = new SpannableStringBuilder(title);
             builder.setSpan(mBlockedColorSpan, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
 
             setTitle(builder);
             setContentDescription(null);
             return;
         }
 
-        final boolean isHttpOrHttps = StringUtils.isHttpOrHttps(url);
         final String baseDomain = tab.getBaseDomain();
 
         String strippedURL = stripAboutReaderURL(url);
 
+        final boolean isHttpOrHttps = StringUtils.isHttpOrHttps(strippedURL);
+
         if (mPrefs.shouldTrimUrls()) {
             strippedURL = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(strippedURL));
         }
 
         // This value is not visible to screen readers but we rely on it when running UI tests. Screen
         // readers will instead focus BrowserToolbar and read the "base domain" from there. UI tests
         // will read the content description to obtain the full URL for performing assertions.
         setContentDescription(strippedURL);
 
         final SiteIdentity siteIdentity = tab.getSiteIdentity();
         if (siteIdentity.hasOwner()) {
             // Show Owner of EV certificate as title
             updateTitleFromSiteIdentity(siteIdentity);
         } else if (isHttpOrHttps && !HardwareUtils.isTablet() && !TextUtils.isEmpty(baseDomain)) {
             // Show just the base domain as title
             setTitle(baseDomain);
-        } else if (isHttpOrHttps) {
+        } else {
             // Display full URL with base domain highlighted as title
             updateAndColorTitleFromFullURL(strippedURL, baseDomain, tab.isPrivate());
-        } else {
-            // Not http(s): Just show the full URL as title
-            setTitle(url);
         }
     }
 
     private void updateTitleFromSiteIdentity(SiteIdentity siteIdentity) {
         final String title;
 
         if (siteIdentity.hasCountry()) {
             title = String.format("%s (%s)", siteIdentity.getOwner(), siteIdentity.getCountry());