Eliminating selection delay when query comes from intent.
We want to delay automatic selection of the first
result when the user is typing in order to prevent
flashing UI. However when the query string is sent
to Contacts as part of an intent, such delay is unnecessary.
Change-Id: I55afd4b435e46fbd701eb6a514bcf0f85b963409
diff --git a/src/com/android/contacts/list/ContactBrowseListFragment.java b/src/com/android/contacts/list/ContactBrowseListFragment.java
index 1d92cab..9b99639 100644
--- a/src/com/android/contacts/list/ContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/ContactBrowseListFragment.java
@@ -137,6 +137,8 @@
private ContactUriQueryHandler mQueryHandler;
+ private boolean mDelaySelection;
+
private Handler getHandler() {
if (mHandler == null) {
mHandler = new Handler() {
@@ -288,6 +290,12 @@
setSelectedContactUri(uri, true, true, true, false);
}
+ @Override
+ public void setQueryString(String queryString, boolean delaySelection) {
+ mDelaySelection = delaySelection;
+ super.setQueryString(queryString, delaySelection);
+ }
+
/**
* Sets the new contact selection.
*
@@ -436,14 +444,14 @@
mLastSelectedPosition = selectedPosition;
} else {
if (isSearchMode()) {
- selectFirstFoundContactAfterDelay();
- if (mListener != null) {
- mListener.onSelectionChange();
+ if (mDelaySelection) {
+ selectFirstFoundContactAfterDelay();
+ if (mListener != null) {
+ mListener.onSelectionChange();
+ }
+ return;
}
- return;
- }
-
- if (mSelectionRequired) {
+ } else if (mSelectionRequired) {
// A specific contact was requested, but it's not in the loaded list.
// Try reconfiguring and reloading the list that will hopefully contain
@@ -460,12 +468,10 @@
notifyInvalidSelection();
}
return;
- }
-
- // If we were trying to load a specific contact, but that contact no longer
- // exists, call the listener, which will adjust the filter.
- if (mFilter != null
+ } else if (mFilter != null
&& mFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
+ // If we were trying to load a specific contact, but that contact no longer
+ // exists, call the listener, which will adjust the filter.
notifyInvalidSelection();
return;
}