Merge "Stop translating photo_file_provider_authority" into lmp-dev
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index bba8a93..dfec204 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -84,6 +84,11 @@
      */
     private static final float INTERMEDIATE_HEADER_HEIGHT_RATIO = 0.5f;
 
+    /**
+     * Maximum velocity for flings in dips per second. Picked via non-rigorous experimentation.
+     */
+    private static final float MAXIMUM_FLING_VELOCITY = 2000;
+
     private float[] mLastEventPosition = { 0, 0 };
     private VelocityTracker mVelocityTracker;
     private boolean mIsBeingDragged = false;
@@ -186,13 +191,6 @@
         void onExitFullscreen();
     }
 
-    private final AnimatorListener mHeaderExpandAnimationListener = new AnimatorListenerAdapter() {
-        @Override
-        public void onAnimationEnd(Animator animation) {
-            mPhotoTouchInterceptOverlay.setClickable(true);
-        }
-    };
-
     private final AnimatorListener mSnapToBottomListener = new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
@@ -242,7 +240,9 @@
         mScroller = new Scroller(context, sInterpolator);
         mTouchSlop = configuration.getScaledTouchSlop();
         mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
-        mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
+        mMaximumVelocity = (int)TypedValue.applyDimension(
+                TypedValue.COMPLEX_UNIT_DIP, MAXIMUM_FLING_VELOCITY,
+                getResources().getDisplayMetrics());
         mTransparentStartHeight = (int) getResources().getDimension(
                 R.dimen.quickcontact_starting_empty_height);
         mToolbarElevation = getResources().getDimension(
@@ -303,7 +303,7 @@
             mPhotoTouchInterceptOverlay.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    expandCollapseHeader();
+                    expandHeader();
                 }
             });
         }
@@ -487,27 +487,18 @@
     }
 
     /**
-     * Expand to maximum size or starting size. Disable clicks on the photo until the animation is
-     * complete.
+     * Expand to maximum size.
      */
-    private void expandCollapseHeader() {
-        mPhotoTouchInterceptOverlay.setClickable(false);
+    private void expandHeader() {
         if (getHeaderHeight() != mMaximumHeaderHeight) {
-            // Expand header
             final ObjectAnimator animator = ObjectAnimator.ofInt(this, "headerHeight",
                     mMaximumHeaderHeight);
-            animator.addListener(mHeaderExpandAnimationListener);
             animator.setDuration(ExpandingEntryCardView.DURATION_EXPAND_ANIMATION_CHANGE_BOUNDS);
             animator.start();
             // Scroll nested scroll view to its top
             if (mScrollView.getScrollY() != 0) {
                 ObjectAnimator.ofInt(mScrollView, "scrollY", -mScrollView.getScrollY()).start();
             }
-        } else if (getHeaderHeight() != mMinimumHeaderHeight) {
-            final ObjectAnimator animator = ObjectAnimator.ofInt(this, "headerHeight",
-                    mIntermediateHeaderHeight);
-            animator.addListener(mHeaderExpandAnimationListener);
-            animator.start();
         }
     }
 
@@ -839,6 +830,9 @@
     }
 
     private void fling(float velocity) {
+        if (Math.abs(mMaximumVelocity) < Math.abs(velocity)) {
+            velocity = -mMaximumVelocity * Math.signum(velocity);
+        }
         // For reasons I do not understand, scrolling is less janky when maxY=Integer.MAX_VALUE
         // then when maxY is set to an actual value.
         mScroller.fling(0, getScroll(), 0, (int) velocity, 0, 0, -Integer.MAX_VALUE,
@@ -893,17 +887,10 @@
     /**
      * Returns the minimum size that we want to compress the header to, given that we don't want to
      * allow the the ScrollView to scroll unless there is new content off of the edge of ScrollView.
-     * This value is never smaller than the current header height.
      */
     private int getFullyCompressedHeaderHeight() {
-        final int minimumScrollableHeaderHeight =
-                Math.min(Math.max(mToolbar.getLayoutParams().height - getOverflowingChildViewSize(),
+        return Math.min(Math.max(mToolbar.getLayoutParams().height - getOverflowingChildViewSize(),
                 mMinimumHeaderHeight), getMaximumScrollableHeaderHeight());
-        // It is possible that the current header height is smaller than the minimum height
-        // that can be obtained by scrolling since tapping on the contact photo collapses it.
-        // In this case, just return the current height or the minimum height.
-        return Math.max(Math.min(minimumScrollableHeaderHeight, mToolbar.getLayoutParams().height),
-                mMinimumHeaderHeight);
     }
 
     /**
@@ -963,6 +950,8 @@
         mLargeTextView.setPivotY(mLargeTextView.getHeight() / 2);
 
         final int toolbarHeight = mToolbar.getLayoutParams().height;
+        mPhotoTouchInterceptOverlay.setClickable(toolbarHeight != mMaximumHeaderHeight);
+
         if (toolbarHeight >= mMaximumHeaderHeight) {
             // Everything is full size when the header is fully expanded.
             mLargeTextView.setScaleX(1);