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
--- 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());