Moving resource declarations to the theme

Change-Id: I25977cac56bfb39f8e9ccb56587ce02d5e713c4c
diff --git a/res/drawable-xlarge/divider_vertical_dark.9.png b/res/drawable-xlarge/divider_vertical_dark.9.png
new file mode 100644
index 0000000..38b794b
--- /dev/null
+++ b/res/drawable-xlarge/divider_vertical_dark.9.png
Binary files differ
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index d5d86c9..300c9d9 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -18,8 +18,4 @@
     <!-- 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-xlarge/styles.xml b/res/values-xlarge/styles.xml
index 5bb1ed5..48923fe 100644
--- a/res/values-xlarge/styles.xml
+++ b/res/values-xlarge/styles.xml
@@ -17,14 +17,35 @@
 <resources>
     <style name="ContactBrowserTheme" parent="@android:Theme.Light.Holo">
         <item name="pressedBackground">@drawable/list_item_pressed_bg</item>
+        <item name="list_item_padding_top">0dip</item>
+        <item name="list_item_padding_right">11dip</item>
+        <item name="list_item_padding_bottom">0dip</item>
+        <item name="list_item_padding_left">4dip</item>
+        <item name="list_item_gap_between_image_and_text">8dip</item>
+        <item name="list_item_gap_between_label_and_data">5dip</item>
+        <item name="list_item_call_button_padding">14dip</item>
+        <item name="list_item_vertical_divider_margin">5dip</item>
+        <item name="list_item_presence_icon_margin">5dip</item>
+        <item name="list_item_header_text_width">56dip</item>
+        <item name="list_item_photo_size">64dip</item>
     </style>
+
     <style name="ContactPickerTheme" parent="@android:Theme.Dialog">
+        <item name="list_item_padding_top">0dip</item>
+        <item name="list_item_padding_right">11dip</item>
+        <item name="list_item_padding_bottom">0dip</item>
+        <item name="list_item_padding_left">4dip</item>
+        <item name="list_item_gap_between_image_and_text">8dip</item>
+        <item name="list_item_gap_between_label_and_data">5dip</item>
+        <item name="list_item_call_button_padding">14dip</item>
+        <item name="list_item_vertical_divider_margin">5dip</item>
+        <item name="list_item_presence_icon_margin">5dip</item>
+        <item name="list_item_header_text_width">56dip</item>
+        <item name="list_item_photo_size">64dip</item>
     </style>
+    
     <style name="ContactsPreferencesTheme" parent="@android:Theme.Dialog">
     </style>
-    <style name="JoinContactActivityTheme" parent="@android:Theme.Dialog">
-        <item name="android:windowContentOverlay">@null</item>
-    </style>
     <style name="CallDetailActivityTheme" parent="@android:Theme.Dialog">
         <item name="android:windowContentOverlay">@null</item>
     </style>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c0ce680..e995c6e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -28,22 +28,6 @@
     <dimen name="contact_shortcut_frame_width">50dip</dimen>    
     <dimen name="contact_shortcut_frame_height">56dip</dimen>    
     
-    <!-- Dimensions for a list item -->
-    <dimen name="list_item_padding_top">4dip</dimen>    
-    <dimen name="list_item_padding_right">11dip</dimen>    
-    <dimen name="list_item_padding_bottom">4dip</dimen>    
-    <dimen name="list_item_padding_left">4dip</dimen>    
-    <dimen name="list_item_gap_between_image_and_text">8dip</dimen>    
-    <dimen name="list_item_gap_between_label_and_data">5dip</dimen>    
-    <dimen name="list_item_call_button_padding">14dip</dimen>    
-    <dimen name="list_item_vertical_divider_margin">5dip</dimen>    
-    <dimen name="list_item_presence_icon_margin">5dip</dimen>    
-    <dimen name="list_item_header_text_width">56dip</dimen>    
-    <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>
 
     <!-- Size of the text in the aizy visual scroll control -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b2e9b2e..f5256ee 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -50,9 +50,6 @@
         <item name="android:src">@drawable/ic_btn_round_less</item>
     </style>
 
-    <style name="JoinContactActivityTheme" parent="android:Theme.NoTitleBar">
-        <item name="android:windowContentOverlay">@null</item>
-    </style>
     <style name="CallDetailActivityTheme" parent="android:Theme.NoTitleBar">
         <item name="android:windowContentOverlay">@null</item>
     </style>
@@ -117,15 +114,64 @@
     <declare-styleable name="ContactListItemView">
         <!-- An attribute that specifies a custom drawable for the pressed state in the contact list-->
         <attr name="pressedBackground" format="reference"/>
