Merge "Bringing read-only contact editor in compliance with mocks"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a1a935e..50e6c6d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -37,6 +37,7 @@
     <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
 
     <application
+        android:name="com.android.contacts.ContactsApplication"
         android:label="@string/contactsList"
         android:icon="@mipmap/ic_launcher_contacts"
         android:process="android.process.acore"
diff --git a/res/layout-large/contact_detail_header_view.xml b/res/layout-large/contact_detail_header_view.xml
index 1af514b..cf43163 100644
--- a/res/layout-large/contact_detail_header_view.xml
+++ b/res/layout-large/contact_detail_header_view.xml
@@ -14,92 +14,98 @@
      limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/banner"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:paddingTop="40dip"
-    android:paddingRight="5dip">
+    android:paddingBottom="28dip">
+
+    <TextView
+        android:id="@+id/attribution"
+        android:layout_width="match_parent"
+        android:layout_height="56dip"
+        android:paddingRight="24dip"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textColor="?android:attr/textColorTertiary"
+        android:gravity="right|center_vertical"
+        android:singleLine="true" />
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal">
 
-        <ImageView android:id="@+id/photo"
-            android:layout_marginRight="16dip"
+        <ImageView
+            android:id="@+id/photo"
             android:layout_marginLeft="16dip"
             android:layout_width="96dip"
-            android:layout_height="96dip"
-        />
+            android:layout_height="96dip" />
 
         <LinearLayout
             android:layout_width="0px"
             android:layout_height="wrap_content"
             android:layout_weight="1"
-            android:orientation="vertical">
+            android:orientation="vertical"
+            android:layout_gravity="top">
+
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="1px"
+                android:background="@color/contact_detail_header_divider_color" />
 
             <LinearLayout
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
-                android:orientation="horizontal" >
+                android:orientation="horizontal"
+                android:paddingTop="16dip"
+                android:layout_marginLeft="16dip">
 
                 <!-- Star -->
                 <CheckBox
                     android:id="@+id/star"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_gravity="center_vertical"
+                    android:layout_marginTop="4dip"
+                    android:layout_gravity="top"
                     android:contentDescription="@string/description_star"
                     android:visibility="invisible"
-                    style="?android:attr/starStyle"
-                />
+                    style="?android:attr/starStyle" />
 
                 <!-- Name, PhoneticName, Directory -->
                 <LinearLayout
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
                     android:paddingLeft="16dip"
-                    android:orientation="vertical" >
+                    android:orientation="vertical">
 
-                    <TextView android:id="@+id/name"
+                    <TextView
+                        android:id="@+id/name"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:singleLine="true"
                         android:ellipsize="end"
-                        android:textSize="26sp"
-                    />
+                        android:textSize="26sp" />
 
-                    <TextView android:id="@+id/phonetic_name"
+                    <TextView
+                        android:id="@+id/phonetic_name"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:textAppearance="?android:attr/textAppearanceSmall"
                         android:singleLine="true"
                         android:ellipsize="end"
                         android:layout_marginTop="-2dip"
-                        android:visibility="gone"
-                    />
+                        android:visibility="gone" />
 
-                    <TextView android:id="@+id/organization"
+                    <TextView
+                        android:id="@+id/organization"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_marginTop="-2dip"
                         android:visibility="gone"
                         android:textColor="#999999"
-                        android:textAppearance="?android:attr/textAppearanceLarge"
-                    />
-
-                    <TextView android:id="@+id/directory_name"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:textAppearance="?android:attr/textAppearanceSmall"
-                        android:textColor="?android:attr/textColorSecondary"
-                        android:singleLine="true"
-                        android:ellipsize="end"
-                        android:layout_marginTop="-2dip"
-                        android:visibility="gone"
-                    />
+                        android:textAppearance="?android:attr/textAppearanceLarge" />
                 </LinearLayout>
             </LinearLayout>
         </LinearLayout>
@@ -120,22 +126,22 @@
         android:paddingBottom="16dip"
         android:visibility="gone">
 
-        <TextView android:id="@+id/status"
+        <TextView
+            android:id="@+id/status"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="#66666666"
             android:maxLines="2"
             android:ellipsize="end"
-            android:visibility="gone"
-        />
+            android:visibility="gone" />
 
