New layout for in-reply-to messages.
diff --git a/res/layout-finger/social_list_item.xml b/res/layout-finger/social_list_item.xml
index 588cbd8..c25e0fc 100644
--- a/res/layout-finger/social_list_item.xml
+++ b/res/layout-finger/social_list_item.xml
@@ -73,7 +73,7 @@
 
         android:lines="1"
         android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textColor="#8000"
+        android:textColor="#999"
     />
 
 </RelativeLayout>
diff --git a/res/layout-finger/social_list_item_reply.xml b/res/layout-finger/social_list_item_reply.xml
new file mode 100644
index 0000000..2cd7b18
--- /dev/null
+++ b/res/layout-finger/social_list_item_reply.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:paddingBottom="2dip">
+
+    <ImageView
+        android:id="@+id/photo"
+        android:layout_width="58dip"
+        android:layout_height="58dip"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_centerVertical="true"
+        android:layout_marginTop="1dip"
+        android:layout_marginRight="8dip"
+        android:layout_marginLeft="32dip"
+
+        android:background="@drawable/contact_picture_border_in_list"
+        android:gravity="center"
+        android:scaleType="fitCenter"
+    />
+
+    <TextView
+        android:id="@+id/content"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_toRightOf="@id/photo"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentTop="true"
+        android:layout_alignWithParentIfMissing="true"
+
+        android:lineSpacingMultiplier="0.9"
+        android:maxLines="6"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+    />
+
+    <TextView
+        android:id="@+id/published"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_toRightOf="@id/photo"
+        android:layout_below="@id/content"
+        android:layout_marginTop="8dip"
+
+        android:lines="1"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textColor="#999"
+    />
+
+</RelativeLayout>
diff --git a/src/com/android/contacts/SocialStreamActivity.java b/src/com/android/contacts/SocialStreamActivity.java
index c3d8997..157100e 100644
--- a/src/com/android/contacts/SocialStreamActivity.java
+++ b/src/com/android/contacts/SocialStreamActivity.java
@@ -77,6 +77,7 @@
         Activities.PUBLISHED,
         Activities.TITLE,
         Activities.SUMMARY,
+        Activities.THREAD_PUBLISHED,
     };
 
     private static final int COL_ID = 0;
@@ -88,6 +89,7 @@
     private static final int COL_PUBLISHED = 6;
     private static final int COL_TITLE = 7;
     private static final int COL_SUMMARY = 8;
+    private static final int COL_THREAD_PUBLISHED = 9;
 
     public static final int PHOTO_SIZE = 58;
 
@@ -170,7 +172,18 @@
             mContactsCache = contactsCache;
             mMappingCache = mappingCache;
             mTextStyleName = new StyleSpan(android.graphics.Typeface.BOLD);
-       }
+        }
+
+        @Override
+        public int getViewTypeCount() {
+            return 2;
+        }
+
+        @Override
+        public int getItemViewType(int position) {
+            Cursor cursor = (Cursor) getItem(position);
+            return isReply(cursor) ? 0 : 1;
+        }
 
         @Override
         public void bindView(View view, Context context, Cursor cursor) {
@@ -200,19 +213,23 @@
                     System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
             holder.published.setText(relativePublished);
 
-            String packageName = cursor.getString(COL_PACKAGE);
-            String mimeType = cursor.getString(COL_MIMETYPE);
-            Mapping mapping = mMappingCache.getMapping(packageName, mimeType);
-            if (mapping != null && mapping.icon != null) {
-                holder.sourceIcon.setImageBitmap(mapping.icon);
-            } else {
-                holder.sourceIcon.setImageDrawable(null);
+            if (holder.sourceIcon != null) {
+                String packageName = cursor.getString(COL_PACKAGE);
+                String mimeType = cursor.getString(COL_MIMETYPE);
+                Mapping mapping = mMappingCache.getMapping(packageName, mimeType);
+                if (mapping != null && mapping.icon != null) {
+                    holder.sourceIcon.setImageBitmap(mapping.icon);
+                } else {
+                    holder.sourceIcon.setImageDrawable(null);
+                }
             }
         }
 
         @Override
         public View newView(Context context, Cursor cursor, ViewGroup parent) {
-            View view = mInflater.inflate(R.layout.social_list_item, parent, false);
+            View view = mInflater.inflate(
+                    isReply(cursor) ? R.layout.social_list_item_reply : R.layout.social_list_item,
+                    parent, false);
 
             SocialHolder holder = new SocialHolder();
             holder.photo = (ImageView) view.findViewById(R.id.photo);
@@ -223,6 +240,21 @@
 
             return view;
         }
+
+        private boolean isReply(Cursor cursor) {
+
+            /*
+             * Comparing the message timestamp to the thread timestamp rather than checking the
+             * in_reply_to field.  The rationale for this approach is that in the case when the
+             * original message to which the reply was posted is missing, we want to display
+             * the message as if it was an original; otherwise it would appear to be a reply
+             * to whatever message preceded it in the list.  In the case when the original message
+             * of the thread is missing, the two timestamps will be the same.
+             */
+            long published = cursor.getLong(COL_PUBLISHED);
+            long threadPublished = cursor.getLong(COL_THREAD_PUBLISHED);
+            return published != threadPublished;
+        }
     }
 
     /**