Fix bug 2102658

-Also sneak in a UI touchup for call/text line padding.

Change-Id: Ia46aa7901518789247e9e64819c77ffbde7d2fe6
diff --git a/res/layout-finger/list_item_text_icons.xml b/res/layout-finger/list_item_text_icons.xml
index 051dde9..7e2e26e 100644
--- a/res/layout-finger/list_item_text_icons.xml
+++ b/res/layout-finger/list_item_text_icons.xml
@@ -23,7 +23,6 @@
     android:minHeight="?android:attr/listPreferredItemHeight"
     android:orientation="horizontal"
     android:paddingLeft="9dip"
-    android:paddingRight="5dip"
     android:gravity="center_vertical"
 >
 
@@ -87,17 +86,16 @@
     <View android:id="@+id/divider"
         android:layout_width="1dip"
         android:layout_height="fill_parent"
-        android:layout_marginRight="11dip"
         android:background="@drawable/divider_vertical_dark"
     />
 
     <ImageView android:id="@+id/secondary_action_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="5dip"
-        android:layout_marginRight="7dip"
+        android:layout_width="64dip"
+        android:layout_height="fill_parent"
+        android:layout_centerVertical="true"
         android:gravity="center"
-        android:scaleType="centerInside"
+        android:scaleType="center"
+        android:background="@android:drawable/list_selector_background"
     />
 
 </LinearLayout>
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index 385fbc6..be78bea 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -231,8 +231,6 @@
 
         //TODO Read this value from a preference
         mShowSmsLinksForAllPhones = true;
-
-        startEntityQuery();
     }
 
     @Override
@@ -306,10 +304,6 @@
                     ContactsSource.LEVEL_SUMMARY);
             addTab(rawContactId, ContactsUtils.createTabIndicatorView(mTabWidget.getTabParent(), source));
         }
-
-        selectInitialTab();
-        mTabWidget.setVisibility(View.VISIBLE);
-        mTabWidget.postInvalidate();
     }
 
     /**
@@ -342,6 +336,8 @@
 
         mTabWidget.setCurrentTab(selectedTabIndex);
         onTabSelectionChanged(selectedTabIndex, false);
+        mTabWidget.setVisibility(View.VISIBLE);
+        mTabWidget.postInvalidate();
     }
 
     private void addAllTab() {
@@ -352,9 +348,11 @@
     }
 
     public void onTabSelectionChanged(int tabIndex, boolean clicked) {
-        long rawContactId = getTabRawContactId(tabIndex);
-        mSelectedRawContactId = rawContactId;
-        bindData();
+        Long rawContactId = getTabRawContactId(tabIndex);
+        if (rawContactId != null) {
+            mSelectedRawContactId = rawContactId;
+            bindData();
+        }
     }
 
     /**
@@ -363,7 +361,7 @@
      * @param index The index of the tab in question.
      * @return The contactId associated with the tab at the specified index.
      */
-    protected long getTabRawContactId(int index) {
+    protected Long getTabRawContactId(int index) {
         return mTabRawContactIdMap.get(index);
     }
 
@@ -392,7 +390,7 @@
                 clearCurrentTabs();
                 mEntities = readEntities(iterator);
                 bindTabs();
-                bindData();
+                selectInitialTab();
             }
         } finally {
             if (iterator != null) {
@@ -851,6 +849,13 @@
                 // TODO: entry.contactId should be renamed to entry.rawContactId
                 long contactId = entValues.getAsLong(RawContacts._ID);
 
+                // This performs the tab filtering
+                if (mSelectedRawContactId != null
+                        && mSelectedRawContactId != contactId
+                        && mSelectedRawContactId != ALL_CONTACTS_ID) {
+                    continue;
+                }
+
                 for (NamedContentValues subValue : entity.getSubValues()) {
                     ViewEntry entry = new ViewEntry();
 
@@ -896,13 +901,6 @@
                         mRawContactIds.add(entry.contactId);
                     }
 
-                    // This performs the tab filtering
-                    if (mSelectedRawContactId != null
-                            && mSelectedRawContactId != entry.contactId
-                            && mSelectedRawContactId != ALL_CONTACTS_ID) {
-                        continue;
-                    }
-
                     if (CommonDataKinds.Phone.CONTENT_ITEM_TYPE.equals(mimetype)
                             || CommonDataKinds.Email.CONTENT_ITEM_TYPE.equals(mimetype)
                             || CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)