-        <TextView android:id="@+id/status_date"
+        <TextView
+            android:id="@+id/status_date"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="#66666666"
-            android:visibility="gone"
-        />
+            android:visibility="gone" />
     </LinearLayout>
 </LinearLayout>
diff --git a/res/layout-xlarge-land/contact_detail_header_view.xml b/res/layout-xlarge-land/contact_detail_header_view.xml
index 18edb10..9e00ab2 100644
--- a/res/layout-xlarge-land/contact_detail_header_view.xml
+++ b/res/layout-xlarge-land/contact_detail_header_view.xml
@@ -14,129 +14,152 @@
      limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/banner"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="horizontal"
-    android:paddingTop="40dip"
-    android:paddingRight="5dip">
+    android:orientation="vertical"
+    android:paddingBottom="28dip">
 
-    <ImageView android:id="@+id/photo"
-        android:layout_marginRight="16dip"
-        android:layout_marginLeft="-1dip"
-        android:layout_width="96dip"
-        android:layout_height="96dip"
-    />
+    <TextView
+        android:id="@+id/attribution"
+        android:layout_width="match_parent"
+        android:layout_height="56dip"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textColor="?android:attr/textColorTertiary"
+        android:gravity="right|center_vertical"
+        android:singleLine="true" />
 
     <LinearLayout
-        android:layout_width="0px"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
+        android:orientation="horizontal">
+
+        <ImageView
+            android:id="@+id/photo"
+            android:layout_marginLeft="-1dip"
+            android:layout_width="96dip"
+            android:layout_height="96dip" />
 
         <LinearLayout
-            android:layout_width="fill_parent"
+            android:layout_width="0px"
             android:layout_height="wrap_content"
-            android:orientation="horizontal" >
+            android:layout_weight="1"
+            android:layout_gravity="top"
+            android:orientation="vertical">
 
-            <!-- Star -->
-            <CheckBox
-                android:id="@+id/star"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center_vertical"
-                android:contentDescription="@string/description_star"
-                android:visibility="invisible"
-                style="?android:attr/starStyle"
-            />
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="1px"
+                android:background="@color/contact_detail_header_divider_color" />
 
-            <!-- Name, PhoneticName, Directory -->
             <LinearLayout
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
-                android:paddingLeft="16dip"
-                android:orientation="vertical" >
-
-                <TextView android:id="@+id/name"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:singleLine="true"
-                    android:ellipsize="end"
-                    android:textSize="26sp"
-                />
-
-                <TextView android:id="@+id/phonetic_name"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceSmall"
-                    android:singleLine="true"
-                    android:ellipsize="end"
-                    android:layout_marginTop="-2dip"
-                    android:visibility="gone"
-                />
-
-                <TextView android:id="@+id/organization"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:singleLine="true"
-                    android:ellipsize="end"
-                    android:layout_marginTop="-2dip"
-                    android:visibility="gone"
-                    android:textColor="#999999"
-                    android:textAppearance="?android:attr/textAppearanceLarge"
-                />
-
-                <TextView android:id="@+id/directory_name"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceSmall"
-                    android:textColor="?android:attr/textColorSecondary"
-                    android:singleLine="true"
-                    android:ellipsize="end"
-                    android:layout_marginTop="-2dip"
-                    android:visibility="gone"
-                />
-            </LinearLayout>
-        </LinearLayout>
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-            <!-- Status info -->
-            <LinearLayout
-                android:id="@+id/status_container"
-                android:layout_width="0px"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:orientation="vertical"
-                android:background="@drawable/statusbox_landscape_holo_light"
-                android:layout_marginTop="30dip"
-                android:paddingLeft="64dip"
+                android:orientation="horizontal"
                 android:paddingTop="16dip"
