Merge change 26115 into eclair

* changes:
  Change to use depressed chiclet when showing diambig resolve list. Fixes bug # 2093651
diff --git a/res/layout-finger/fasttrack_item.xml b/res/layout-finger/fasttrack_item.xml
index e4d130e..e820a03 100644
--- a/res/layout-finger/fasttrack_item.xml
+++ b/res/layout-finger/fasttrack_item.xml
@@ -14,7 +14,8 @@
      limitations under the License.
 -->
 
-<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.contacts.ui.CheckableImageView 
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="59dip"
     android:layout_height="52dip"
     android:paddingLeft="12dip"
diff --git a/src/com/android/contacts/ui/CheckableImageView.java b/src/com/android/contacts/ui/CheckableImageView.java
new file mode 100644
index 0000000..257e407
--- /dev/null
+++ b/src/com/android/contacts/ui/CheckableImageView.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+package com.android.contacts.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.Checkable;
+import android.widget.ImageView;
+
+/**
+ * A special variation of ImageView that can be used as a checkable object.
+ * This is used as the background view of fasttrack chiclet, which is in checked state
+ * when disambig list is shown. Otherwise, it works identically to a ImageView.
+ */
+public class CheckableImageView extends ImageView implements Checkable {
+    private boolean mChecked;
+
+    private static final int[] CHECKED_STATE_SET = {
+        android.R.attr.state_checked
+    };
+
+    public CheckableImageView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    public int[] onCreateDrawableState(int extraSpace) {
+        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
+        if (isChecked()) {
+            mergeDrawableStates(drawableState, CHECKED_STATE_SET);
+        }
+        return drawableState;
+    }
+
+    public void toggle() {
+        setChecked(!mChecked);
+    }
+    
+    public boolean isChecked() {
+        return mChecked;
+    }
+
+    public void setChecked(boolean checked) {
+        if (mChecked != checked) {
+            mChecked = checked;
+            refreshDrawableState();
+        }
+    }
+}
diff --git a/src/com/android/contacts/ui/FastTrackWindow.java b/src/com/android/contacts/ui/FastTrackWindow.java
index d4aad19..bad8a21 100644
--- a/src/com/android/contacts/ui/FastTrackWindow.java
+++ b/src/com/android/contacts/ui/FastTrackWindow.java
@@ -133,6 +133,7 @@
     private View mFooter;
     private View mFooterDisambig;
     private ListView mResolveList;
+    private CheckableImageView mLastChiclet;
 
     /**
      * Set of {@link Action} that are associated with the aggregate currently
@@ -348,6 +349,9 @@
             mWindow.closeAllPanels();
         }
 
+        // Release refrence to last chiclet.
+        mLastChiclet = null;
+
         // Completely hide header from current mode
         mHeader.setVisibility(View.GONE);
 
@@ -931,7 +935,7 @@
      * the icon provided by the {@link DataKind}.
      */
     private View inflateAction(String mimeType) {
-        ImageView view = (ImageView)mInflater.inflate(R.layout.fasttrack_item, mTrack, false);
+        CheckableImageView view = (CheckableImageView)mInflater.inflate(R.layout.fasttrack_item, mTrack, false);
 
         // Add direct intent if single child, otherwise flag for multiple
         ActionList children = mActions.get(mimeType);
@@ -982,14 +986,17 @@
             // If showing list, then hide and save state of down arrow
             mWasDownArrow = mWasDownArrow || (mArrowDown.getVisibility() == View.VISIBLE);
             mArrowDown.setVisibility(View.INVISIBLE);
+	    mLastChiclet.setChecked(true);
         } else {
             // If hiding list, restore any down arrow state
             mArrowDown.setVisibility(mWasDownArrow ? View.VISIBLE : View.INVISIBLE);
+	    mLastChiclet.setChecked(false);
         }
     }
 
     /** {@inheritDoc} */
     public void onClick(View v) {
+        mLastChiclet = (CheckableImageView)v;
         final Object tag = v.getTag();
         if (tag instanceof Intent) {
             // Hide the resolution list, if present