Bug 1337459 - Update to selected tab when ToolbarDisplayLayout is ready. r=sebastian, a=lizzard
authorJim Chen <nchen@mozilla.com>
Wed, 22 Feb 2017 23:10:16 -0500
changeset 378690 e49433bc9adad6bb7ec4a809d299b19ac9459a35
parent 378689 3ee39b8e78be1b03da8d3f7282844bdc70ab3dd8
child 378691 e5d37ee6a1d0954a6add1c740143b53aa48b00bc
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, lizzard
bugs1337459
milestone53.0a2
Bug 1337459 - Update to selected tab when ToolbarDisplayLayout is ready. r=sebastian, a=lizzard We don't update ToolbarDisplayLayout when it's not ready (i.e. when it's not attached to a window yet), but when it does become ready, we should update it to the selected tab, if any.
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
@@ -14,16 +14,17 @@ import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.reader.ReaderModeUtils;
 import org.mozilla.gecko.SiteIdentity;
 import org.mozilla.gecko.SiteIdentity.MixedMode;
 import org.mozilla.gecko.SiteIdentity.SecurityMode;
 import org.mozilla.gecko.SiteIdentity.TrackingMode;
 import org.mozilla.gecko.Tab;
+import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.toolbar.BrowserToolbarTabletBase.ForwardButtonAnimation;
 import org.mozilla.gecko.Experiments;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
 import org.mozilla.gecko.widget.themed.ThemedTextView;
@@ -164,16 +165,22 @@ public class ToolbarDisplayLayout extend
     }
 
     @Override
     public void onAttachedToWindow() {
         super.onAttachedToWindow();
 
         mIsAttached = true;
 
+        final Tab selectedTab = Tabs.getInstance().getSelectedTab();
+        if (selectedTab != null) {
+            // A tab was selected before we became ready; update to that tab now.
+            updateFromTab(selectedTab, EnumSet.allOf(UpdateFlags.class));
+        }
+
         mSiteIdentityPopup.registerListeners();
 
         mSiteSecurity.setOnClickListener(new Button.OnClickListener() {
             @Override
             public void onClick(View view) {
                 mSiteIdentityPopup.show();
             }
         });