Added ListView for fast-track resolution.
diff --git a/res/layout-finger/fasttrack.xml b/res/layout-finger/fasttrack.xml
index c7efac8..9c9ab98 100644
--- a/res/layout-finger/fasttrack.xml
+++ b/res/layout-finger/fasttrack.xml
@@ -40,41 +40,25 @@
android:layout_height="40dip"
android:layout_marginLeft="4dip"
android:background="@drawable/frame_sm_track"
- android:scaleType="fitCenter" />
-
- <ImageView
- android:id="@+id/presence"
- android:layout_width="wrap_content"
- android:layout_height="42dip"
- android:layout_marginRight="8dip"
- android:layout_marginTop="4dip"
- android:layout_alignParentRight="true"
- android:src="@android:drawable/presence_online"
- android:scaleType="centerInside" />
+ android:scaleType="fitCenter" />
<LinearLayout
android:layout_width="0dip"
- android:layout_toLeftOf="@id/presence"
+ android:layout_toLeftOf="@id/presence"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="8dip"
android:paddingRight="8dip"
- android:textColor="#f000"
+ android:orientation="vertical">
-
- <TextView
- android:id="@+id/status"
- android:layout_toRightOf="@id/photo"
- android:layout_toLeftOf="@id/presence"
- android:layout_below="@id/displayname"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
- android:maxLines="2"
- android:ellipsize="end"
- android:textColor="#f000"
- android:textSize="14dip" />
+ <TextView
+ android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:textColor="#f000"
+ android:textSize="14dip" />
<TextView
android:id="@+id/published"
@@ -96,8 +80,9 @@
android:scaleType="centerInside" />
</LinearLayout>
+
<HorizontalScrollView
- android:layout_below="@id/status"
+ android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdgeLength="40dip"
@@ -113,6 +98,16 @@
</HorizontalScrollView>
+ <ListView
+ android:id="@android:id/list"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/scroll"
+ android:layout_marginLeft="60dip"
+ android:visibility="gone"
+ android:background="#ff00"
+ />
+
<ImageView
android:id="@+id/arrow_down"
android:layout_width="wrap_content"
diff --git a/res/layout-finger/fasttrack_resolve_item.xml b/res/layout-finger/fasttrack_resolve_item.xml
new file mode 100755
index 0000000..f276511
--- /dev/null
+++ b/res/layout-finger/fasttrack_resolve_item.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:textAppearance="?android:attr/textAppearanceLargeInverse"
+ android:gravity="center_vertical"
+ android:drawablePadding="14dip"
+ android:paddingLeft="15dip"
+ android:paddingRight="15dip" />
diff --git a/src/com/android/contacts/FastTrackWindow.java b/src/com/android/contacts/FastTrackWindow.java
index 1252086..7758c87 100644
--- a/src/com/android/contacts/FastTrackWindow.java
+++ b/src/com/android/contacts/FastTrackWindow.java
@@ -40,6 +40,7 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.provider.Contacts.Phones;
import android.text.SpannableStringBuilder;
@@ -64,6 +65,8 @@
import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AbsListView;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -88,7 +91,7 @@
* Window that shows fast-track contact details for a specific
* {@link Aggregate#_ID}.
*/
-public class FastTrackWindow implements Window.Callback, QueryCompleteListener, OnClickListener {
+public class FastTrackWindow implements Window.Callback, QueryCompleteListener, OnClickListener, AbsListView.OnItemClickListener {
private static final String TAG = "FastTrackWindow";
/**
@@ -130,6 +133,7 @@
private TextView mContent;
private TextView mPublished;
private ViewGroup mTrack;
+ private ListView mResolveList;
// TODO: read from a resource somewhere
private static final int mHeight = 138;
@@ -196,6 +200,7 @@
mContent = (TextView)mWindow.findViewById(R.id.content);
mPublished = (TextView)mWindow.findViewById(R.id.published);
mTrack = (ViewGroup)mWindow.findViewById(R.id.fasttrack);
+ mResolveList = (ListView)mWindow.findViewById(android.R.id.list);
// TODO: move generation of mime-type cache to more-efficient place
generateMappingCache();
@@ -338,9 +343,9 @@
// Reset all views to prepare for possible recycling
mPhoto.setImageResource(R.drawable.ic_contact_list_picture);
- mPresence.setImageDrawable(null);
+// mPresence.setImageDrawable(null);
+// mPublished.setText(null);
mContent.setText(null);
- mPublished.setText(null);
mActions.clear();
mTrack.removeAllViews();
@@ -593,22 +598,31 @@
// Add direct intent if single child, otherwise flag for multiple
LinkedList<ActionInfo> children = mActions.get(mimeType);
ActionInfo firstInfo = children.get(0);
- if (children.size() == 1) {
+// if (children.size() == 1) {
view.setTag(firstInfo.buildIntent());
- } else {
- view.setTag(mimeType);
- }
+// } else {
+// view.setTag(children);
+// }
// Set icon and listen for clicks
view.setImageBitmap(firstInfo.mapping.icon);
view.setOnClickListener(this);
return view;
}
+
+ /** {@inheritDoc} */
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ // Pass list item clicks along so that Intents are handled uniformly
+ onClick(view);
+ }
/** {@inheritDoc} */
public void onClick(View v) {
final Object tag = v.getTag();
if (tag instanceof Intent) {
+ // Hide the resolution list, if present
+ mResolveList.setVisibility(View.GONE);
+
// Incoming tag is concrete intent, so launch
try {
mContext.startActivity((Intent)tag);
@@ -616,12 +630,48 @@
Log.w(TAG, NOT_FOUND);
Toast.makeText(mContext, NOT_FOUND, Toast.LENGTH_SHORT).show();
}
- } else if (tag instanceof String) {
- // Incoming tag is a mime-type, so show resolution list
- LinkedList<ActionInfo> children = mActions.get(tag);
-
- // TODO: show drop-down resolution list
- Log.d(TAG, "would show list between several options here");
+// } else if (tag instanceof LinkedList) {
+// // Incoming tag is a mime-type, so show resolution list
+// final LinkedList<ActionInfo> children = (LinkedList<ActionInfo>)tag;
+// Log.d(TAG, "found chidlren=" + children);
+//
+// mResolveList.setVisibility(View.VISIBLE);
+// mResolveList.setOnItemClickListener(this);
+// mResolveList.setAdapter(new BaseAdapter() {
+// public int getCount() {
+// return children.size();
+// }
+//
+// public Object getItem(int position) {
+// return children.get(position);
+// }
+//
+// public long getItemId(int position) {
+// return position;
+// }
+//
+// public View getView(int position, View convertView, ViewGroup parent) {
+// if (convertView == null) {
+// convertView = mInflater.inflate(R.layout.fasttrack_resolve_item, parent, false);
+// }
+//
+// // Set action title based on summary value
+// ActionInfo info = (ActionInfo)getItem(position);
+// TextView textView = (TextView)convertView;
+// textView.setText(info.summaryValue);
+// textView.setTag(info.buildIntent());
+// textView.setCompoundDrawablesWithIntrinsicBounds(
+// new BitmapDrawable(info.mapping.icon), null, null, null);
+//
+// return convertView;
+// }
+// });
+//
+// // Make sure we resize to make room for ListView
+// onWindowAttributesChanged(mWindow.getAttributes());
+//
+// // TODO: show drop-down resolution list
+// Log.d(TAG, "would show list between several options here");
}
}
diff --git a/src/com/android/contacts/ShowOrCreateActivity.java b/src/com/android/contacts/ShowOrCreateActivity.java
index 059a7ee..aa7a1c5 100755
--- a/src/com/android/contacts/ShowOrCreateActivity.java
+++ b/src/com/android/contacts/ShowOrCreateActivity.java
@@ -86,7 +86,7 @@
private static final String EXTRA_X = "pixel_x";
private static final String EXTRA_Y = "pixel_y";
private static final String EXTRA_HEIGHT = "pixel_height";
- private static final int DEFAULT_X = 0;
+ private static final int DEFAULT_X = 30;
private static final int DEFAULT_Y = 90;
private static final int DEFAULT_HEIGHT = 30;