Bug 767980 - Use faster interpolator for the tabs pane animation (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 12 Oct 2012 12:57:06 +0100
changeset 110196 d2dabf55ea419d9c48d10920654d1cdad9e36728
parent 110195 b992d80a7998c38df81f9dc7894927493c94f8da
child 110197 2e416d28e933ab2b7991046d6d7f20025a0fca44
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmfinkle
bugs767980
milestone19.0a1
Bug 767980 - Use faster interpolator for the tabs pane animation (r=mfinkle)
mobile/android/base/BrowserApp.java
mobile/android/base/PropertyAnimator.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -29,16 +29,17 @@ import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.Interpolator;
 import android.widget.LinearLayout;
 import android.widget.Toast;
 
 import dalvik.system.DexClassLoader;
 
 import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
@@ -68,16 +69,23 @@ abstract public class BrowserApp extends
             this.icon = icon;
         }
     }
 
     private Vector<MenuItemInfo> mAddonMenuItemsCache;
 
     private PropertyAnimator mMainLayoutAnimator;
 
+    private static final Interpolator sTabsInterpolator = new Interpolator() {
+        public float getInterpolation(float t) {
+            t -= 1.0f;
+            return t * t * t * t * t + 1.0f;
+        }
+    };
+
     private FindInPageBar mFindInPageBar;
 
     // We'll ask for feedback after the user launches the app this many times.
     private static final int FEEDBACK_LAUNCH_COUNT = 10;
 
     @Override
     public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
         switch(msg) {
@@ -495,17 +503,17 @@ abstract public class BrowserApp extends
     @Override
     public void onTabsLayoutChange(int width, int height) {
         if (mMainLayoutAnimator != null)
             mMainLayoutAnimator.stop();
 
         if (mTabsPanel.isShown())
             mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
 
-        mMainLayoutAnimator = new PropertyAnimator(150);
+        mMainLayoutAnimator = new PropertyAnimator(450, sTabsInterpolator);
         mMainLayoutAnimator.setPropertyAnimationListener(this);
 
         if (hasTabsSideBar()) {
             mMainLayoutAnimator.attach(mBrowserToolbar.getLayout(),
                                        PropertyAnimator.Property.SHRINK_LEFT,
                                        width);
 
             // Set the gecko layout for sliding.
--- a/mobile/android/base/PropertyAnimator.java
+++ b/mobile/android/base/PropertyAnimator.java
@@ -18,18 +18,16 @@ import android.view.animation.Interpolat
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
 
 public class PropertyAnimator implements Runnable {
     private static final String LOGTAG = "GeckoPropertyAnimator";
 
-    private Interpolator mInterpolator;
-
     public static enum Property {
         SHRINK_LEFT,
         SHRINK_TOP,
         SLIDE_TOP,
         SLIDE_LEFT
     }
 
     private class ElementHolder {
@@ -39,27 +37,32 @@ public class PropertyAnimator implements
         int to;
     }
 
     public static interface PropertyAnimationListener {
         public void onPropertyAnimationStart();
         public void onPropertyAnimationEnd();
     }
 
+    private Interpolator mInterpolator;
     private long mStartTime;
     private long mDuration;
     private float mDurationReciprocal;
     private List<ElementHolder> mElementsList;
     private PropertyAnimationListener mListener;
     private FramePoster mFramePoster;
 
     public PropertyAnimator(int duration) {
+        this(duration, new DecelerateInterpolator());
+    }
+
+    public PropertyAnimator(int duration, Interpolator interpolator) {
         mDuration = duration;
         mDurationReciprocal = 1.0f / (float) mDuration;
-        mInterpolator = new DecelerateInterpolator();
+        mInterpolator = interpolator;
         mElementsList = new ArrayList<ElementHolder>();
         mFramePoster = FramePoster.create(this);
     }
 
     public void attach(View view, Property property, int to) {
         if (!(view instanceof ViewGroup) && (property == Property.SHRINK_LEFT ||
                                              property == Property.SHRINK_TOP)) {
             Log.i(LOGTAG, "Margin can only be animated on Viewgroups");