-                android:paddingRight="16dip"
-                android:paddingBottom="16dip"
-                android:visibility="gone">
-    
-                <TextView android:id="@+id/status"
-                    android:layout_width="match_parent"
+                android:layout_marginLeft="16dip">
+
+                <!-- Star -->
+                <CheckBox
+                    android:id="@+id/star"
+                    android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:textColor="#66666666"
-                    android:maxLines="2"
-                    android:ellipsize="end"
-                    android:visibility="gone"
-                />
-    
-                <TextView android:id="@+id/status_date"
-                    android:layout_width="match_parent"
-                    android:layout_height="0dip"
+                    android:layout_marginTop="4dip"
+                    android:layout_gravity="top"
+                    android:contentDescription="@string/description_star"
+                    android:visibility="invisible"
+                    style="?android:attr/starStyle" />
+
+                <!-- Name, PhoneticName, Directory -->
+                <LinearLayout
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:paddingLeft="16dip"
+                    android:orientation="vertical">
+
+                    <TextView
+                        android:id="@+id/name"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:singleLine="true"
+                        android:ellipsize="end"
+                        android:textSize="26sp" />
+
+                    <TextView
+                        android:id="@+id/phonetic_name"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:textAppearance="?android:attr/textAppearanceSmall"
+                        android:singleLine="true"
+                        android:ellipsize="end"
+                        android:layout_marginTop="-2dip"
+                        android:visibility="gone" />
+
+                    <TextView
+                        android:id="@+id/organization"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:singleLine="true"
+                        android:ellipsize="end"
+                        android:layout_marginTop="-2dip"
+                        android:visibility="gone"
+                        android:textColor="#999999"
+                        android:textAppearance="?android:attr/textAppearanceLarge" />
+
+                    <TextView
+                        android:id="@+id/directory_name"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:textAppearance="?android:attr/textAppearanceSmall"
+                        android:textColor="?android:attr/textColorSecondary"
+                        android:singleLine="true"
+                        android:ellipsize="end"
+                        android:layout_marginTop="-2dip"
+                        android:visibility="gone" />
+                </LinearLayout>
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <!-- Status info -->
+                <LinearLayout
+                    android:id="@+id/status_container"
+                    android:layout_width="0px"
+                    android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:textColor="#66666666"
-                    android:visibility="gone"
-                />
+                    android:orientation="vertical"
+                    android:background="@drawable/statusbox_landscape_holo_light"
+                    android:layout_marginTop="30dip"
+                    android:paddingLeft="64dip"
+                    android:paddingTop="16dip"
+                    android:paddingRight="16dip"
+                    android:paddingBottom="16dip"
+                    android:visibility="gone">
+
+                    <TextView
+                        android:id="@+id/status"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        android:textColor="#66666666"
+                        android:maxLines="2"
+                        android:ellipsize="end"
+                        android:visibility="gone" />
+
+                    <TextView
+                        android:id="@+id/status_date"
+                        android:layout_width="match_parent"
+                        android:layout_height="0dip"
+                        android:layout_weight="1"
+                        android:textAppearance="?android:attr/textAppearanceMedium"
+                        android:textColor="#66666666"
+                        android:visibility="gone" />
+                </LinearLayout>
             </LinearLayout>
         </LinearLayout>
     </LinearLayout>
diff --git a/res/layout-xlarge-land/contact_detail_list_item.xml b/res/layout-xlarge-land/contact_detail_list_item.xml
index 252e8d8..41ca7ee 100644
--- a/res/layout-xlarge-land/contact_detail_list_item.xml
+++ b/res/layout-xlarge-land/contact_detail_list_item.xml
@@ -22,14 +22,14 @@
     android:layout_height="wrap_content"
     android:orientation="vertical"
 >
-    <!-- Longer seperating line (between kinds) -->
+    <!-- Longer separating line (between kinds) -->
     <View
         android:id="@+id/kind_divider"
         android:layout_width="match_parent"
         android:layout_height="1px"
         android:background="@drawable/list_item_divider_holo"
     />
-    <!-- Shorter seperating line if there was no kind-seperator -->
+    <!-- Shorter separating line if there was no kind-separator -->
     <View
         android:id="@+id/in_kind_divider"
         android:layout_width="match_parent"
@@ -116,7 +116,7 @@
             android:background="@android:drawable/list_selector_background"
         />
     </LinearLayout>
-    <!-- Longer seperating line (only for the last row) -->
+    <!-- Longer separating line (only for the last row) -->
     <View
         android:id="@+id/line_below_last"
         android:layout_width="match_parent"
diff --git a/res/layout-xlarge/contact_detail_fragment.xml b/res/layout-xlarge/contact_detail_fragment.xml
index 744b8f5..4ebe379 100644
--- a/res/layout-xlarge/contact_detail_fragment.xml
+++ b/res/layout-xlarge/contact_detail_fragment.xml
@@ -27,15 +27,18 @@
     <com.android.contacts.widget.InterpolatingLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="28dip">
