summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/SearchDialog.java19
-rw-r--r--core/java/android/app/SearchManager.java5
-rw-r--r--core/java/android/app/SuggestionsAdapter.java25
-rw-r--r--core/java/com/google/android/util/GoogleWebContentHelper.java9
4 files changed, 54 insertions, 4 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index ff110c8..3675ec2 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -1275,11 +1275,28 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
private void handleCursorRespondIntent(Intent intent) {
Cursor c = mSuggestionsAdapter.getCursor();
if (c != null) {
- c.respond(intent.getExtras());
+ Bundle response = c.respond(intent.getExtras());
+
+ // The SHOW_CORPUS_SELECTORS command to the cursor also returns a value in
+ // its bundle, keyed by the same command string, which contains the index
+ // of the "More results..." list item, which we use to instruct the
+ // AutoCompleteTextView's list to scroll to that item when the item is
+ // clicked.
+ if (response.containsKey(SuggestionsAdapter.SHOW_CORPUS_SELECTORS)) {
+ int indexOfMore = response.getInt(SuggestionsAdapter.SHOW_CORPUS_SELECTORS);
+ mSuggestionsAdapter.setListItemToSelect(indexOfMore);
+ }
}
}
/**
+ * Sets the list item selection in the AutoCompleteTextView's ListView.
+ */
+ public void setListSelection(int index) {
+ mSearchAutoComplete.setListSelection(index);
+ }
+
+ /**
* Saves the previous component that was searched, so that we can go
* back to it.
*/
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 3bf37c3..be2f50f 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -1302,9 +1302,10 @@ public class SearchManager
/**
* Column name for suggestions cursor. <i>Optional.</i> This column allows suggestions
* to provide additional arbitrary data which will be included as an extra under the key
- * {@link #EXTRA_DATA_KEY}.
+ * {@link #EXTRA_DATA_KEY}. For use by the global search system only - if other providers
+ * attempt to use this column, the value will be overwritten by global search.
*
- * @hide pending API council approval
+ * @hide
*/
public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data";
/**
diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java
index aeb96b4..4406f8e 100644
--- a/core/java/android/app/SuggestionsAdapter.java
+++ b/core/java/android/app/SuggestionsAdapter.java
@@ -50,6 +50,11 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
// so we can correctly display (or not display) the 'working' spinner in the search dialog.
public static final String IS_WORKING = "isWorking";
+ // The value used to tell a cursor to display the corpus selectors, if this is global
+ // search. Also returns the index of the more results item to allow the SearchDialog
+ // to tell the ListView to scroll to that list item.
+ public static final String SHOW_CORPUS_SELECTORS = "showCorpusSelectors";
+
private static final boolean DBG = false;
private static final String LOG_TAG = "SuggestionsAdapter";
@@ -68,6 +73,13 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
private int mIconBitmap1Col;
private int mIconBitmap2Col;
+ // This value is stored in SuggestionsAdapter by the SearchDialog to indicate whether
+ // a particular list item should be selected upon the next call to notifyDataSetChanged.
+ // This is used to indicate the index of the "More results..." list item so that when
+ // the data set changes after a click of "More results...", we can correctly tell the
+ // ListView to scroll to the right line item. It gets reset to -1 every time it is consumed.
+ private int mListItemToSelect = -1;
+
public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable,
WeakHashMap<String, Drawable> outsideDrawablesCache, boolean globalSearchMode) {
super(context,
@@ -134,6 +146,19 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
updateWorking();
+ if (mListItemToSelect != -1) {
+ mSearchDialog.setListSelection(mListItemToSelect);
+ mListItemToSelect = -1;
+ }
+ }
+
+ /**
+ * Specifies the list item to select upon next call of {@link #notifyDataSetChanged()},
+ * in order to let us scroll the "More results..." list item to the top of the screen
+ * (or as close as it can get) when clicked.
+ */
+ public void setListItemToSelect(int index) {
+ mListItemToSelect = index;
}
/**
diff --git a/core/java/com/google/android/util/GoogleWebContentHelper.java b/core/java/com/google/android/util/GoogleWebContentHelper.java
index 2911420..3cdf855 100644
--- a/core/java/com/google/android/util/GoogleWebContentHelper.java
+++ b/core/java/com/google/android/util/GoogleWebContentHelper.java
@@ -130,7 +130,14 @@ public class GoogleWebContentHelper {
mWebView.loadUrl(mSecureUrl);
return this;
}
-
+
+ public GoogleWebContentHelper loadDataWithFailUrl(String base, String data,
+ String mimeType, String encoding, String failUrl) {
+ ensureViews();
+ mWebView.loadDataWithBaseURL(base, data, mimeType, encoding, failUrl);
+ return this;
+ }
+
/**
* Helper to handle the back key. Returns true if the back key was handled,
* otherwise returns false.