Bug 889621 - Fade in homepager while expanding URL bar on tap (r=sriram)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 26 Jul 2013 12:46:28 +0100
changeset 143449 f803324a9344e6d22d6df82c01376deb035391c6
parent 143448 3c979362cc69e0de2d1cf706753c942192e6fb80
child 143450 7121a3b23982bf3f5592962c2e1b08c3deb4c1ab
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs889621
milestone25.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 889621 - Fade in homepager while expanding URL bar on tap (r=sriram)
mobile/android/base/BrowserApp.java
mobile/android/base/BrowserToolbar.java
mobile/android/base/home/HomePager.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1308,18 +1308,23 @@ abstract public class BrowserApp extends
                 // whenever the user performs a search.
                 url = tab.getUserSearch();
                 if (TextUtils.isEmpty(url)) {
                     url = tab.getURL();
                 }
             }
         }
 
-        mBrowserToolbar.startEditing(url);
-        animateShowHomePager(HomePager.Page.VISITED);
+        final PropertyAnimator animator = new PropertyAnimator(300);
+        animator.setUseHardwareLayer(false);
+
+        mBrowserToolbar.startEditing(url, animator);
+        showHomePagerWithAnimator(HomePager.Page.VISITED, animator);
+
+        animator.start();
     }
 
     void commitEditingMode() {
         if (!mBrowserToolbar.isEditing()) {
             return;
         }
 
         final String url = mBrowserToolbar.commitEdit();
@@ -1347,40 +1352,35 @@ abstract public class BrowserApp extends
         if (TextUtils.isEmpty(searchTerm)) {
             hideBrowserSearch();
         } else {
             showBrowserSearch();
             mBrowserSearch.filter(searchTerm, handler);
         }
     }
 