+        >
         <com.android.contacts.views.detail.ContactDetailHeaderView
             android:id="@+id/contact_header_widget"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginBottom="28dip"
             ex:layout_wideParentWidth="800dip"
             ex:layout_wideLeftMargin="80dip"
+            ex:layout_wideRightMargin="48dip"
             ex:layout_narrowParentWidth="500dip"
             ex:layout_narrowLeftMargin="15dip"
+            ex:layout_narrowRightMargin="5dip"
         />
     </com.android.contacts.widget.InterpolatingLayout>
 
diff --git a/res/layout/contact_detail_header_view.xml b/res/layout/contact_detail_header_view.xml
index dba99c1..3248920 100644
--- a/res/layout/contact_detail_header_view.xml
+++ b/res/layout/contact_detail_header_view.xml
@@ -70,7 +70,7 @@
             android:visibility="gone"
         />
 
-        <TextView android:id="@+id/directory_name"
+        <TextView android:id="@+id/attribution"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0f24531..81b0bec 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -36,4 +36,7 @@
 
     <!-- Color used for the label (type) in the editor -->
     <color name="editor_label_text_color">#FF7F7F7F</color>
+
+    <!-- Color of the line above the contact photo in the contact detail header -->
+    <color name="contact_detail_header_divider_color">#FF999999</color>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 25e39fe..8f9df4b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1339,10 +1339,7 @@
     <string name="menu_copyContact">Copy to my contacts</string>
 
     <!-- The description of the directory where the contact was found [CHAR LIMIT=100]-->
-    <string name="contact_directory_description">from <xliff:g id="type" example="Corporate Directory">%1$s</xliff:g></string>
-
-    <!-- The description of the directory where the contact was found [CHAR LIMIT=100]-->
-    <string name="contact_directory_account_description">from <xliff:g id="type" example="Corporate Directory">%1$s</xliff:g> (<xliff:g id="name" example="me@acme.com">%2$s</xliff:g>)</string>
+    <string name="contact_directory_description">Directory <xliff:g id="type" example="Corporate Directory">%1$s</xliff:g></string>
 
     <!-- The label displayed in the Contacts action bar when in search mode [CHAR LIMIT=64] -->
     <string name="search_label">Searching all contacts</string>
@@ -1452,4 +1449,7 @@
     <string name="toast_join_with_empty_contact">Please enter contact name before joining
       with another contact.
     </string>
+
+    <!-- Joined contact indicator displayed in the contact detail [CHAR LIMIT=64] -->
+    <string name="indicator_joined_contact">Joined contact</string>
 </resources>
