Bug 1268608 - Toolbar hiding should be a snappy, constant speed r?sebastian draft
authorJonathan Almeida (:jonalmeida) <jonalmeida942@gmail.com>
Thu, 23 Jun 2016 08:16:51 -0700
changeset 380943 addb84188221beaceb1663cec6fd2c7aa08a02c9
parent 379985 3c5025f98e561a20e24d97c91a9e4e0ec28015ea
child 523850 8c6782c38f52d3e2022cbacfefefe74c410d2d9f
push id21359
push userjonalmeida942@gmail.com
push dateThu, 23 Jun 2016 18:49:22 +0000
reviewerssebastian
bugs1268608
milestone50.0a1
Bug 1268608 - Toolbar hiding should be a snappy, constant speed r?sebastian By changing the Interpolator to be linear instead of decelerating, we should see an animation with constant speed. I've also reduced the animation time from 250 milliseconds to 150 to give it a snappier feel. MozReview-Commit-ID: LBsdxG0lyvX
gradle.properties
mobile/android/base/java/org/mozilla/gecko/gfx/DynamicToolbarAnimator.java
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,3 @@
 org.gradle.parallel=true
 org.gradle.daemon=true
+org.gradle.jvmargs=-Xmx3072M
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/DynamicToolbarAnimator.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/DynamicToolbarAnimator.java
@@ -8,18 +8,18 @@ package org.mozilla.gecko.gfx;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.PrefsHelper;
 import org.mozilla.gecko.util.FloatUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.graphics.PointF;
 import android.support.v4.view.ViewCompat;
 import android.util.Log;
-import android.view.animation.DecelerateInterpolator;
 import android.view.MotionEvent;
+import android.view.animation.LinearInterpolator;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
 
 public class DynamicToolbarAnimator {
@@ -31,17 +31,17 @@ public class DynamicToolbarAnimator {
         ACTION_MODE,
         FULL_SCREEN,
         CARET_DRAG
     }
 
     private final Set<PinReason> pinFlags = Collections.synchronizedSet(EnumSet.noneOf(PinReason.class));
 
     // The duration of the animation in ns
-    private static final long ANIMATION_DURATION = 250000000;
+    private static final long ANIMATION_DURATION = 150000000;
 
     private final GeckoLayerClient mTarget;
     private final List<LayerView.DynamicToolbarListener> mListeners;
 
     /* The translation to be applied to the toolbar UI view. This is the
      * distance from the default/initial location (at the top of the screen,
      * visible to the user) to where we want it to be. This variable should
      * always be between 0 (toolbar fully visible) and the height of the toolbar
@@ -58,17 +58,17 @@ public class DynamicToolbarAnimator {
     private float mLayerViewTranslation;
 
     /* This stores the maximum translation that can be applied to the toolbar
      * and layerview when scrolling. This is populated with the height of the
      * toolbar. */
     private float mMaxTranslation;
 
     /* This interpolator is used for the above mentioned animation */
-    private DecelerateInterpolator mInterpolator;
+    private LinearInterpolator mInterpolator;
 
     /* This is the proportion of the viewport rect that needs to be travelled
      * while scrolling before the translation will start taking effect.
      */
     private float SCROLL_TOOLBAR_THRESHOLD = 0.20f;
     /* The ID of the prefs listener for the scroll-toolbar threshold */
     private final PrefsHelper.PrefHandler mPrefObserver;
 
@@ -97,17 +97,17 @@ public class DynamicToolbarAnimator {
 
     /* Set to true when root content is being scrolled */
     private boolean mScrollingRootContent;
 
     public DynamicToolbarAnimator(GeckoLayerClient aTarget) {
         mTarget = aTarget;
         mListeners = new ArrayList<LayerView.DynamicToolbarListener>();
 
-        mInterpolator = new DecelerateInterpolator();
+        mInterpolator = new LinearInterpolator();
 
         // Listen to the dynamic toolbar pref
         mPrefObserver = new PrefsHelper.PrefHandlerBase() {
             @Override
             public void prefValue(String pref, int value) {
                 SCROLL_TOOLBAR_THRESHOLD = value / 100.0f;
             }
         };