+
+        <attr name="list_item_padding_top" format="dimension"/>
+        <attr name="list_item_padding_right" format="dimension"/>
+        <attr name="list_item_padding_bottom" format="dimension"/>
+        <attr name="list_item_padding_left" format="dimension"/>
+        <attr name="list_item_gap_between_image_and_text" format="dimension"/>
+        <attr name="list_item_gap_between_label_and_data" format="dimension"/>
+        <attr name="list_item_call_button_padding" format="dimension"/>
+        <attr name="list_item_vertical_divider_margin" format="dimension"/>
+        <attr name="list_item_presence_icon_margin" format="dimension"/>
+        <attr name="list_item_header_text_width" format="dimension"/>
+        <attr name="list_item_photo_size" format="dimension"/>
+
+    </declare-styleable>
+
+    <declare-styleable name="MultiplePhonePickerItemView">
+        <attr name="list_item_header_chip_width" format="dimension"/>
+        <attr name="list_item_header_chip_right_margin" format="dimension"/>
+        <attr name="list_item_header_checkbox_margin" format="dimension"/>
     </declare-styleable>
 
     <style name="ContactBrowserTheme" parent="@android:Theme">
         <item name="pressedBackground">@*android:drawable/list_selector_background</item>
+        <item name="list_item_padding_top">4dip</item>
+        <item name="list_item_padding_right">11dip</item>
+        <item name="list_item_padding_bottom">4dip</item>
+        <item name="list_item_padding_left">4dip</item>
+        <item name="list_item_gap_between_image_and_text">8dip</item>
+        <item name="list_item_gap_between_label_and_data">5dip</item>
+        <item name="list_item_call_button_padding">14dip</item>
+        <item name="list_item_vertical_divider_margin">5dip</item>
+        <item name="list_item_presence_icon_margin">5dip</item>
+        <item name="list_item_header_text_width">56dip</item>
+        <item name="list_item_photo_size">56dip</item>
     </style>
 
     <style name="ContactPickerTheme" parent="@android:Theme">
+        <item name="list_item_padding_top">4dip</item>
+        <item name="list_item_padding_right">11dip</item>
+        <item name="list_item_padding_bottom">4dip</item>
+        <item name="list_item_padding_left">4dip</item>
+        <item name="list_item_gap_between_image_and_text">8dip</item>
+        <item name="list_item_gap_between_label_and_data">5dip</item>
+        <item name="list_item_call_button_padding">14dip</item>
+        <item name="list_item_vertical_divider_margin">5dip</item>
+        <item name="list_item_presence_icon_margin">5dip</item>
+        <item name="list_item_header_text_width">56dip</item>
+        <item name="list_item_photo_size">56dip</item>
+        <item name="list_item_header_chip_width">4dip</item>
+        <item name="list_item_header_chip_right_margin">4dip</item>
+        <item name="list_item_header_checkbox_margin">5dip</item>
     </style>
 
+    <style name="JoinContactActivityTheme" parent="ContactPickerTheme">
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowContentOverlay">@null</item>
+    </style>
+    
     <style name="ContactsPreferencesTheme" parent="@android:Theme">
     </style>
 </resources>
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 97a1358..e3c6001 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -22,7 +22,6 @@
 import com.android.contacts.widget.TextWithHighlightingFactory;
 
 import android.content.Context;
-import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.database.CharArrayBuffer;
 import android.database.Cursor;
@@ -95,6 +94,7 @@
     private TextView mSnippetView;
     private ImageView mPresenceIcon;
 
+    private int mDefaultPhotoViewSize;
     private int mPhotoViewWidth;
     private int mPhotoViewHeight;
     private int mLine1Height;
@@ -112,7 +112,6 @@
 
     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.
@@ -144,34 +143,33 @@
                 a.getDimensionPixelSize(android.R.styleable.Theme_listPreferredItemHeight, 0);
         a.recycle();
 
-        mPressedBackgroundDrawable = getResources().getDrawable(R.drawable.list_item_pressed_bg);
-
         a = getContext().obtainStyledAttributes(attrs,R.styleable.ContactListItemView);
         mPressedBackgroundDrawable = a.getDrawable(
                 R.styleable.ContactListItemView_pressedBackground);
-        a.recycle();
+        mVerticalDividerMargin = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_vertical_divider_margin, 0);
+        mPaddingTop = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_padding_top, 0);
+        mPaddingBottom = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_padding_bottom, 0);
+        mPaddingLeft = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_padding_left, 0);
+        mPaddingRight = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_padding_right, 0);
+        mGapBetweenImageAndText = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_gap_between_image_and_text, 0);
+        mGapBetweenLabelAndData = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_gap_between_label_and_data, 0);
+        mCallButtonPadding = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_call_button_padding, 0);
+        mPresenceIconMargin = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_presence_icon_margin, 0);
+        mHeaderTextWidth = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_header_text_width, 0);
+        mDefaultPhotoViewSize = a.getDimensionPixelOffset(
+                R.styleable.ContactListItemView_list_item_photo_size, 0);
 
