Bug 869022 - Fade tabs button and menu away when tabs panel is open (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 07 May 2013 18:19:19 +0100
changeset 142093 9931f97194ec398983cdd68fd4c46350b9dd43e1
parent 142092 7b440e4f094ccca2ea6b46f70d996ad922f24224
child 142094 aa6a74a92890c873e81a3fd201d49292aa46d672
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs869022
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 869022 - Fade tabs button and menu away when tabs panel is open (r=mfinkle)
mobile/android/base/BrowserApp.java
mobile/android/base/BrowserToolbar.java
mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
mobile/android/base/resources/layout/browser_toolbar.xml
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -923,16 +923,17 @@ abstract public class BrowserApp extends
                                        -width);
         } else {
             mMainLayoutAnimator.attach(mMainLayout,
                                        PropertyAnimator.Property.SCROLL_Y,
                                        -height);
         }
 
         mTabsPanel.prepareTabsAnimation(mMainLayoutAnimator);
+        mBrowserToolbar.prepareTabsAnimation(areTabsShown());
 
         // If the tabs layout is animating onto the screen, pin the dynamic
         // toolbar.
         if (mLayerView != null && isDynamicToolbarEnabled()) {
             if (width > 0 && height > 0) {
                 mLayerView.getLayerMarginsAnimator().showMargins(false);
                 mLayerView.getLayerMarginsAnimator().setMarginsPinned(true);
             } else {
@@ -950,16 +951,18 @@ abstract public class BrowserApp extends
     @Override
     public void onPropertyAnimationEnd() {
         if (!areTabsShown()) {
             mTabsPanel.setVisibility(View.INVISIBLE);
             mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
         }
 
         mTabsPanel.finishTabsAnimation();
+        mBrowserToolbar.finishTabsAnimation(areTabsShown());
+
         mMainLayoutAnimator = null;
     }
 
     /* Favicon methods */
     private void loadFavicon(final Tab tab) {
         maybeCancelFaviconLoad(tab);
 
         long id = Favicons.getInstance().loadFavicon(tab.getURL(), tab.getFaviconURL(), !tab.isPrivate(),
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -81,16 +81,17 @@ public class BrowserToolbar implements T
     public ImageButton mFavicon;
     public ImageButton mStop;
     public ImageButton mSiteSecurity;
     public ImageButton mReader;
     private AnimationDrawable mProgressSpinner;
     private TabCounter mTabsCounter;
     private ImageView mShadow;
     private GeckoImageButton mMenu;
+    private GeckoImageView mMenuIcon;
     private LinearLayout mActionItemBar;
     private MenuPopup mMenuPopup;
     private List<View> mFocusOrder;
 
     final private BrowserApp mActivity;
     private Handler mHandler;
     private boolean mHasSoftMenuButton;
 
@@ -355,21 +356,24 @@ public class BrowserToolbar implements T
         mTitleSlideRight.setAnimationListener(this);
 
         final int lockAnimDuration = 300;
         mLockFadeIn.setDuration(lockAnimDuration);
         mTitleSlideLeft.setDuration(lockAnimDuration);
         mTitleSlideRight.setDuration(lockAnimDuration);
 
         mMenu = (GeckoImageButton) mLayout.findViewById(R.id.menu);
+        mMenuIcon = (GeckoImageView) mLayout.findViewById(R.id.menu_icon);
         mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items);
         mHasSoftMenuButton = !HardwareUtils.hasMenuButton();
 
         if (mHasSoftMenuButton) {
             mMenu.setVisibility(View.VISIBLE);
+            mMenuIcon.setVisibility(View.VISIBLE);
+
             mMenu.setOnClickListener(new Button.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     mActivity.openOptionsMenu();
                 }
             });
         }
 
@@ -949,16 +953,48 @@ public class BrowserToolbar implements T
         mShowReader = showReader;
         setPageActionVisibility(mStop.getVisibility() == View.VISIBLE);
     }
 
     public void requestFocusFromTouch() {
         mLayout.requestFocusFromTouch();
     }
 
