Move social snippet and date to updates fragment

- Now the phone landscape view shows the social update
- Make updates tab show 3 lines of the social update
(no status date)
- Remove empty "no updates" view in updates fragment
(if there are no updates, the updates tab shouldn't
even appear)
- Remove star in "about" tab because it's been moved
to the action bar
- TODO: Make this a list of updates when social
integration is ready

Change-Id: I60cf15edb58b8818c63e6fe9b5fec01f64fca563
diff --git a/res/layout/carousel_about_tab.xml b/res/layout/carousel_about_tab.xml
index f1ed4f1..bf67ee2 100644
--- a/res/layout/carousel_about_tab.xml
+++ b/res/layout/carousel_about_tab.xml
@@ -50,17 +50,4 @@
         android:textColor="@color/detail_header_view_text_color"
         style="@android:style/Widget.Holo.ActionBar.TabView" />
 
-    <CheckBox
-        android:id="@+id/star"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="10dip"
-        android:layout_marginRight="10dip"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentRight="true"
-        android:layout_gravity="center_vertical"
-        android:contentDescription="@string/description_star"
-        android:visibility="invisible"
-        style="?android:attr/starStyle"/>
-
 </RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/carousel_updates_tab.xml b/res/layout/carousel_updates_tab.xml
index 9deb2f7..9da2272 100644
--- a/res/layout/carousel_updates_tab.xml
+++ b/res/layout/carousel_updates_tab.xml
@@ -45,22 +45,16 @@
 
     <TextView android:id="@+id/status"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:layout_height="match_parent"
         android:layout_alignParentTop="true"
         android:layout_alignParentLeft="true"
-        android:layout_marginTop="@dimen/detail_update_tab_vertical_margin"
+        android:layout_above="@id/label"
+        android:gravity="center_vertical"
         android:paddingLeft="@dimen/detail_update_tab_side_padding"
         android:paddingRight="@dimen/detail_update_tab_side_padding"
-        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textAppearance="?android:attr/textAppearanceLarge"
+        android:textColor="@color/detail_update_tab_text_color"
+        android:textStyle="bold"
         android:maxLines="3"/>
 
-    <TextView android:id="@+id/status_date"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_below="@+id/status"
-        android:layout_marginBottom="@dimen/detail_update_tab_vertical_margin"
-        android:paddingLeft="@dimen/detail_update_tab_side_padding"
-        android:paddingRight="@dimen/detail_update_tab_side_padding"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textColor="?android:attr/textColorTertiary"/>
 </RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/contact_detail_updates_fragment.xml b/res/layout/contact_detail_updates_fragment.xml
index e9c36f3..36a40c3 100644
--- a/res/layout/contact_detail_updates_fragment.xml
+++ b/res/layout/contact_detail_updates_fragment.xml
@@ -16,20 +16,43 @@
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/contact_detail_updates_fragment"
-    android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <TextView android:id="@+id/emptyText"
+    <!--
+      TODO: Make this a list of social updates instead of just showing one update. Wait
+      until the social integration is done in the provider so that we know the
+      best way to setup the adapter.
+    -->
+    <LinearLayout
+        android:orientation="vertical"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/no_contact_details"
-        android:textSize="20sp"
-        android:textColor="?android:attr/textColorSecondary"
-        android:paddingLeft="10dip"
-        android:paddingRight="10dip"
+        android:layout_height="match_parent"
         android:paddingTop="@dimen/detail_tab_carousel_height"
-        android:layout_marginTop="10dip"/>
+        android:background="@color/background_primary">
+
+        <include
+            android:id="@+id/title"
+            layout="@layout/contact_detail_kind_title_entry_view"
+            android:paddingTop="@dimen/detail_item_vertical_margin" />
+
+        <TextView android:id="@+id/status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingTop="@dimen/detail_item_vertical_margin"
+            android:paddingLeft="@dimen/detail_item_side_margin"
+            android:paddingRight="@dimen/detail_item_side_margin"
+            android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+        <TextView android:id="@+id/status_date"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingLeft="@dimen/detail_item_side_margin"
+            android:paddingRight="@dimen/detail_item_side_margin"
+            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:textColor="?android:attr/textColorTertiary"/>
+
+    </LinearLayout>
 
     <View
         android:id="@+id/alpha_overlay"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 496d55f..5641d35 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -54,4 +54,7 @@
 
     <!-- Color of the background of the tabs on the contact detail page -->
     <color name="detail_tab_background">#DBDBDB</color>
+
+    <!-- Color of the text in the updates tab in the tab carousel on the contact detail page -->
+    <color name="detail_update_tab_text_color">#777777</color>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 7ab889c..eb40382 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -101,10 +101,10 @@
     <dimen name="detail_fragment_carousel_fragment_width">420dip</dimen>
 
     <!-- Vertical margin of the text within the update tab in the tab carousel -->
-    <dimen name="detail_update_tab_vertical_margin">20dip</dimen>
+    <dimen name="detail_update_tab_vertical_margin">32dip</dimen>
 
     <!-- Left and right padding of the text within the update tab in the tab carousel -->
