Bigger pictures in the two-pane list

Change-Id: I8bd95f6d5efb59443e96ee295fbe69e14921f7e1
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index 7f1edf1..d5d86c9 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -17,4 +17,9 @@
 <resources>
     <!-- Size of the text in the aizy visual scroll control -->
     <dimen name="aizy_text_size">12sp</dimen>
+
+    <dimen name="list_item_padding_top">0dip</dimen>
+    <dimen name="list_item_padding_bottom">0dip</dimen>
+    <dimen name="list_item_photo_size">64dip</dimen>
+
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b8b06ff..c0ce680 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -42,6 +42,7 @@
     <dimen name="list_item_header_chip_width">4dip</dimen>
     <dimen name="list_item_header_chip_right_margin">4dip</dimen>
     <dimen name="list_item_header_checkbox_margin">5dip</dimen>
+    <dimen name="list_item_photo_size">56dip</dimen>
 
     <dimen name="aggregation_suggestion_icon_size">40dip</dimen>
 
diff --git a/src/com/android/contacts/list/ContactListAdapter.java b/src/com/android/contacts/list/ContactListAdapter.java
index 8cf47a6..c6ceb18 100644
--- a/src/com/android/contacts/list/ContactListAdapter.java
+++ b/src/com/android/contacts/list/ContactListAdapter.java
@@ -182,6 +182,7 @@
         final ContactListItemView view = new ContactListItemView(context, null);
         view.setUnknownNameText(mUnknownNameText);
         view.setTextWithHighlightingFactory(getTextWithHighlightingFactory());
+        view.setQuickContactEnabled(isQuickContactEnabled());
         return view;
     }
 
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 287b796..af429e4 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -83,6 +83,7 @@
     private int mHeaderBackgroundHeight;
     private TextView mHeaderTextView;
 
+    private boolean mQuickContactEnabled = true;
     private QuickContactBadge mQuickContact;
     private ImageView mPhotoView;
     private TextView mNameTextView;
@@ -110,6 +111,7 @@
 
     private CharSequence mUnknownNameText;
 
+
     /**
      * Special class to allow the parent to be pressed without being pressed itself.
      * This way the line of a tab can be pressed, but the image itself is not.
@@ -179,6 +181,10 @@
         mUnknownNameText = unknownNameText;
     }
 
+    public void setQuickContactEnabled(boolean flag) {
+        mQuickContactEnabled = flag;
+    }
+
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         // We will match parent's width and wrap content vertically, but make sure
@@ -229,7 +235,13 @@
 
         ensurePhotoViewSize();
 
-        height = Math.max(height, mPhotoViewHeight);
+        height = Math.max(height, mPhotoViewHeight + mPaddingBottom + mPaddingTop);
+
+        if (mHorizontalDividerVisible) {
+            ensureHorizontalDivider();
+            height += mHorizontalDividerHeight;
+        }
+
         height = Math.max(height, mPreferredHeight);
 
         if (mHeaderVisible) {
@@ -240,11 +252,6 @@
             height += mHeaderBackgroundHeight;
         }
 
-        if (mHorizontalDividerVisible) {
-            ensureHorizontalDivider();
-            height += mHorizontalDividerHeight;
-        }
-
         setMeasuredDimension(width, height);
     }
 
@@ -255,6 +262,7 @@
 
         // Determine the vertical bounds by laying out the header first.
         int topBound = 0;
+        int bottomBound = height;
 
         if (mHeaderVisible) {
             mHeaderBackgroundDrawable.setBounds(
@@ -266,19 +274,6 @@
             topBound += mHeaderBackgroundHeight;
         }
 
-        if (mItemSelected) {
-            ensureCheckedBackgroundDivider();
-            mSelectedBackgroundDrawable.setBounds(0, topBound, width, height);
-        }
-
-        // Positions of views on the left are fixed and so are those on the right side.
-        // The stretchable part of the layout is in the middle.  So, we will start off
-        // by laying out the left and right sides. Then we will allocate the remainder
-        // to the text fields in the middle.
-
-        int leftBound = layoutLeftSide(height, topBound, mPaddingLeft);
-        int rightBound = layoutRightSide(height, topBound, right);
-
         if (mHorizontalDividerVisible) {
             ensureHorizontalDivider();
             mHorizontalDividerDrawable.setBounds(
@@ -286,11 +281,24 @@
                     height - mHorizontalDividerHeight,
                     width,
                     height);
+            bottomBound -= mHorizontalDividerHeight;
+        }
+
+        if (mItemSelected) {
+            ensureCheckedBackgroundDivider();
+            mSelectedBackgroundDrawable.setBounds(0, topBound, width, bottomBound);
         }
 
         topBound += mPaddingTop;
+        bottomBound -= mPaddingBottom;
 
-        int bottomBound = height - mPaddingBottom;
+        // Positions of views on the left are fixed and so are those on the right side.
+        // The stretchable part of the layout is in the middle.  So, we will start off
+        // by laying out the left and right sides. Then we will allocate the remainder
+        // to the text fields in the middle.
+
+        int leftBound = layoutLeftSide(height, topBound, bottomBound, mPaddingLeft);
+        int rightBound = layoutRightSide(height, topBound, right);
 
         // Text lines, centered vertically
         rightBound -= mPaddingRight;
@@ -343,11 +351,11 @@
      *
      * @return new left boundary
      */
