Merge change Ic3aa7aa6 into eclair
* changes:
Recreate search dialog view each time it's shown.
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 1e9d5a1..36d3678 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -127,8 +127,8 @@
private ArrayList<ComponentName> mPreviousComponents;
// For voice searching
- private Intent mVoiceWebSearchIntent;
- private Intent mVoiceAppSearchIntent;
+ private final Intent mVoiceWebSearchIntent;
+ private final Intent mVoiceAppSearchIntent;
// support for AutoCompleteTextView suggestions display
private SuggestionsAdapter mSuggestionsAdapter;
@@ -156,18 +156,25 @@
*/
public SearchDialog(Context context) {
super(context, com.android.internal.R.style.Theme_GlobalSearchBar);
+
+ // Save voice intent for later queries/launching
+ mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
+ mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
+ RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
+
+ mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
+ mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
/**
- * We create the search dialog just once, and it stays around (hidden)
- * until activated by the user.
+ * Create the search dialog and any resources that are used for the
+ * entire lifetime of the dialog.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(com.android.internal.R.layout.search_bar);
-
Window theWindow = getWindow();
WindowManager.LayoutParams lp = theWindow.getAttributes();
lp.type = WindowManager.LayoutParams.TYPE_SEARCH_BAR;
@@ -180,6 +187,17 @@
lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
theWindow.setAttributes(lp);
+ // Touching outside of the search dialog will dismiss it
+ setCanceledOnTouchOutside(true);
+ }
+
+ /**
+ * We recreate the dialog view each time it becomes visible so as to limit
+ * the scope of any problems with the contained resources.
+ */
+ private void createContentView() {
+ setContentView(com.android.internal.R.layout.search_bar);
+
// get the view elements for local access
SearchBar searchBar = (SearchBar) findViewById(com.android.internal.R.id.search_bar);
searchBar.setSearchDialog(this);
@@ -211,19 +229,6 @@
mBadgeLabel.setVisibility(View.GONE);
// Additional adjustments to make Dialog work for Search
-
- // Touching outside of the search dialog will dismiss it
- setCanceledOnTouchOutside(true);
-
- // Save voice intent for later queries/launching
- mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
- mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
- RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
-
- mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
- mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
mSearchAutoCompleteImeOptions = mSearchAutoComplete.getImeOptions();
}
@@ -358,7 +363,9 @@
// isDefaultSearchable() should always give the same result.
mGlobalSearchMode = globalSearch || searchManager.isDefaultSearchable(mSearchable);
mActivityContext = mSearchable.getActivityContext(getContext());
-
+
+ createContentView();
+
// show the dialog. this will call onStart().
if (!isShowing()) {
// The Dialog uses a ContextThemeWrapper for the context; use this to change the