Merge "Resolving issue with the wrong contact displayed in search results."
diff --git a/res/drawable-hdpi/change_photo_box_focused_holo_light.9.png b/res/drawable-hdpi/change_photo_box_focused_holo_light.9.png
new file mode 100644
index 0000000..5254473
--- /dev/null
+++ b/res/drawable-hdpi/change_photo_box_focused_holo_light.9.png
Binary files differ
diff --git a/res/drawable-hdpi/change_photo_box_normal_holo_light.9.png b/res/drawable-hdpi/change_photo_box_normal_holo_light.9.png
new file mode 100644
index 0000000..f026cc8
--- /dev/null
+++ b/res/drawable-hdpi/change_photo_box_normal_holo_light.9.png
Binary files differ
diff --git a/res/drawable-hdpi/change_photo_box_pressed_holo_light.9.png b/res/drawable-hdpi/change_photo_box_pressed_holo_light.9.png
new file mode 100644
index 0000000..a0770ea
--- /dev/null
+++ b/res/drawable-hdpi/change_photo_box_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-hdpi/contact_picture_border_highlight.9.png b/res/drawable-hdpi/contact_picture_border_highlight.9.png
deleted file mode 100755
index 776d614..0000000
--- a/res/drawable-hdpi/contact_picture_border_highlight.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/contact_picture_border_normal.9.png b/res/drawable-hdpi/contact_picture_border_normal.9.png
deleted file mode 100755
index be67b1a..0000000
--- a/res/drawable-hdpi/contact_picture_border_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/contact_picture_border_pressed.9.png b/res/drawable-hdpi/contact_picture_border_pressed.9.png
deleted file mode 100755
index 32fbaa5..0000000
--- a/res/drawable-hdpi/contact_picture_border_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_add_picture.png b/res/drawable-hdpi/ic_menu_add_picture.png
deleted file mode 100755
index 85faf1c..0000000
--- a/res/drawable-hdpi/ic_menu_add_picture.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/change_photo_box_focused_holo_light.9.png b/res/drawable-mdpi/change_photo_box_focused_holo_light.9.png
new file mode 100644
index 0000000..36c8b87
--- /dev/null
+++ b/res/drawable-mdpi/change_photo_box_focused_holo_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/change_photo_box_holo_light.9.png b/res/drawable-mdpi/change_photo_box_holo_light.9.png
deleted file mode 100644
index 375ed4a..0000000
--- a/res/drawable-mdpi/change_photo_box_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/change_photo_box_normal_holo_light.9.png b/res/drawable-mdpi/change_photo_box_normal_holo_light.9.png
new file mode 100644
index 0000000..d380b40
--- /dev/null
+++ b/res/drawable-mdpi/change_photo_box_normal_holo_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/change_photo_box_pressed_holo_light.9.png b/res/drawable-mdpi/change_photo_box_pressed_holo_light.9.png
new file mode 100644
index 0000000..21d8a96
--- /dev/null
+++ b/res/drawable-mdpi/change_photo_box_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/contact_picture_border_highlight.9.png b/res/drawable-mdpi/contact_picture_border_highlight.9.png
deleted file mode 100644
index c48b83f..0000000
--- a/res/drawable-mdpi/contact_picture_border_highlight.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/contact_picture_border_normal.9.png b/res/drawable-mdpi/contact_picture_border_normal.9.png
deleted file mode 100644
index 84bfad5..0000000
--- a/res/drawable-mdpi/contact_picture_border_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/contact_picture_border_pressed.9.png b/res/drawable-mdpi/contact_picture_border_pressed.9.png
deleted file mode 100644
index d5328f3..0000000
--- a/res/drawable-mdpi/contact_picture_border_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_add_picture.png b/res/drawable-mdpi/ic_menu_add_picture.png
deleted file mode 100644
index 35f10b8..0000000
--- a/res/drawable-mdpi/ic_menu_add_picture.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/btn_contact_picture.xml b/res/drawable/change_photo_box_holo_light.xml
similarity index 74%
rename from res/drawable/btn_contact_picture.xml
rename to res/drawable/change_photo_box_holo_light.xml
index 643231a..f08beb0 100644
--- a/res/drawable/btn_contact_picture.xml
+++ b/res/drawable/change_photo_box_holo_light.xml
@@ -16,11 +16,11 @@
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_window_focused="false"
-        android:drawable="@drawable/contact_picture_border_normal" />
+        android:drawable="@drawable/change_photo_box_normal_holo_light" />
     <item android:state_pressed="true"
-        android:drawable="@drawable/contact_picture_border_pressed" />
+        android:drawable="@drawable/change_photo_box_pressed_holo_light" />
     <item android:state_focused="true"
-        android:drawable="@drawable/contact_picture_border_highlight" />
+        android:drawable="@drawable/change_photo_box_focused_holo_light" />
     <item
-         android:drawable="@drawable/contact_picture_border_normal" />
+        android:drawable="@drawable/change_photo_box_normal_holo_light" />
 </selector>