+    public void prepareTabsAnimation(boolean tabsAreShown) {
+        if (!tabsAreShown) {
+            return;
+        }
+
+        ViewHelper.setAlpha(mTabsCounter, 0.0f);
+
+        if (mHasSoftMenuButton && !HardwareUtils.isTablet()) {
+            ViewHelper.setAlpha(mMenuIcon, 0.0f);
+        }
+    }
+
+    public void finishTabsAnimation(boolean tabsAreShown) {
+        if (tabsAreShown) {
+            return;
+        }
+
+        PropertyAnimator animator = new PropertyAnimator(150);
+
+        animator.attach(mTabsCounter,
+                        PropertyAnimator.Property.ALPHA,
+                        1.0f);
+
+        if (mHasSoftMenuButton && !HardwareUtils.isTablet()) {
+            animator.attach(mMenuIcon,
+                            PropertyAnimator.Property.ALPHA,
+                            1.0f);
+        }
+
+        animator.start();
+    }
+
     public void updateBackButton(boolean enabled) {
          Drawable drawable = mBack.getDrawable();
          if (drawable != null)
              drawable.setAlpha(enabled ? 255 : 77);
 
          mBack.setEnabled(enabled);
     }
 
@@ -1104,16 +1140,17 @@ public class BrowserToolbar implements T
             updateForwardButton(tab.canDoForward());
 
             final boolean isPrivate = tab.isPrivate();
             mAddressBarBg.setPrivateMode(isPrivate);
             mLayout.setPrivateMode(isPrivate);
             mTabs.setPrivateMode(isPrivate);
             mTitle.setPrivateMode(isPrivate);
             mMenu.setPrivateMode(isPrivate);
+            mMenuIcon.setPrivateMode(isPrivate);
 
             if (mBack instanceof BackButton)
                 ((BackButton) mBack).setPrivateMode(isPrivate);
 
             if (mForward instanceof ForwardButton)
                 ((ForwardButton) mForward).setPrivateMode(isPrivate);
         }
     }
--- a/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
@@ -128,24 +128,28 @@
                   android:orientation="horizontal"
                   android:layout_toLeftOf="@id/menu"
                   android:layout_alignWithParentIfMissing="true"/>
 
     <Gecko.ImageButton android:id="@+id/menu"
                        style="@style/AddressBar.ImageButton"
                        android:layout_width="56dip"
                        android:layout_alignParentRight="true"
-                       android:gravity="center_vertical"
-                       android:src="@drawable/menu_level"
                        android:contentDescription="@string/menu"
                        android:background="@drawable/action_bar_button"
-                       android:paddingLeft="14dip"
-                       android:paddingRight="14dip"
                        android:visibility="gone"/>
 
+    <Gecko.ImageView android:id="@+id/menu_icon"
+                     style="@style/AddressBar.ImageButton"
+                     android:layout_alignLeft="@id/menu"
+                     android:layout_alignRight="@id/menu"
+                     android:gravity="center_vertical"
+                     android:src="@drawable/menu_level"
+                     android:visibility="gone"/>
+
     <ImageView android:id="@+id/shadow"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:layout_alignParentBottom="true"
                android:background="@drawable/address_bar_bg_shadow_repeat"
                android:visibility="gone"/>
 
 </org.mozilla.gecko.BrowserToolbarLayout>
--- a/mobile/android/base/resources/layout/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout/browser_toolbar.xml
@@ -54,22 +54,28 @@
 
     <LinearLayout android:id="@+id/menu_items"
                   style="@style/AddressBar.ImageButton.Unused"/>
 
     <Gecko.ShapedButton android:id="@+id/menu"
                         style="@style/AddressBar.ImageButton"
                         android:layout_width="48dip"
                         android:layout_alignParentRight="true"
-                        android:gravity="center_vertical"
-                        android:src="@drawable/menu_level"
                         android:contentDescription="@string/menu"
                         android:background="@drawable/shaped_button"
                         android:visibility="gone"/>
 
+    <Gecko.ImageView android:id="@+id/menu_icon"
+                     style="@style/AddressBar.ImageButton"
+                     android:layout_alignLeft="@id/menu"
+                     android:layout_alignRight="@id/menu"
+                     android:gravity="center_vertical"
+                     android:src="@drawable/menu_level"
+                     android:visibility="gone"/>
+
     <Gecko.ShapedButton android:id="@+id/tabs"
                         style="@style/AddressBar.ImageButton"
                         android:layout_width="72dip"
                         android:layout_toLeftOf="@id/menu"
                         android:layout_alignWithParentIfMissing="true"
                         gecko:curveTowards="right"
                         android:background="@drawable/shaped_button"
                         android:gravity="center_vertical"