Bug 1123904 - Display original title in toolbar in reader mode. r=margaret, a=lmandel
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 19 Feb 2015 14:38:32 -0800
changeset 250064 c0030498e1c0330c637210111e2ad1210ad9de83
parent 250063 3bd3a47eca9295be77669339d5d794e69af5f5c5
child 250065 bfa75fd2520338c5c362e47863e79dfe8519712f
push id4492
push userryanvm@gmail.com
push dateMon, 23 Feb 2015 21:13:48 +0000
treeherdermozilla-beta@192f6746dc45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lmandel
bugs1123904
milestone37.0
Bug 1123904 - Display original title in toolbar in reader mode. r=margaret, a=lmandel
mobile/android/base/toolbar/ToolbarDisplayLayout.java
--- a/mobile/android/base/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/toolbar/ToolbarDisplayLayout.java
@@ -9,16 +9,17 @@ import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.List;
 
 import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.NewTabletUI;
 import org.mozilla.gecko.R;
+import org.mozilla.gecko.ReaderModeUtils;
 import org.mozilla.gecko.SiteIdentity;
 import org.mozilla.gecko.SiteIdentity.SecurityMode;
 import org.mozilla.gecko.SiteIdentity.MixedMode;
 import org.mozilla.gecko.SiteIdentity.TrackingMode;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.favicons.Favicons;
@@ -358,21 +359,24 @@ public class ToolbarDisplayLayout extend
         }
 
         // If the pref to show the title is set, use the tab's display title.
         if (!mPrefs.shouldShowUrl(mActivity) || url == null) {
             setTitle(tab.getDisplayTitle());
             return;
         }
 
-        CharSequence title = url;
+        String strippedURL = stripAboutReaderURL(url);
+
         if (mPrefs.shouldTrimUrls()) {
-            title = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url));
+            strippedURL = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(strippedURL));
         }
 
+        CharSequence title = strippedURL;
+
         final String baseDomain = tab.getBaseDomain();
         if (!TextUtils.isEmpty(baseDomain)) {
             final SpannableStringBuilder builder = new SpannableStringBuilder(title);
 
             int index = title.toString().indexOf(baseDomain);
             if (index > -1) {
                 builder.setSpan(mUrlColor, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                 builder.setSpan(tab.isPrivate() ? mPrivateDomainColor : mDomainColor,
@@ -380,16 +384,24 @@ public class ToolbarDisplayLayout extend
 
                 title = builder;
             }
         }
 
         setTitle(title);
     }
 
+    private String stripAboutReaderURL(final String url) {
+        if (!AboutPages.isAboutReader(url)) {
+            return url;
+        }
+
+        return ReaderModeUtils.getUrlFromAboutReader(url);
+    }
+
     private void updateFavicon(Tab tab) {
         if (NewTabletUI.isEnabled(getContext())) {
             // We don't display favicons in the toolbar for the new Tablet UI.
             return;
         }
 
         if (tab == null) {
             mFavicon.setImageDrawable(null);