From da1f4b669ead7813079643b43301f100127aaeed Mon Sep 17 00:00:00 2001 From: Bjorn Bringert Date: Tue, 28 Jul 2009 15:15:26 +0100 Subject: [PATCH] Only dismiss search on suggestion click in in-app search We now distinguish between in-app search (pivoted in from GlobalSearch) and real in-app search mode. Only the latter dismisses the search dialog when a suggestion is clicked. Also, the drop-down is now always visible except in real in-app search mode. Fixes http://b/issue?id=2014626 --- core/java/android/app/SearchDialog.java | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index dd70130eb9d03..34429fae876f8 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -244,7 +244,12 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS } return success; } - + + private boolean isInRealAppSearch() { + return !mGlobalSearchMode + && (mPreviousComponents == null || mPreviousComponents.isEmpty()); + } + /** * Called in response to a press of the hard search button in * {@link #onKeyDown(int, KeyEvent)}, this method toggles between in-app @@ -535,7 +540,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // we dismiss the entire dialog instead mSearchAutoComplete.setDropDownDismissedOnCompletion(false); - if (mGlobalSearchMode) { + if (!isInRealAppSearch()) { mSearchAutoComplete.setDropDownAlwaysVisible(true); // fill space until results come in } else { mSearchAutoComplete.setDropDownAlwaysVisible(false); @@ -1259,10 +1264,13 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS launchGlobalSearchIntent(intent); } else { getContext().startActivity(intent); - // in global search mode, SearchDialogWrapper#performActivityResuming + // If the search switches to a different activity, + // SearchDialogWrapper#performActivityResuming // will handle hiding the dialog when the next activity starts, but for - // in-app search, we still need to dismiss the dialog. - dismiss(); + // real in-app search, we still need to dismiss the dialog. + if (isInRealAppSearch()) { + dismiss(); + } } } catch (RuntimeException ex) { Log.e(LOG_TAG, "Failed launch activity: " + intent, ex); @@ -1401,13 +1409,13 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS return; } if (DBG) Log.d(LOG_TAG, "Switching to " + componentName); - - ComponentName previous = mLaunchComponent; + + pushPreviousComponent(mLaunchComponent); if (!show(componentName, mAppSearchData, false)) { Log.w(LOG_TAG, "Failed to switch to source " + componentName); + popPreviousComponent(); return; } - pushPreviousComponent(previous); String query = intent.getStringExtra(SearchManager.QUERY); setUserQuery(query);