Added text name and photo to fast-track dialog.
diff --git a/res/layout-finger/fasttrack.xml b/res/layout-finger/fasttrack.xml
index 23e6be1..cf6b3d0 100644
--- a/res/layout-finger/fasttrack.xml
+++ b/res/layout-finger/fasttrack.xml
@@ -14,17 +14,47 @@
limitations under the License.
-->
-<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:fadingEdgeLength="40dip"
- android:scrollbars="none">
+ android:orientation="vertical">
- <LinearLayout
- android:id="@+id/fasttrack"
+ <ImageView
+ android:id="@+id/photo"
+ android:layout_width="32dip"
+ android:layout_height="32dip"
+ android:layout_marginLeft="4dip"
+ android:layout_marginTop="4dip"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/displayname"
+ android:layout_toRightOf="@id/photo"
+ android:layout_alignTop="@id/photo"
+ android:layout_alignBottom="@id/photo"
+ android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:padding="4dip"
- android:orientation="horizontal" />
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip"
+ android:textSize="18dip"
+ android:textStyle="bold" />
-</HorizontalScrollView>
+ <HorizontalScrollView
+ android:layout_below="@id/photo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fadingEdgeLength="40dip"
+ android:padding="4dip"
+ android:scrollbars="none">
+
+ <LinearLayout
+ android:id="@+id/fasttrack"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" />
+
+ </HorizontalScrollView>
+
+</RelativeLayout>
+
diff --git a/src/com/android/contacts/FastTrackWindow.java b/src/com/android/contacts/FastTrackWindow.java
index 4b7bbd8..0cf9daf 100644
--- a/src/com/android/contacts/FastTrackWindow.java
+++ b/src/com/android/contacts/FastTrackWindow.java
@@ -21,11 +21,13 @@
import com.android.contacts.SocialStreamActivity.MappingCache;
import com.android.contacts.SocialStreamActivity.MappingCache.Mapping;
import com.android.providers.contacts2.ContactsContract;
+import com.android.providers.contacts2.ContactsContract.Aggregates;
import com.android.providers.contacts2.ContactsContract.CommonDataKinds;
import com.android.providers.contacts2.ContactsContract.Data;
import com.android.providers.contacts2.ContactsContract.CommonDataKinds.Email;
import com.android.providers.contacts2.ContactsContract.CommonDataKinds.Im;
import com.android.providers.contacts2.ContactsContract.CommonDataKinds.Phone;
+import com.android.providers.contacts2.ContactsContract.CommonDataKinds.Photo;
import com.android.providers.contacts2.ContactsContract.CommonDataKinds.Postal;
import android.content.ActivityNotFoundException;
@@ -34,6 +36,8 @@
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.Log;
import android.view.Gravity;
@@ -82,6 +86,7 @@
private boolean mShowing = false;
private boolean mHasPosition = false;
+ private boolean mHasDisplayName = false;
private boolean mHasData = false;
public static final int ICON_SIZE = 42;
@@ -91,7 +96,8 @@
private int mFirstX;
private int mFirstY;
- private static final int TOKEN = 1;
+ private static final int TOKEN_DISPLAY_NAME = 1;
+ private static final int TOKEN_DATA = 2;
private static final int GRAVITY = Gravity.LEFT | Gravity.TOP;
@@ -152,8 +158,10 @@
mDataUri = Uri.withAppendedPath(aggUri, ContactsContract.Aggregates.Data.CONTENT_DIRECTORY);
mHandler = new NotifyingAsyncQueryHandler(context, this);
- mHandler.startQuery(TOKEN, null, mDataUri, null, null, null, null);
+ mHandler.startQuery(TOKEN_DISPLAY_NAME, null, aggUri, null, null, null, null);
+ mHandler.startQuery(TOKEN_DATA, null, mDataUri, null, null, null, null);
+ // TODO: poll around for latest status message or location details
}
/**
@@ -161,7 +169,7 @@
* completed query results.
*/
private synchronized void considerShowing() {
- if (mHasData && mHasPosition && !mShowing) {
+ if (mHasData && mHasPosition && mHasDisplayName && !mShowing) {
mShowing = true;
showAtLocation(mParent, GRAVITY, mFirstX, mFirstY);
}
@@ -185,6 +193,40 @@
/** {@inheritDoc} */
public void onQueryComplete(int token, Object cookie, Cursor cursor) {
+ if (cursor == null) {
+ return;
+ }
+ switch (token) {
+ case TOKEN_DISPLAY_NAME:
+ handleDisplayName(cursor);
+ break;
+ case TOKEN_DATA:
+ handleData(cursor);
+ break;
+ }
+ considerShowing();
+ }
+
+ /**
+ * Handle the result from the {@link TOKEN_DISPLAY_NAME} query.
+ */
+ private void handleDisplayName(Cursor cursor) {
+ final TextView displayname = (TextView)mContent.findViewById(R.id.displayname);
+ final int COL_DISPLAY_NAME = cursor.getColumnIndex(Aggregates.DISPLAY_NAME);
+
+ if (cursor.moveToNext()) {
+ String foundName = cursor.getString(COL_DISPLAY_NAME);
+ displayname.setText(foundName);
+ }
+
+ mHasDisplayName = true;
+ }
+
+ /**
+ * Handle the result from the {@link TOKEN_DATA} query.
+ */
+ private void handleData(Cursor cursor) {
+ final ImageView photo = (ImageView)mContent.findViewById(R.id.photo);
final ViewGroup fastTrack = (ViewGroup)mContent.findViewById(R.id.fasttrack);
// Build list of actions for this contact, this could be done better in
@@ -194,12 +236,25 @@
final int COL_ID = cursor.getColumnIndex(Data._ID);
final int COL_PACKAGE = cursor.getColumnIndex(Data.PACKAGE);
final int COL_MIMETYPE = cursor.getColumnIndex(Data.MIMETYPE);
+ final int COL_PHOTO = cursor.getColumnIndex(Photo.PHOTO);
+
+ boolean foundDisplayName = false;
+ boolean foundPhoto = false;
while (cursor.moveToNext()) {
final long dataId = cursor.getLong(COL_ID);
final String packageName = cursor.getString(COL_PACKAGE);
final String mimeType = cursor.getString(COL_MIMETYPE);
+ // Handle finding the photo among various return rows
+ if (!foundPhoto && Photo.CONTENT_ITEM_TYPE.equals(mimeType)) {
+ byte[] photoBlob = cursor.getBlob(COL_PHOTO);
+ Bitmap photoBitmap = BitmapFactory.decodeByteArray(photoBlob, 0, photoBlob.length);
+ photo.setImageBitmap(photoBitmap);
+ photo.setVisibility(View.VISIBLE);
+ foundPhoto = true;
+ }
+
ImageView action;
// First, try looking in mapping cache for possible icon match
@@ -262,7 +317,6 @@
}
mHasData = true;
- considerShowing();
}
/**