-    protected int layoutLeftSide(int height, int topBound, int leftBound) {
+    protected int layoutLeftSide(int height, int topBound, int bottomBound, int leftBound) {
         View photoView = mQuickContact != null ? mQuickContact : mPhotoView;
         if (photoView != null) {
             // Center the photo vertically
-            int photoTop = topBound + (height - topBound - mPhotoViewHeight) / 2;
+            int photoTop = topBound + (bottomBound - topBound - mPhotoViewHeight) / 2;
             photoView.layout(
                     leftBound,
                     photoTop,
@@ -449,16 +457,21 @@
      */
     private void ensurePhotoViewSize() {
         if (mPhotoViewWidth == 0 && mPhotoViewHeight == 0) {
-            TypedArray a = mContext.obtainStyledAttributes(null,
-                    com.android.internal.R.styleable.ViewGroup_Layout,
-                    QUICK_CONTACT_BADGE_STYLE, 0);
-            mPhotoViewWidth = a.getLayoutDimension(
-                    android.R.styleable.ViewGroup_Layout_layout_width,
-                    ViewGroup.LayoutParams.WRAP_CONTENT);
-            mPhotoViewHeight = a.getLayoutDimension(
-                    android.R.styleable.ViewGroup_Layout_layout_height,
-                    ViewGroup.LayoutParams.WRAP_CONTENT);
-            a.recycle();
+            if (mQuickContactEnabled) {
+                TypedArray a = mContext.obtainStyledAttributes(null,
+                        com.android.internal.R.styleable.ViewGroup_Layout,
+                        QUICK_CONTACT_BADGE_STYLE, 0);
+                mPhotoViewWidth = a.getLayoutDimension(
+                        android.R.styleable.ViewGroup_Layout_layout_width,
+                        ViewGroup.LayoutParams.WRAP_CONTENT);
+                mPhotoViewHeight = a.getLayoutDimension(
+                        android.R.styleable.ViewGroup_Layout_layout_height,
+                        ViewGroup.LayoutParams.WRAP_CONTENT);
+                a.recycle();
+            } else {
+                mPhotoViewWidth = mPhotoViewHeight =
+                    mContext.getResources().getDimensionPixelSize(R.dimen.list_item_photo_size);
+            }
         }
     }
 
@@ -516,6 +529,9 @@
      * Returns the quick contact badge, creating it if necessary.
      */
     public QuickContactBadge getQuickContact() {
+        if (!mQuickContactEnabled) {
+            throw new IllegalStateException("QuickContact is disabled for this view");
+        }
         if (mQuickContact == null) {
             mQuickContact = new QuickContactBadge(mContext, null, QUICK_CONTACT_BADGE_STYLE);
             mQuickContact.setExcludeMimes(new String[] { Contacts.CONTENT_ITEM_TYPE });
@@ -529,7 +545,11 @@
      */
     public ImageView getPhotoView() {
         if (mPhotoView == null) {
-            mPhotoView = new ImageView(mContext, null, QUICK_CONTACT_BADGE_STYLE);
+            if (mQuickContactEnabled) {
+                mPhotoView = new ImageView(mContext, null, QUICK_CONTACT_BADGE_STYLE);
+            } else {
+                mPhotoView = new ImageView(mContext);
+            }
             // Quick contact style used above will set a background - remove it
             mPhotoView.setBackgroundDrawable(null);
             addView(mPhotoView);
diff --git a/src/com/android/contacts/list/MultiplePhonePickerItemView.java b/src/com/android/contacts/list/MultiplePhonePickerItemView.java
index 4801d33..e865c1f 100644
--- a/src/com/android/contacts/list/MultiplePhonePickerItemView.java
+++ b/src/com/android/contacts/list/MultiplePhonePickerItemView.java
@@ -67,13 +67,13 @@
     }
 
     @Override
-    protected int layoutLeftSide(int height, int topBound, int leftBound) {
+    protected int layoutLeftSide(int height, int topBound, int bottomBound, int leftBound) {
         if (mChipView != null) {
             mChipView.layout(leftBound, topBound, leftBound + mChipWidth, height);
             leftBound += mChipWidth + mChipRightMargin;
         }
 
-        return super.layoutLeftSide(height, topBound, leftBound);
+        return super.layoutLeftSide(height, topBound, bottomBound, leftBound);
     }
 
     @Override