-    <dimen name="detail_update_tab_side_padding">10dip</dimen>
+    <dimen name="detail_update_tab_side_padding">24dip</dimen>
 
     <!-- Margin around the contact's photo on the contact card -->
     <dimen name="detail_contact_photo_margin">15dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0e47ebb..0064a8b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1265,6 +1265,9 @@
     <!-- Title for the list of all contact details that come from third-party sources (including a corporate directory) [CHAR LIMIT=20] -->
     <string name="network">Network</string>
 
+    <!-- Section title for the page containing the contact's social updates on the contact card [CHAR LIMIT=20]-->
+    <string name="recent_updates">Recent</string>
+
     <!-- String describing which account type a contact came from when editing it -->
     <string name="account_type_format"><xliff:g id="source" example="Gmail">%1$s</xliff:g> contact</string>
 
diff --git a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
index 357350d..3f28b58 100644
--- a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
+++ b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
@@ -205,6 +205,16 @@
     }
 
     /**
+     * Set the social snippet text. If there isn't one, then set the view to gone.
+     */
+    public static void setSocialSnippet(Context context, Result contactData, TextView statusView) {
+        if (statusView == null) {
+            return;
+        }
+        setDataOrHideIfNone(contactData.getSocialSnippet(), statusView);
+    }
+
+    /**
      * Set the social snippet text and date. If there isn't one, then set the view to gone.
      */
     public static void setSocialSnippetAndDate(Context context, Result contactData,
diff --git a/src/com/android/contacts/detail/ContactDetailTabCarousel.java b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
index 161ae32..2ce26c6 100644
--- a/src/com/android/contacts/detail/ContactDetailTabCarousel.java
+++ b/src/com/android/contacts/detail/ContactDetailTabCarousel.java
@@ -17,18 +17,14 @@
 package com.android.contacts.detail;
 
 import com.android.contacts.ContactLoader;
-import com.android.contacts.ContactSaveService;
 import com.android.contacts.R;
 
 import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnTouchListener;
-import android.widget.CheckBox;
 import android.widget.HorizontalScrollView;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -44,7 +40,6 @@
 
     private ImageView mPhotoView;
     private TextView mStatusView;
-    private TextView mStatusDateView;
 
     private Listener mListener;
 
@@ -189,13 +184,11 @@
         // Retrieve the photo view for the "about" tab
         mPhotoView = (ImageView) aboutView.findViewById(R.id.photo);
 
-        // Retrieve the social update views for the "updates" tab
+        // Retrieve the social update view for the "updates" tab
         mStatusView = (TextView) updateView.findViewById(R.id.status);
-        mStatusDateView = (TextView) updateView.findViewById(R.id.status_date);
 
         ContactDetailDisplayUtils.setPhoto(mContext, contactData, mPhotoView);
-        ContactDetailDisplayUtils.setSocialSnippetAndDate(mContext, contactData, mStatusView,
-                mStatusDateView);
+        ContactDetailDisplayUtils.setSocialSnippet(mContext, contactData, mStatusView);
     }
 
     /**
diff --git a/src/com/android/contacts/detail/ContactDetailUpdatesFragment.java b/src/com/android/contacts/detail/ContactDetailUpdatesFragment.java
index 1f29957..85dcc1d 100644
--- a/src/com/android/contacts/detail/ContactDetailUpdatesFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailUpdatesFragment.java
@@ -27,6 +27,7 @@
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
+import android.widget.TextView;
 
 public class ContactDetailUpdatesFragment extends Fragment
         implements FragmentKeyListener, FragmentOverlay {
@@ -36,6 +37,9 @@
     private ContactLoader.Result mContactData;
     private Uri mLookupUri;
 
+    private TextView mStatusView;
+    private TextView mStatusDateView;
+
     /**
      * This optional view adds an alpha layer over the entire fragment.
      */
@@ -56,6 +60,21 @@
         View rootView = inflater.inflate(R.layout.contact_detail_updates_fragment, container,
                 false);
 
+        TextView titleTextView = (TextView) rootView.findViewById(R.id.kind);
+        titleTextView.setText(getString(R.string.recent_updates).toUpperCase());
+
+        mStatusView = (TextView) rootView.findViewById(R.id.status);
+        mStatusDateView = (TextView) rootView.findViewById(R.id.status_date);
+
+        // It is possible that the contact data was set to the fragment when it was first attached
+        // to the activity, but before this method was called because the fragment was not
+        // visible on screen yet (i.e. using a {@link ViewPager}), so display the data if we already
+        // have it.
+        if (mContactData != null) {
+            ContactDetailDisplayUtils.setSocialSnippetAndDate(getActivity(), mContactData,
+                    mStatusView, mStatusDateView);
+        }
+
         mAlphaLayer = rootView.findViewById(R.id.alpha_overlay);
         mTouchInterceptLayer = rootView.findViewById(R.id.touch_intercept_overlay);
 
@@ -63,9 +82,13 @@
     }
 
     public void setData(Uri lookupUri, ContactLoader.Result result) {
+        if (result == null) {
+            return;
+        }
         mLookupUri = lookupUri;
         mContactData = result;
-        // TODO: Load up the "recent updates" section based on the result
+        ContactDetailDisplayUtils.setSocialSnippetAndDate(getActivity(), mContactData,
+                mStatusView, mStatusDateView);
     }
 
     @Override