Adding thumbnail and link.
Cutting corners for the sake of expedient prototyping.
diff --git a/res/layout-finger/social_list_item.xml b/res/layout-finger/social_list_item.xml
index cd92ce5..92dcfce 100644
--- a/res/layout-finger/social_list_item.xml
+++ b/res/layout-finger/social_list_item.xml
@@ -16,8 +16,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="2dip">
+ android:layout_height="wrap_content">
<ImageView
android:id="@+id/sourceIcon"
@@ -28,7 +27,7 @@
android:layout_centerVertical="true"
android:layout_marginTop="2dip"
android:layout_marginLeft="5dip"
- android:layout_marginRight="5dip"
+ android:layout_marginRight="8dip"
android:gravity="center"
android:scaleType="centerInside"
@@ -49,31 +48,56 @@
android:scaleType="fitCenter"
/>
- <TextView
- android:id="@+id/content"
+ <LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/photo"
android:layout_toLeftOf="@id/sourceIcon"
- 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"
- />
+ android:paddingBottom="2dip"
+ android:orientation="vertical"
+ >
+
+ <TextView
+ android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+
+ android:lineSpacingMultiplier="0.9"
+ android:maxLines="6"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+
+ <TextView
+ android:id="@+id/summary"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+
+ android:maxLines="2"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="#39F"
+ />
+
+ <ImageView
+ android:id="@+id/thumbnail"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="30dip"
+
+ android:maxHeight="54dip"
+ android:maxWidth="100dip"
+ android:scaleType="fitStart"
+ />
+
+ <TextView
+ android:id="@+id/published"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+
+ android:lines="1"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="#999"
+ />
+ </LinearLayout>
</RelativeLayout>
diff --git a/res/layout-finger/social_list_item_reply.xml b/res/layout-finger/social_list_item_reply.xml
index b508f16..5b21768 100644
--- a/res/layout-finger/social_list_item_reply.xml
+++ b/res/layout-finger/social_list_item_reply.xml
@@ -28,38 +28,63 @@
android:layout_centerVertical="true"
android:layout_marginTop="1dip"
android:layout_marginRight="8dip"
- android:layout_marginLeft="58dip"
+ android:layout_marginLeft="50dip"
android:background="@drawable/contact_picture_border_in_list"
android:gravity="center"
android:scaleType="fitCenter"
/>
- <TextView
- android:id="@+id/content"
+ <LinearLayout
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"
- />
-
+ android:paddingBottom="2dip"
+ android:orientation="vertical"
+ >
+
+ <TextView
+ android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+
+ android:lineSpacingMultiplier="0.9"
+ android:maxLines="6"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+
+ <TextView
+ android:id="@+id/summary"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+
+ android:maxLines="2"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="#39F"
+ />
+
+ <ImageView
+ android:id="@+id/thumbnail"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="30dip"
+
+ android:maxHeight="54dip"
+ android:maxWidth="100dip"
+ android:scaleType="fitStart"
+ />
+
+ <TextView
+ android:id="@+id/published"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+
+ android:lines="1"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="#999"
+ />
+ </LinearLayout>
</RelativeLayout>
diff --git a/src/com/android/contacts/SocialStreamActivity.java b/src/com/android/contacts/SocialStreamActivity.java
index 157100e..9412287 100644
--- a/src/com/android/contacts/SocialStreamActivity.java
+++ b/src/com/android/contacts/SocialStreamActivity.java
@@ -32,6 +32,7 @@
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -57,6 +58,7 @@
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
+import android.widget.ListView;
import android.widget.TextView;
import java.io.IOException;
@@ -78,6 +80,8 @@
Activities.TITLE,
Activities.SUMMARY,
Activities.THREAD_PUBLISHED,
+ Activities.LINK,
+ Activities.THUMBNAIL,
};
private static final int COL_ID = 0;
@@ -90,8 +94,11 @@
private static final int COL_TITLE = 7;
private static final int COL_SUMMARY = 8;
private static final int COL_THREAD_PUBLISHED = 9;
+ private static final int COL_LINK = 10;
+ private static final int COL_THUMBNAIL = 11;
- public static final int PHOTO_SIZE = 58;
+ public static final int PHOTO_SIZE = 54;
+ public static final int THUMBNAIL_SIZE = 54;
private ListAdapter mAdapter;
@@ -145,6 +152,19 @@
}
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ Cursor cursor = (Cursor)getListAdapter().getItem(position);
+
+ // TODO check mime type and if it is supported, launch the corresponding app
+ String link = cursor.getString(COL_LINK);
+ if (link == null) {
+ return;
+ }
+
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
+ }
+
/**
* List adapter for social stream data queried from
* {@link Activities#CONTENT_URI}.
@@ -161,6 +181,8 @@
ImageView sourceIcon;
TextView content;
SpannableStringBuilder contentBuilder = new SpannableStringBuilder();
+ TextView summary;
+ ImageView thumbnail;
TextView published;
}
@@ -192,7 +214,9 @@
long contactId = cursor.getLong(COL_AUTHOR_CONTACT_ID);
String name = cursor.getString(COL_DISPLAY_NAME);
String title = cursor.getString(COL_TITLE);
+ String summary = cursor.getString(COL_SUMMARY);
long published = cursor.getLong(COL_PUBLISHED);
+ byte[] thumbnailBlob = cursor.getBlob(COL_THUMBNAIL);
// TODO: trigger async query to find actual name and photo instead
// of using this lazy caching mechanism
@@ -209,6 +233,22 @@
holder.contentBuilder.setSpan(mTextStyleName, 0, name.length(), 0);
holder.content.setText(holder.contentBuilder);
+ if (summary == null) {
+ holder.summary.setVisibility(View.GONE);
+ } else {
+ holder.summary.setText(summary);
+ holder.summary.setVisibility(View.VISIBLE);
+ }
+
+ if (thumbnailBlob != null) {
+ Bitmap thumbnail =
+ BitmapFactory.decodeByteArray(thumbnailBlob, 0, thumbnailBlob.length);
+ holder.thumbnail.setImageBitmap(thumbnail);
+ holder.thumbnail.setVisibility(View.VISIBLE);
+ } else {
+ holder.thumbnail.setVisibility(View.GONE);
+ }
+
CharSequence relativePublished = DateUtils.getRelativeTimeSpanString(published,
System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
holder.published.setText(relativePublished);
@@ -235,6 +275,8 @@
holder.photo = (ImageView) view.findViewById(R.id.photo);
holder.sourceIcon = (ImageView) view.findViewById(R.id.sourceIcon);
holder.content = (TextView) view.findViewById(R.id.content);
+ holder.summary = (TextView) view.findViewById(R.id.summary);
+ holder.thumbnail = (ImageView) view.findViewById(R.id.thumbnail);
holder.published = (TextView) view.findViewById(R.id.published);
view.setTag(holder);