-        Resources resources = context.getResources();
-        mVerticalDividerMargin =
-                resources.getDimensionPixelOffset(R.dimen.list_item_vertical_divider_margin);
-        mPaddingTop =
-                resources.getDimensionPixelOffset(R.dimen.list_item_padding_top);
-        mPaddingBottom =
-                resources.getDimensionPixelOffset(R.dimen.list_item_padding_bottom);
-        mPaddingLeft =
-                resources.getDimensionPixelOffset(R.dimen.list_item_padding_left);
-        mPaddingRight =
-                resources.getDimensionPixelOffset(R.dimen.list_item_padding_right);
-        mGapBetweenImageAndText =
-                resources.getDimensionPixelOffset(R.dimen.list_item_gap_between_image_and_text);
-        mGapBetweenLabelAndData =
-                resources.getDimensionPixelOffset(R.dimen.list_item_gap_between_label_and_data);
-        mCallButtonPadding =
-                resources.getDimensionPixelOffset(R.dimen.list_item_call_button_padding);
-        mPresenceIconMargin =
-                resources.getDimensionPixelOffset(R.dimen.list_item_presence_icon_margin);
-        mHeaderTextWidth =
-                resources.getDimensionPixelOffset(R.dimen.list_item_header_text_width);
+        a.recycle();
     }
 
     /**
@@ -297,7 +295,9 @@
             mSelectedBackgroundDrawable.setBounds(0, topBound, width, bottomBound);
         }
 
-        mPressedBackgroundDrawable.setBounds(0, topBound, width, bottomBound);
+        if (mPressedBackgroundDrawable != null) {
+            mPressedBackgroundDrawable.setBounds(0, topBound, width, bottomBound);
+        }
 
         topBound += mPaddingTop;
         bottomBound -= mPaddingBottom;
@@ -479,8 +479,7 @@
                         ViewGroup.LayoutParams.WRAP_CONTENT);
                 a.recycle();
             } else {
-                mPhotoViewWidth = mPhotoViewHeight =
-                    mContext.getResources().getDimensionPixelSize(R.dimen.list_item_photo_size);
+                mPhotoViewWidth = mPhotoViewHeight = mDefaultPhotoViewSize;
             }
         }
     }
@@ -488,13 +487,15 @@
     @Override
     protected void drawableStateChanged() {
         super.drawableStateChanged();
-        mPressedBackgroundDrawable.setState(getDrawableState());
-        invalidate();
+        if (mPressedBackgroundDrawable != null) {
+            mPressedBackgroundDrawable.setState(getDrawableState());
+            invalidate();
+        }
     }
 
     @Override
     public void dispatchDraw(Canvas canvas) {
-        if (isPressed()) {
+        if (isPressed() && mPressedBackgroundDrawable != null) {
             mPressedBackgroundDrawable.draw(canvas);
         } else if (mItemSelected) {
             mSelectedBackgroundDrawable.draw(canvas);
diff --git a/src/com/android/contacts/list/MultiplePhonePickerItemView.java b/src/com/android/contacts/list/MultiplePhonePickerItemView.java
index e865c1f..87f53bf 100644
--- a/src/com/android/contacts/list/MultiplePhonePickerItemView.java
+++ b/src/com/android/contacts/list/MultiplePhonePickerItemView.java
@@ -19,7 +19,7 @@
 import com.android.contacts.R;
 
 import android.content.Context;
-import android.content.res.Resources;
+import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.CheckBox;
@@ -44,13 +44,15 @@
 
     public MultiplePhonePickerItemView(Context context, AttributeSet attrs) {
         super(context, attrs);
-        Resources resources = context.getResources();
-        mChipWidth =
-                resources.getDimensionPixelOffset(R.dimen.list_item_header_chip_width);
-        mChipRightMargin =
-                resources.getDimensionPixelOffset(R.dimen.list_item_header_chip_right_margin);
-        mCheckBoxMargin =
-                resources.getDimensionPixelOffset(R.dimen.list_item_header_checkbox_margin);
+        TypedArray a = getContext().obtainStyledAttributes(
+                attrs, R.styleable.MultiplePhonePickerItemView);
+        mChipWidth = a.getDimensionPixelOffset(
+                R.styleable.MultiplePhonePickerItemView_list_item_header_chip_width, 0);
+        mChipRightMargin = a.getDimensionPixelOffset(
+                R.styleable.MultiplePhonePickerItemView_list_item_header_chip_right_margin, 0);
+        mCheckBoxMargin = a.getDimensionPixelOffset(
+                R.styleable.MultiplePhonePickerItemView_list_item_header_checkbox_margin, 0);
+        a.recycle();
     }
 
     @Override