From b8facece38bcbb9805757e14d657022fadf21ddb Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Wed, 31 Oct 2012 10:59:46 -0700 Subject: [PATCH] Bug 783092: Make the animation ready for Lightweight themes. [r=lucasr, f=mfinkle] --HG-- extra : rebase_source : e6eac76d57ae7301963a710bb315a43e7e5b178f --- mobile/android/base/BrowserApp.java | 23 +++++++++++++---------- mobile/android/base/BrowserToolbar.java | 25 ++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index b1c562bc1885..70f9b0589620 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -543,24 +543,27 @@ abstract public class BrowserApp extends GeckoApp else mTabsPanel.setDrawingCacheEnabled(false); - if (hasTabsSideBar() && mTabsPanel.isShown()) { - boolean usingTextureView = mLayerView.shouldUseTextureView(); + if (mTabsPanel.isShown()) { + if (hasTabsSideBar()) { + boolean usingTextureView = mLayerView.shouldUseTextureView(); - int leftMargin = (usingTextureView ? 0 : mTabsPanel.getWidth()); - int rightMargin = (usingTextureView ? mTabsPanel.getWidth() : 0); - ((LinearLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(leftMargin, 0, rightMargin, 0); + int leftMargin = (usingTextureView ? 0 : mTabsPanel.getWidth()); + int rightMargin = (usingTextureView ? mTabsPanel.getWidth() : 0); + ((LinearLayout.LayoutParams) mGeckoLayout.getLayoutParams()).setMargins(leftMargin, 0, rightMargin, 0); - if (!usingTextureView) - mGeckoLayout.scrollTo(0, 0); + if (!usingTextureView) + mGeckoLayout.scrollTo(0, 0); + } mGeckoLayout.requestLayout(); - } - - if (!mTabsPanel.isShown()) { + } else { mBrowserToolbar.updateTabs(false); mBrowserToolbar.finishTabsAnimation(); mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); } + + if (hasTabsSideBar()) + mBrowserToolbar.adjustTabsAnimation(true); } /* Favicon methods */ diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index a16779d3a40e..94b90019245f 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -515,6 +515,9 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, PropertyAnimator.Property.TRANSLATION_X, width); + // Uses the old mTabsPaneWidth. + adjustTabsAnimation(false); + mTabsPaneWidth = width; // Only update title padding immediatelly when shrinking the browser @@ -524,6 +527,22 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, setPageActionVisibility(mStop.getVisibility() == View.VISIBLE); } + public void adjustTabsAnimation(boolean reset) { + int width = reset ? 0 : mTabsPaneWidth; + mAwesomeBarRightEdge.setTranslationX(-width); + mAwesomeBar.setTranslationX(width); + mAddressBarBg.setTranslationX(width); + mTabs.setTranslationX(width); + mTabsCount.setTranslationX(width); + mBack.setTranslationX(width); + mForward.setTranslationX(width); + mTitle.setTranslationX(width); + mFavicon.setTranslationX(width); + mSiteSecurity.setTranslationX(width); + + ((ViewGroup.MarginLayoutParams) mLayout.getLayoutParams()).leftMargin = reset ? mTabsPaneWidth : 0; + } + public void finishTabsAnimation() { setPageActionVisibility(mStop.getVisibility() == View.VISIBLE); } @@ -550,6 +569,10 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, mMenu.getBackground().setLevel(TABS_CONTRACTED); } } + + // A level change will not trigger onMeasure() for the tabs, where the path is created. + // Manually requesting a layout to re-calculate the path. + mTabs.requestLayout(); } public void setProgressVisibility(boolean visible) { @@ -582,7 +605,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, // We want title to fill the whole space available for it when there are icons // being shown on the right side of the toolbar as the icons already have some // padding in them. This is just to avoid wasting space when icons are shown. - mTitle.setPadding(0, 0, (!mShowReader && !isLoading ? mTitlePadding : 0) + mTabsPaneWidth, 0); + mTitle.setPadding(0, 0, (!mShowReader && !isLoading ? mTitlePadding : 0), 0); updateFocusOrder(); }