diff --git a/src/com/android/contacts/AttachImage.java b/src/com/android/contacts/AttachImage.java
index ba1892a..5e0ead4 100644
--- a/src/com/android/contacts/AttachImage.java
+++ b/src/com/android/contacts/AttachImage.java
@@ -175,8 +175,9 @@
     /**
      * Inserts a photo on the raw contact.
      * @param values the photo values
-     * @param assertAccount if true, will check to verify if the account is Google or exchange,
-     *     no photos exist (Google and exchange only take one picture)
+     * @param assertAccount if true, will check to verify that no photos exist for Google,
+     *     Exchange and unsynced phone account types. These account types only take one picture,
+     *     so if one exists, the account will be updated with the new photo.
      */
     private void insertPhoto(ContentValues values, Uri rawContactDataUri,
             boolean assertAccount) {
@@ -185,10 +186,11 @@
             new ArrayList<ContentProviderOperation>();
 
         if (assertAccount) {
-            // make sure for Google and exchange, no pictures exist
+            // Make sure no pictures exist for Google, Exchange and unsynced phone accounts.
             operations.add(ContentProviderOperation.newAssertQuery(rawContactDataUri)
-                    .withSelection(Photo.MIMETYPE + "=? AND "
-                            + RawContacts.ACCOUNT_TYPE + " IN (?,?)",
+                    .withSelection(Photo.MIMETYPE + "=? AND ("
+                            + RawContacts.ACCOUNT_TYPE + " IN (?,?) OR "
+                            + RawContacts.ACCOUNT_TYPE + " IS NULL)",
                             new String[] {Photo.CONTENT_ITEM_TYPE, GoogleAccountType.ACCOUNT_TYPE,
                             ExchangeAccountType.ACCOUNT_TYPE})
                             .withExpectedCount(0).build());
diff --git a/src/com/android/contacts/ContactsApplication.java b/src/com/android/contacts/ContactsApplication.java
new file mode 100644
index 0000000..df12cf8
--- /dev/null
+++ b/src/com/android/contacts/ContactsApplication.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package com.android.contacts;
+
+import android.app.Application;
+import android.os.StrictMode;
+
+public final class ContactsApplication extends Application {
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+
+        StrictMode.setThreadPolicy(
+                new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
+    }
+}
diff --git a/src/com/android/contacts/views/detail/ContactDetailHeaderView.java b/src/com/android/contacts/views/detail/ContactDetailHeaderView.java
index 4a00f3a..942cbaa 100644
--- a/src/com/android/contacts/views/detail/ContactDetailHeaderView.java
+++ b/src/com/android/contacts/views/detail/ContactDetailHeaderView.java
@@ -62,7 +62,7 @@
     private View mStatusContainerView;
     private TextView mStatusView;
     private TextView mStatusDateView;
-    private TextView mDirectoryNameView;
+    private TextView mAttributionView;
 
     private Uri mContactUri;
     private Listener mListener;
@@ -105,7 +105,7 @@
         mStatusView = (TextView)findViewById(R.id.status);
         mStatusDateView = (TextView)findViewById(R.id.status_date);
 
-        mDirectoryNameView = (TextView) findViewById(R.id.directory_name);
+        mAttributionView = (TextView) findViewById(R.id.attribution);
     }
 
     /**
@@ -129,8 +129,8 @@
         setStared(!contactData.isDirectoryEntry(), contactData.getStarred());
         setSocialSnippet(contactData.getSocialSnippet());
         setSocialDate(ContactBadgeUtil.getSocialDate(contactData, getContext()));
-        setDirectoryName(contactData.isDirectoryEntry(), contactData.getDirectoryDisplayName(),
-                contactData.getDirectoryType(), contactData.getDirectoryAccountName());
+        setAttribution(contactData.getEntities().size() > 1, contactData.isDirectoryEntry(),
+                contactData.getDirectoryDisplayName(), contactData.getDirectoryType());
     }
 
     /**
@@ -269,27 +269,38 @@
         }
     }
 
-    private void setDirectoryName(boolean isDirectoryEntry, String directoryDisplayName,
-            String directoryType, String directoryAccountName) {
-        if (isDirectoryEntry) {
-            String name = TextUtils.isEmpty(directoryDisplayName)
-                    ? directoryAccountName
-                    : directoryDisplayName;
-            String text;
-            if (TextUtils.isEmpty(name)) {
-                text = getContext().getString(
-                        R.string.contact_directory_description, directoryType);
-            } else {
-                text = getContext().getString(
-                        R.string.contact_directory_account_description, directoryType, name);
-            }
-            mDirectoryNameView.setText(text);
-            mDirectoryNameView.setVisibility(View.VISIBLE);
+    private void setAttribution(boolean isJoinedContact, boolean isDirectoryEntry,
+            String directoryDisplayName, String directoryType) {
+        if (isJoinedContact) {
+            mAttributionView.setText(R.string.indicator_joined_contact);
+            mAttributionView.setVisibility(View.VISIBLE);
+        } else if (isDirectoryEntry) {
+            String text = getContext().getString(R.string.contact_directory_description,
+                    buildDirectoryName(directoryType, directoryDisplayName));
+            mAttributionView.setText(text);
+            mAttributionView.setVisibility(View.VISIBLE);
         } else {
-            mDirectoryNameView.setVisibility(View.GONE);
+            mAttributionView.setVisibility(View.INVISIBLE);
         }
     }
 
+    private CharSequence buildDirectoryName(String directoryType, String directoryName) {
+        String title;
+        if (!TextUtils.isEmpty(directoryName)) {
+            title = directoryName;
+            // TODO: STOPSHIP - remove this once this is done by both directory providers
+            int atIndex = title.indexOf('@');
+            if (atIndex != -1 && atIndex < title.length() - 2) {
+                final char firstLetter = Character.toUpperCase(title.charAt(atIndex + 1));
+                title = firstLetter + title.substring(atIndex + 2);
+            }
+        } else {
+            title = directoryType;
+        }
+
+        return title;
+    }
+
     @Override
     public void onClick(View view) {
         switch (view.getId()) {