am 296a576d: am a54f8fd0: Merge "Improve setting of contact photos in InCallUI" into lmp-mr1-dev

* commit '296a576d818adb63b00cc179d6ad70a7f1d20e33':
  Improve setting of contact photos in InCallUI
diff --git a/InCallUI/res/drawable/img_conference_automirrored.xml b/InCallUI/res/drawable/img_conference_automirrored.xml
new file mode 100644
index 0000000..fa1fd49
--- /dev/null
+++ b/InCallUI/res/drawable/img_conference_automirrored.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  ~ Copyright (C) 2014 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
+  -->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+    android:src="@drawable/img_conference"
+    android:autoMirrored="true" />
\ No newline at end of file
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 8aa8d23..77ec173 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -78,6 +78,7 @@
     private View mCallNumberAndLabel;
     private ImageView mPhoto;
     private TextView mElapsedTime;
+    private Drawable mPrimaryPhotoDrawable;
 
     // Container view that houses the entire primary call card, including the call buttons
     private View mPrimaryCallCardContainer;
@@ -111,6 +112,8 @@
 
     private int mVideoAnimationDuration;
 
+    private Drawable mDefaultContactPhoto;
+
     private MaterialPalette mCurrentThemeColors;
 
     @Override
@@ -599,10 +602,15 @@
 
     private void setDrawableToImageView(ImageView view, Drawable photo) {
         if (photo == null) {
-            photo = view.getResources().getDrawable(R.drawable.img_no_image);
-            photo.setAutoMirrored(true);
+            photo = ContactInfoCache.getInstance(
+                    view.getContext()).getDefaultContactPhotoDrawable();
         }
 
+        if (mPrimaryPhotoDrawable == photo) {
+            return;
+        }
+        mPrimaryPhotoDrawable = photo;
+
         final Drawable current = view.getDrawable();
         if (current == null) {
             view.setImageDrawable(photo);
@@ -622,8 +630,9 @@
 
     private Drawable getConferencePhoto(boolean canManageConference) {
         Log.v(this, "canManageConferencePhoto: " + canManageConference);
-        final int resId = canManageConference ? R.drawable.img_conference : R.drawable.img_phone;
-        return getView().getResources().getDrawable(resId);
+        final ContactInfoCache cache = ContactInfoCache.getInstance(getView().getContext());
+        return canManageConference ? cache.getConferenceDrawable()
+                : cache.getDefaultContactPhotoDrawable();
     }
 
     /**
diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java
index f8bd38d..4962169 100644
--- a/InCallUI/src/com/android/incallui/ContactInfoCache.java
+++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java
@@ -57,6 +57,9 @@
 
     private static ContactInfoCache sCache = null;
 
+    private Drawable mDefaultContactPhotoDrawable;
+    private Drawable mConferencePhotoDrawable;
+
     public static synchronized ContactInfoCache getInstance(Context mContext) {
         if (sCache == null) {
             sCache = new ContactInfoCache(mContext.getApplicationContext());
@@ -316,12 +319,10 @@
             if (info.cachedPhoto != null) {
                 photo = info.cachedPhoto;
             } else {
-                photo = context.getResources().getDrawable(R.drawable.img_no_image);
-                photo.setAutoMirrored(true);
+                photo = getDefaultContactPhotoDrawable();
             }
         } else if (info.contactDisplayPhotoUri == null) {
-            photo = context.getResources().getDrawable(R.drawable.img_no_image);
-            photo.setAutoMirrored(true);
+            photo = getDefaultContactPhotoDrawable();
         } else {
             cce.displayPhotoUri = info.contactDisplayPhotoUri;
         }
@@ -491,6 +492,22 @@
         return name;
     }
 
+    public Drawable getDefaultContactPhotoDrawable() {
+        if (mDefaultContactPhotoDrawable == null) {
+            mDefaultContactPhotoDrawable =
+                    mContext.getResources().getDrawable(R.drawable.img_no_image_automirrored);
+        }
+        return mDefaultContactPhotoDrawable;
+    }
+
+    public Drawable getConferenceDrawable() {
+        if (mConferencePhotoDrawable == null) {
+            mConferencePhotoDrawable =
+                    mContext.getResources().getDrawable(R.drawable.img_conference_automirrored);
+        }
+        return mConferencePhotoDrawable;
+    }
+
     /**
      * Callback interface for the contact query.
      */