From 11f09bb5cd45a76ae7757b6f20807e836c3692f8 Mon Sep 17 00:00:00 2001 From: Bjorn Bringert Date: Mon, 5 Oct 2009 21:00:53 +0100 Subject: [PATCH] Don't reinflate search bar when dialog is already showing Change https://android-git.corp.google.com/g/27729 started reinflating the entire search bar every time the search source was changed, to get around problems with bad state in AutoCompleteTextView (http://b/issue?id=2132686). This had some side-effects if the search dialog was already visible, as it is when selecting a source in "More results" or when presing the search key to go to QSB from in-app search. This change changes the reinflation to only happen if the dialog is not already showing. Fixes: http://b/issue?id=2166640 "After selecting More results from suggestions, the search box is no longer visible." http://b/issue?id=2166675 "Calling QSB with the hardware key does not place focus in the search tab." http://b/issue?id=2166712 "back key has unexpected behaviour in QSB after selecting "More results" from suggestions." Change-Id: I8d48149c3e9ad97ec11c49ec7efb356f27dfe4f6 --- core/java/android/app/SearchDialog.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 605647aa41df5..933c2fc2fa794 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -364,10 +364,12 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mGlobalSearchMode = globalSearch || searchManager.isDefaultSearchable(mSearchable); mActivityContext = mSearchable.getActivityContext(getContext()); - createContentView(); - // show the dialog. this will call onStart(). - if (!isShowing()) { + if (!isShowing()) { + // Recreate the search bar view every time the dialog is shown, to get rid + // of any bad state in the AutoCompleteTextView etc + createContentView(); + // The Dialog uses a ContextThemeWrapper for the context; use this to change the // theme out from underneath us, between the global search theme and the in-app // search theme. They are identical except that the global search theme does not