am bd421b68: Merge "Add an additional line to Call Log for PhoneAccount name" into lmp-mr1-dev

* commit 'bd421b68ec17cd33ee3dd1d2613f5637299e57d9':
  Add an additional line to Call Log for PhoneAccount name
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index c77a1f7..db59b74 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -112,15 +112,6 @@
                         android:layout_marginEnd="@dimen/call_log_icon_margin"
                         android:layout_gravity="center_vertical"
                         />
-                    <ImageView
-                        android:id="@+id/call_account_icon"
-                        android:layout_width="@dimen/call_provider_small_icon_size"
-                        android:layout_height="@dimen/call_provider_small_icon_size"
-                        android:layout_marginEnd="@dimen/call_log_icon_margin"
-                        android:layout_gravity="center_vertical"
-                        android:tint="?attr/call_log_secondary_text_color"
-                        android:scaleType="centerInside"
-                        />
                     <TextView
                         android:id="@+id/call_location_and_date"
                         android:layout_width="wrap_content"
@@ -132,6 +123,16 @@
                         android:singleLine="true"
                         />
                 </LinearLayout>
+                <TextView
+                    android:id="@+id/call_account_label"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginEnd="@dimen/call_log_icon_margin"
+                    android:textColor="?attr/call_log_secondary_text_color"
+                    android:textSize="@dimen/call_log_secondary_text_size"
+                    android:visibility="gone"
+                    android:singleLine="true"
+                    />
             </LinearLayout>
             <ImageView
                 android:id="@+id/call_indicator_icon"
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index e888431..2e1651a 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -22,6 +22,7 @@
 import android.provider.CallLog;
 import android.provider.CallLog.Calls;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.telecom.PhoneAccount;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.view.View;
@@ -35,6 +36,7 @@
 import com.android.dialer.calllog.PhoneNumberDisplayHelper;
 import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
 import com.android.dialer.util.DialerUtils;
+
 import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
@@ -106,13 +108,21 @@
         // Set the call count, location and date.
         setCallCountAndDate(views, callCount, callLocationAndDate);
 
-        // set the account icon if it exists
-        Drawable accountIcon = PhoneAccountUtils.getAccountIcon(mContext, details.accountHandle);
-        if (accountIcon != null) {
-            views.callAccountIcon.setVisibility(View.VISIBLE);
-            views.callAccountIcon.setImageDrawable(accountIcon);
+        // Set the account label if it exists.
+        String accountLabel = PhoneAccountUtils.getAccountLabel(mContext, details.accountHandle);
+
+        if (accountLabel != null) {
+            views.callAccountLabel.setVisibility(View.VISIBLE);
+            views.callAccountLabel.setText(accountLabel);
+            int color = PhoneAccountUtils.getAccountColor(mContext, details.accountHandle);
+            if (color == PhoneAccount.NO_COLOR) {
+                int defaultColor = R.color.dialtacts_secondary_text_color;
+                views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor));
+            } else {
+                views.callAccountLabel.setTextColor(color);
+            }
         } else {
-            views.callAccountIcon.setVisibility(View.GONE);
+            views.callAccountLabel.setVisibility(View.GONE);
         }
 
         final CharSequence nameText;
diff --git a/src/com/android/dialer/PhoneCallDetailsViews.java b/src/com/android/dialer/PhoneCallDetailsViews.java
index 67babc1..05026d6 100644
--- a/src/com/android/dialer/PhoneCallDetailsViews.java
+++ b/src/com/android/dialer/PhoneCallDetailsViews.java
@@ -30,19 +30,19 @@
     public final TextView nameView;
     public final View callTypeView;
     public final CallTypeIconsView callTypeIcons;
-    public final ImageView callAccountIcon;
     public final TextView callLocationAndDate;
     public final TextView voicemailTranscriptionView;
+    public final TextView callAccountLabel;
 
     private PhoneCallDetailsViews(TextView nameView, View callTypeView,
-            CallTypeIconsView callTypeIcons, ImageView callAccountIcon,
-            TextView callLocationAndDate, TextView voicemailTranscriptionView) {
+            CallTypeIconsView callTypeIcons, TextView callLocationAndDate,
+            TextView voicemailTranscriptionView, TextView callAccountLabel) {
         this.nameView = nameView;
         this.callTypeView = callTypeView;
         this.callTypeIcons = callTypeIcons;
-        this.callAccountIcon = callAccountIcon;
         this.callLocationAndDate = callLocationAndDate;
         this.voicemailTranscriptionView = voicemailTranscriptionView;
+        this.callAccountLabel = callAccountLabel;
     }
 
     /**
@@ -56,9 +56,9 @@
         return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
                 view.findViewById(R.id.call_type),
                 (CallTypeIconsView) view.findViewById(R.id.call_type_icons),
-                (ImageView) view.findViewById(R.id.call_account_icon),
                 (TextView) view.findViewById(R.id.call_location_and_date),
-                (TextView) view.findViewById(R.id.voicemail_transcription));
+                (TextView) view.findViewById(R.id.voicemail_transcription),
+                (TextView) view.findViewById(R.id.call_account_label));
     }
 
     public static PhoneCallDetailsViews createForTest(Context context) {
@@ -66,7 +66,7 @@
                 new TextView(context),
                 new View(context),
                 new CallTypeIconsView(context),
-                new ImageView(context),
+                new TextView(context),
                 new TextView(context),
                 new TextView(context));
     }
diff --git a/src/com/android/dialer/calllog/PhoneAccountUtils.java b/src/com/android/dialer/calllog/PhoneAccountUtils.java
index eb9e433..7ab212f 100644
--- a/src/com/android/dialer/calllog/PhoneAccountUtils.java
+++ b/src/com/android/dialer/calllog/PhoneAccountUtils.java
@@ -61,35 +61,30 @@
     }
 
     /**
-     * Extract account icon from PhoneAccount object.
+     * Extract account label from PhoneAccount object.
      */
-    public static Drawable getAccountIcon(Context context, PhoneAccountHandle phoneAccount) {
-        final PhoneAccount account = getAccountOrNull(context, phoneAccount);
-        if (account == null) {
-            return null;
-        }
-        return account.getIcon(context);
+    public static String getAccountLabel(Context context, PhoneAccountHandle accountHandle) {
+        PhoneAccount account = getAccountOrNull(context, accountHandle);
+        return account == null ? null : account.getLabel().toString();
     }
 
     /**
-     * Extract account label from PhoneAccount object.
+     * Extract account color from PhoneAccount object.
      */
-    public static String getAccountLabel(Context context, PhoneAccountHandle phoneAccount) {
-        final PhoneAccount account = getAccountOrNull(context, phoneAccount);
-        if (account == null) {
-            return null;
-        }
-        return account.getLabel().toString();
+    public static int getAccountColor(Context context, PhoneAccountHandle accountHandle) {
+        PhoneAccount account = getAccountOrNull(context, accountHandle);
+        return account == null ? PhoneAccount.NO_COLOR : account.getColor();
     }
 
     /**
      * Retrieve the account metadata, but if the account does not exist or the device has only a
      * single registered and enabled account, return null.
      */
-    private static PhoneAccount getAccountOrNull(Context context, PhoneAccountHandle phoneAccount) {
-        final TelecomManager telecomManager =
+    private static PhoneAccount getAccountOrNull(Context context,
+            PhoneAccountHandle accountHandle) {
+        TelecomManager telecomManager =
                 (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
-        final PhoneAccount account = telecomManager.getPhoneAccount(phoneAccount);
+        final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle);
         if (account == null || !telecomManager.hasMultipleCallCapableAccounts()) {
             return null;
         }