Merge "Clicking in the top 56dp of QC card now expands it" into lmp-mr1-dev
diff --git a/res/layout/quickcontact_header.xml b/res/layout/quickcontact_header.xml
index 37672c7..010146b 100644
--- a/res/layout/quickcontact_header.xml
+++ b/res/layout/quickcontact_header.xml
@@ -47,7 +47,8 @@
          this view, instead of another. This will *not* cause an additional draw since the
          background is transparent.-->
     <Toolbar
-        android:layout_width="match_parent"
+        android:layout_width="wrap_content"
+        android:layout_gravity="end|top"
         android:layout_height="?android:attr/actionBarSize"
         android:background="#00000000"
         android:id="@+id/toolbar"/>
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index dcc3b61..ce654e9 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -41,6 +41,7 @@
 import android.widget.Scroller;
 import android.widget.ScrollView;
 import android.widget.TextView;
+import android.widget.Toolbar;
 
 /**
  * A custom {@link ViewGroup} that operates similarly to a {@link ScrollView}, except with multiple
@@ -103,7 +104,7 @@
     private MultiShrinkScrollerListener mListener;
     private TextView mLargeTextView;
     private View mPhotoTouchInterceptOverlay;
-    /** Contains desired location/size of the title, once the header is fully compressed */
+    /** Contains desired size & vertical offset of the title, once the header is fully compressed */
     private TextView mInvisiblePlaceholderTextView;
     private View mTitleGradientView;
     private View mActionBarGradientView;
@@ -297,6 +298,7 @@
         mTitleGradientView.setBackground(mTitleGradientDrawable);
         mActionBarGradientView = findViewById(R.id.action_bar_gradient);
         mActionBarGradientView.setBackground(mActionBarGradientDrawable);
+        mCollapsedTitleStartMargin = ((Toolbar) findViewById(R.id.toolbar)).getContentInsetStart();
 
         mPhotoTouchInterceptOverlay = findViewById(R.id.photo_touch_intercept_overlay);
         if (!mIsTwoPanel) {
@@ -1006,17 +1008,9 @@
      */
     private void calculateCollapsedLargeTitlePadding() {
         final Rect largeTextViewRect = new Rect();
-        final Rect invisiblePlaceholderTextViewRect = new Rect();
         mToolbar.getBoundsOnScreen(largeTextViewRect);
+        final Rect invisiblePlaceholderTextViewRect = new Rect();
         mInvisiblePlaceholderTextView.getBoundsOnScreen(invisiblePlaceholderTextViewRect);
-        if (isLayoutRtl()) {
-            mCollapsedTitleStartMargin = largeTextViewRect.right
-                    - invisiblePlaceholderTextViewRect.right;
-        } else {
-            mCollapsedTitleStartMargin = invisiblePlaceholderTextViewRect.left
-                    - largeTextViewRect.left;
-        }
-
         // Distance between top of toolbar to the center of the target rectangle.
         final int desiredTopToCenter = (
                 invisiblePlaceholderTextViewRect.top + invisiblePlaceholderTextViewRect.bottom)