From f28d1875741d1845df45808e143f3a850e66f893 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 26 Jul 2011 12:21:03 -0700 Subject: Make sure that suggestions are queried on focus or tapping. Bug: 3110831 Change-Id: Ic74a7eac1c5aa7d07c8a2e3f1ad19e026c990153 --- core/java/android/widget/SearchView.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 55b73df..a630430 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -221,6 +221,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { mCloseButton.setOnClickListener(mOnClickListener); mSubmitButton.setOnClickListener(mOnClickListener); mVoiceButton.setOnClickListener(mOnClickListener); + mQueryTextView.setOnClickListener(mOnClickListener); mQueryTextView.addTextChangedListener(mTextWatcher); mQueryTextView.setOnEditorActionListener(mOnEditorActionListener); @@ -319,7 +320,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { // If it is not iconified, then give the focus to the text field if (!isIconified()) { boolean result = mQueryTextView.requestFocus(direction, previouslyFocusedRect); - if (result) updateViewsVisibility(false); + if (result) { + updateViewsVisibility(false); + } return result; } else { return super.requestFocus(direction, previouslyFocusedRect); @@ -681,6 +684,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { onSubmitQuery(); } else if (v == mVoiceButton) { onVoiceClicked(); + } else if (v == mQueryTextView) { + forceSuggestionQuery(); } } }; @@ -1029,6 +1034,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { void onTextFocusChanged() { updateViewsVisibility(isIconified()); updateFocusedState(mQueryTextView.hasFocus()); + if (mQueryTextView.hasFocus()) { + forceSuggestionQuery(); + } } @Override @@ -1376,6 +1384,11 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { } } + private void forceSuggestionQuery() { + mQueryTextView.doBeforeTextChanged(); + mQueryTextView.doAfterTextChanged(); + } + static boolean isLandscapeMode(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; -- cgit v1.1