OSDN Git Service

Absorbing extra key events on contact search.
authorDmitri Plotnikov <dplotnikov@google.com>
Fri, 2 Apr 2010 02:33:24 +0000 (19:33 -0700)
committerDmitri Plotnikov <dplotnikov@google.com>
Fri, 2 Apr 2010 02:33:24 +0000 (19:33 -0700)
When contact search is started from a keyboard,
we start a search activity, but subsequent key events
are still coming to the original activity and
it just keeps launching new search activities.

Discussed this with Dianne.  The only available solution
in FroYo is to swallow the extra events.

This CL does just that.

Bug: 2565998

Change-Id: Ib9318ad4832e950172af5a3999194bc14321938b

src/com/android/contacts/ContactsListActivity.java

index 6fd03f7..aeb4014 100644 (file)
@@ -452,6 +452,7 @@ public class ContactsListActivity extends ListActivity implements View.OnCreateC
     private boolean mShowNumberOfContacts;
 
     private boolean mShowSearchSnippets;
+    private boolean mSearchInitiated;
 
     private String mInitialFilter;
 
@@ -1058,6 +1059,7 @@ public class ContactsListActivity extends ListActivity implements View.OnCreateC
             startQuery();
         }
         mJustCreated = false;
+        mSearchInitiated = false;
     }
 
     /**
@@ -1651,9 +1653,10 @@ public class ContactsListActivity extends ListActivity implements View.OnCreateC
      * bringing up the search UI first.
      */
     public boolean onKey(View v, int keyCode, KeyEvent event) {
-        if (!mSearchMode && (mMode & MODE_MASK_NO_FILTER) == 0) {
+        if (!mSearchMode && (mMode & MODE_MASK_NO_FILTER) == 0 && !mSearchInitiated) {
             int unicodeChar = event.getUnicodeChar();
             if (unicodeChar != 0) {
+                mSearchInitiated = true;
                 startSearch(new String(new int[]{unicodeChar}, 0, 1), false, null, false);
                 return true;
             }