diff --git a/res/layout-xlarge/item_photo_editor.xml b/res/layout-xlarge/item_photo_editor.xml
deleted file mode 100644
index 35ade24..0000000
--- a/res/layout-xlarge/item_photo_editor.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-  
-          http://www.apache.org/licenses/LICENSE-2.0
-  
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<com.android.contacts.views.editor.PhotoEditorView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="@dimen/edit_photo_size"
-    android:layout_height="@dimen/edit_photo_size"
-    android:clickable="true"
-    android:focusable="true"
-    android:src="@drawable/ic_menu_add_picture"
-    android:cropToPadding="true"
-    android:scaleType="center"
-    android:background="@drawable/btn_contact_picture"
-    android:contentDescription="@string/description_contact_photo"
-    android:gravity="center" />
diff --git a/res/layout/item_photo_editor.xml b/res/layout/item_photo_editor.xml
index 35ade24..3b816b8 100644
--- a/res/layout/item_photo_editor.xml
+++ b/res/layout/item_photo_editor.xml
@@ -14,15 +14,28 @@
      limitations under the License.
 -->
 
-<com.android.contacts.views.editor.PhotoEditorView
+<view
+    class="com.android.contacts.views.editor.PhotoEditorView"
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="@dimen/edit_photo_size"
     android:layout_height="@dimen/edit_photo_size"
-    android:clickable="true"
-    android:focusable="true"
-    android:src="@drawable/ic_menu_add_picture"
-    android:cropToPadding="true"
-    android:scaleType="center"
-    android:background="@drawable/btn_contact_picture"
-    android:contentDescription="@string/description_contact_photo"
-    android:gravity="center" />
+    >
+    <ImageView
+        android:id="@+id/photo"
+        android:layout_width="@dimen/edit_photo_size"
+        android:layout_height="@dimen/edit_photo_size"
+        android:src="@drawable/ic_contact_picture"
+        android:cropToPadding="true"
+        android:scaleType="centerCrop"
+        android:gravity="center"
+    />
+    <View
+        android:id="@+id/frame"
+        android:layout_width="@dimen/edit_photo_size"
+        android:layout_height="@dimen/edit_photo_size"
+        android:clickable="true"
+        android:focusable="true"
+        android:contentDescription="@string/description_contact_photo"
+        android:background="@drawable/change_photo_box_holo_light"
+    />
+</view>
diff --git a/src/com/android/contacts/views/editor/PhotoEditorView.java b/src/com/android/contacts/views/editor/PhotoEditorView.java
index ba3372c..0ab44d2 100644
--- a/src/com/android/contacts/views/editor/PhotoEditorView.java
+++ b/src/com/android/contacts/views/editor/PhotoEditorView.java
@@ -28,7 +28,7 @@
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.View;
-import android.view.View.OnClickListener;
+import android.widget.FrameLayout;
 import android.widget.ImageView;
 
 import java.io.ByteArrayOutputStream;
@@ -37,9 +37,12 @@
 /**
  * Simple editor for {@link Photo}.
  */
-public class PhotoEditorView extends ImageView implements Editor, OnClickListener {
+public class PhotoEditorView extends FrameLayout implements Editor {
     private static final String TAG = "PhotoEditorView";
 
+    private ImageView mPhotoImageView;
+    private View mFrameView;
+
     private ValuesDelta mEntry;
     private EditorListener mListener;
 
@@ -58,22 +61,26 @@
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
-        this.setOnClickListener(this);
+        mPhotoImageView = (ImageView) findViewById(R.id.photo);
+        mFrameView = findViewById(R.id.frame);
+        mFrameView.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (mListener != null) {
+                    mListener.onRequest(EditorListener.REQUEST_PICK_PHOTO);
+                }
+            }
+        });
     }
 
     /** {@inheritDoc} */
-    public void onClick(View v) {
-        if (mListener != null) {
-            mListener.onRequest(EditorListener.REQUEST_PICK_PHOTO);
-        }
-    }
-
-    /** {@inheritDoc} */
+    @Override
     public void onFieldChanged(String column, String value) {
         throw new UnsupportedOperationException("Photos don't support direct field changes");
     }
 
     /** {@inheritDoc} */
+    @Override
     public void setValues(DataKind kind, ValuesDelta values, EntityDelta state, boolean readOnly,
             ViewIdGenerator vig) {
         mEntry = values;
@@ -88,8 +95,7 @@
                 final Bitmap photo = BitmapFactory.decodeByteArray(photoBytes, 0,
                         photoBytes.length);
 
-                setScaleType(ImageView.ScaleType.CENTER_CROP);
-                setImageBitmap(photo);
+                mPhotoImageView.setImageBitmap(photo);
                 setEnabled(true);
                 mHasSetPhoto = true;
                 mEntry.setFromTemplate(false);
@@ -129,7 +135,7 @@
             out.close();
 
             mEntry.put(Photo.PHOTO, out.toByteArray());
-            setImageBitmap(photo);
+            mPhotoImageView.setImageBitmap(photo);
             setEnabled(true);
             mHasSetPhoto = true;
             mEntry.setFromTemplate(false);
@@ -150,19 +156,14 @@
 
     protected void resetDefault() {
         // Invalid photo, show default "add photo" place-holder
-        setScaleType(ImageView.ScaleType.CENTER);
-        if (mReadOnly) {
-            setImageResource(R.drawable.ic_contact_picture);
-            setEnabled(false);
-        } else {
-            setImageResource(R.drawable.ic_menu_add_picture);
-            setEnabled(true);
-        }
+        mPhotoImageView.setImageResource(R.drawable.ic_contact_picture);
+        setEnabled(!mReadOnly);
         mHasSetPhoto = false;
         mEntry.setFromTemplate(true);
     }
 
     /** {@inheritDoc} */
+    @Override
     public void setEditorListener(EditorListener listener) {
         mListener = listener;
     }