Account header icon cut off in contact editor for local contacts

Bug: 5298440
Change-Id: I9dfe60ef1c2b81c96f9b785d734031839a62d758
diff --git a/res/layout/editor_account_header.xml b/res/layout/editor_account_header.xml
index ff33cf1..6dd55fd 100644
--- a/res/layout/editor_account_header.xml
+++ b/res/layout/editor_account_header.xml
@@ -38,18 +38,20 @@
 
         <TextView
             android:id="@+id/account_type"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:singleLine="true" />
+            android:singleLine="true"
+            android:ellipsize="end" />
 
         <TextView
              android:id="@+id/account_name"
-             android:layout_width="wrap_content"
+             android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceSmall"
              android:textColor="?android:attr/textColorTertiary"
-             android:singleLine="true" />
+             android:singleLine="true"
+             android:ellipsize="end" />
 
     </LinearLayout>
 
diff --git a/res/layout/editor_account_header_with_dropdown.xml b/res/layout/editor_account_header_with_dropdown.xml
index 001eaae..12c2a84 100644
--- a/res/layout/editor_account_header_with_dropdown.xml
+++ b/res/layout/editor_account_header_with_dropdown.xml
@@ -29,37 +29,35 @@
     <LinearLayout
         android:id="@+id/account"
         android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
+        android:layout_width="0dip"
+        android:layout_weight="1"
         android:orientation="vertical"
         style="?android:attr/spinnerStyle">
 
         <TextView
             android:id="@+id/account_type"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:singleLine="true" />
+            android:singleLine="true"
+            android:ellipsize="end" />
 
         <TextView
              android:id="@+id/account_name"
-             android:layout_width="wrap_content"
+             android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:paddingRight="8dip"
              android:textAppearance="?android:attr/textAppearanceSmall"
              android:textColor="?android:attr/textColorTertiary"
-             android:singleLine="true" />
+             android:singleLine="true"
+             android:ellipsize="end" />
 
     </LinearLayout>
 
-    <!-- Spacer between the account type / name dropdown and the account icon -->
-    <View
-        android:layout_width="0dip"
-        android:layout_height="match_parent"
-        android:layout_weight="1"/>
-
     <FrameLayout
         android:layout_width="wrap_content"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:layout_marginLeft="10dip">
 
         <ImageView
              android:id="@+id/account_icon"
diff --git a/src/com/android/contacts/editor/ExternalRawContactEditorView.java b/src/com/android/contacts/editor/ExternalRawContactEditorView.java
index 9b4f988..0788961 100644
--- a/src/com/android/contacts/editor/ExternalRawContactEditorView.java
+++ b/src/com/android/contacts/editor/ExternalRawContactEditorView.java
@@ -148,8 +148,12 @@
                 accountType = mContext.getString(R.string.account_phone);
             }
             if (!TextUtils.isEmpty(mAccountName)) {
+                mAccountNameTextView.setVisibility(View.VISIBLE);
                 mAccountNameTextView.setText(
                         mContext.getString(R.string.from_account_format, mAccountName));
+            } else {
+                // Hide this view so the other text view will be centered vertically
+                mAccountNameTextView.setVisibility(View.GONE);
             }
             mAccountTypeTextView.setText(mContext.getString(R.string.account_type_format,
                     accountType));
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index 2d42a50..3a40a0f 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -195,8 +195,12 @@
                 accountType = mContext.getString(R.string.account_phone);
             }
             if (!TextUtils.isEmpty(accountName)) {
+                mAccountNameTextView.setVisibility(View.VISIBLE);
                 mAccountNameTextView.setText(
                         mContext.getString(R.string.from_account_format, accountName));
+            } else {
+                // Hide this view so the other text view will be centered vertically
+                mAccountNameTextView.setVisibility(View.GONE);
             }
             mAccountTypeTextView.setText(
                     mContext.getString(R.string.account_type_format, accountType));