-    private void animateShowHomePager(HomePager.Page page) {
-        showHomePagerWithAnimation(true, page);
+    private void showHomePager(HomePager.Page page) {
+        showHomePagerWithAnimator(page, null);
     }
 
-    private void showHomePager(HomePager.Page page) {
-        showHomePagerWithAnimation(false, page);
-    }
-
-    private void showHomePagerWithAnimation(boolean animate, HomePager.Page page) {
+    private void showHomePagerWithAnimator(HomePager.Page page, PropertyAnimator animator) {
         if (mHomePager.isVisible()) {
             return;
         }
 
         // Refresh toolbar height to possibly restore the toolbar padding
         refreshToolbarHeight();
 
         // Show the toolbar before hiding about:home so the
         // onMetricsChanged callback still works.
         if (isDynamicToolbarEnabled() && mLayerView != null) {
             mLayerView.getLayerMarginsAnimator().showMargins(true);
         }
 
-        // FIXME: do animation if animate is true
-        mHomePager.show(getSupportFragmentManager(), page);
+        mHomePager.show(getSupportFragmentManager(), page, animator);
     }
 
     private void animateHideHomePager() {
         hideHomePagerWithAnimation(true);
     }
 
     private void hideHomePager() {
         hideHomePagerWithAnimation(false);
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -1199,88 +1199,84 @@ public class BrowserToolbar extends Geck
         mUrlDisplayContainer.setVisibility(View.VISIBLE);
         mUrlEditContainer.setVisibility(View.GONE);
     }
 
     public boolean isEditing() {
         return isSelected();
     }
 
-    public void startEditing(String url) {
+    public void startEditing(String url, PropertyAnimator animator) {
         if (isEditing()) {
             return;
         }
 
         mUrlEditText.setText(url != null ? url : "");
 
         // This animation doesn't make much sense in a sidebar UI
         if (HardwareUtils.isTablet()) {
             setSelected(true);
             showUrlEditContainer();
             return;
         }
 
         if (mAnimatingEntry)
             return;
 
-        final PropertyAnimator contentAnimator = new PropertyAnimator(250);
-        contentAnimator.setUseHardwareLayer(false);
-
         final int entryTranslation = getUrlBarEntryTranslation();
         final int curveTranslation = getUrlBarCurveTranslation();
 
         // Keep the entry highlighted during the animation
         setSelected(true);
 
         // Hide page actions/stop buttons immediately
         ViewHelper.setAlpha(mPageActionLayout, 0);
         ViewHelper.setAlpha(mStop, 0);
 
         // Slide the right side elements of the toolbar
 
         if (mUrlBarRightEdge != null) {
-            contentAnimator.attach(mUrlBarRightEdge,
-                                   PropertyAnimator.Property.TRANSLATION_X,
-                                   entryTranslation);
+            animator.attach(mUrlBarRightEdge,
+                            PropertyAnimator.Property.TRANSLATION_X,
+                            entryTranslation);
         }
 
-        contentAnimator.attach(mTabs,
-                               PropertyAnimator.Property.TRANSLATION_X,
-                               curveTranslation);
-        contentAnimator.attach(mTabsCounter,
-                               PropertyAnimator.Property.TRANSLATION_X,
-                               curveTranslation);
-        contentAnimator.attach(mActionItemBar,
-                               PropertyAnimator.Property.TRANSLATION_X,
-                               curveTranslation);
+        animator.attach(mTabs,
+                        PropertyAnimator.Property.TRANSLATION_X,
+                        curveTranslation);
+        animator.attach(mTabsCounter,
+                        PropertyAnimator.Property.TRANSLATION_X,
+                        curveTranslation);
+        animator.attach(mActionItemBar,
+                        PropertyAnimator.Property.TRANSLATION_X,
+                        curveTranslation);
 
         if (mHasSoftMenuButton) {
-            contentAnimator.attach(mMenu,
-                                   PropertyAnimator.Property.TRANSLATION_X,
-                                   curveTranslation);
+            animator.attach(mMenu,
+                            PropertyAnimator.Property.TRANSLATION_X,
+                            curveTranslation);
 
-            contentAnimator.attach(mMenuIcon,
-                                   PropertyAnimator.Property.TRANSLATION_X,
-                                   curveTranslation);
+            animator.attach(mMenuIcon,
+                            PropertyAnimator.Property.TRANSLATION_X,
+                            curveTranslation);
         }
 
-        contentAnimator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
+        animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
             @Override
             public void onPropertyAnimationStart() {
             }
 
             @Override
             public void onPropertyAnimationEnd() {
                 showUrlEditContainer();
                 mAnimatingEntry = false;
             }
         });
 
         mAnimatingEntry = true;
-        contentAnimator.start();
     }
 
     /**
      * Exits edit mode without updating the toolbar title.
      *
      * @return the url that was entered
      */
     public String cancelEdit() {
--- a/mobile/android/base/home/HomePager.java
+++ b/mobile/android/base/home/HomePager.java
@@ -1,16 +1,18 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
 import org.mozilla.gecko.R;
+import org.mozilla.gecko.animation.PropertyAnimator;
+import org.mozilla.gecko.animation.ViewHelper;
 
 import android.content.Context;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentStatePagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.util.AttributeSet;
@@ -54,29 +56,37 @@ public class HomePager extends ViewPager
         mContext = context;
     }
 
     /**
      * Loads and initializes the pager.
      *
      * @param fm FragmentManager for the adapter
      */
-    public void show(FragmentManager fm, Page page) {
+    public void show(FragmentManager fm, Page page, PropertyAnimator animator) {
         mLoaded = true;
         TabsAdapter adapter = new TabsAdapter(fm);
 
         // Add the pages to the adapter in order.
         adapter.addTab(Page.VISITED, VisitedPage.class, null, getContext().getString(R.string.visited_title));
         adapter.addTab(Page.BOOKMARKS, BookmarksPage.class, null, getContext().getString(R.string.bookmarks_title));
         adapter.addTab(Page.READING_LIST, ReadingListPage.class, null, getContext().getString(R.string.reading_list));
 
         setAdapter(adapter);
 
         setCurrentItem(adapter.getItemPosition(page), false);
         setVisibility(VISIBLE);
+
+        if (animator != null) {
+            ViewHelper.setAlpha(this, 0.0f);
+
+            animator.attach(this,
+                            PropertyAnimator.Property.ALPHA,
+                            1.0f);
+        }
     }
 
     /**
      * Hides the pager and removes all child fragments.
      */
     public void hide() {
         mLoaded = false;
         setVisibility(GONE);