diff options
author | John Reck <jreck@google.com> | 2010-11-10 11:57:04 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-11-10 11:57:04 -0800 |
commit | 40f720ecfd4ef7ebb657f0fc1906a9982b3bafbd (patch) | |
tree | 5064294545b26fa7ee046e45fe45626616bc75d1 | |
parent | e222fe87a6a582b283cbad0f6967e908c4bfe85e (diff) | |
download | packages_apps_Browser-40f720ecfd4ef7ebb657f0fc1906a9982b3bafbd.zip packages_apps_Browser-40f720ecfd4ef7ebb657f0fc1906a9982b3bafbd.tar.gz packages_apps_Browser-40f720ecfd4ef7ebb657f0fc1906a9982b3bafbd.tar.bz2 |
Omnibox supports search extra data
Bug: 3025590
Fix the omnibox to support passing on SearchManager.EXTRA_SEARCH_DATA
in searches done from the suggestion adapter.
Change-Id: Ica6462ef27722c3bbcc0508178ce431e87e27e86
-rw-r--r-- | src/com/android/browser/SuggestionsAdapter.java | 11 | ||||
-rw-r--r-- | src/com/android/browser/TitleBarXLarge.java | 7 | ||||
-rw-r--r-- | src/com/android/browser/UrlInputView.java | 16 |
3 files changed, 21 insertions, 13 deletions
diff --git a/src/com/android/browser/SuggestionsAdapter.java b/src/com/android/browser/SuggestionsAdapter.java index 626283a..d3609b2 100644 --- a/src/com/android/browser/SuggestionsAdapter.java +++ b/src/com/android/browser/SuggestionsAdapter.java @@ -73,7 +73,7 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable, OnCli public void onSearch(String txt); - public void onSelect(String txt); + public void onSelect(String txt, String extraData); public void onFilterComplete(int count); @@ -119,7 +119,8 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable, OnCli mListener.onSearch(item.title); } else { SuggestItem item = (SuggestItem) v.getTag(); - mListener.onSelect((TextUtils.isEmpty(item.url)? item.title : item.url)); + mListener.onSelect((TextUtils.isEmpty(item.url)? item.title : item.url), + item.extra); } } @@ -378,6 +379,7 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable, OnCli String title; String url; int type; + String extra; public SuggestItem(String text, String u, int t) { title = text; @@ -541,7 +543,10 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable, OnCli String uri = mCursor.getString( mCursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_DATA)); int type = (TextUtils.isEmpty(url)) ? TYPE_SUGGEST : TYPE_SUGGEST_URL; - return new SuggestItem(title, url, type); + SuggestItem item = new SuggestItem(title, url, type); + item.extra = mCursor.getString( + mCursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA)); + return item; } return null; } diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java index b87ea78..f39c769 100644 --- a/src/com/android/browser/TitleBarXLarge.java +++ b/src/com/android/browser/TitleBarXLarge.java @@ -137,7 +137,7 @@ public class TitleBarXLarge extends TitleBarBase stopOrRefresh(); } else if (mGoButton == v) { if (!TextUtils.isEmpty(mUrlFocused.getText())) { - onAction(mUrlFocused.getText().toString()); + onAction(mUrlFocused.getText().toString(), null); } } else if (mClearButton == v) { mUrlFocused.setText(""); @@ -154,12 +154,15 @@ public class TitleBarXLarge extends TitleBarBase // UrlInputListener implementation @Override - public void onAction(String text) { + public void onAction(String text, String extra) { mBrowserActivity.getTabControl().getCurrentTopWebView().requestFocus(); mBrowserActivity.hideFakeTitleBar(); Intent i = new Intent(); i.setAction(Intent.ACTION_SEARCH); i.putExtra(SearchManager.QUERY, text); + if (extra != null) { + i.putExtra(SearchManager.EXTRA_DATA_KEY, extra); + } mBrowserActivity.onNewIntent(i); setUrlMode(false); setDisplayTitle(text); diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java index 18c5fe6..e7fc233 100644 --- a/src/com/android/browser/UrlInputView.java +++ b/src/com/android/browser/UrlInputView.java @@ -114,7 +114,7 @@ public class UrlInputView extends AutoCompleteTextView @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - finishInput(getText().toString()); + finishInput(getText().toString(), null); return true; } @@ -123,7 +123,7 @@ public class UrlInputView extends AutoCompleteTextView if (hasFocus) { forceIme(); } else { - finishInput(null); + finishInput(null, null); } if (mWrappedFocusListener != null) { mWrappedFocusListener.onFocusChange(v, hasFocus); @@ -138,14 +138,14 @@ public class UrlInputView extends AutoCompleteTextView mInputManager.showSoftInput(this, 0); } - private void finishInput(String url) { + private void finishInput(String url, String extra) { this.dismissDropDown(); this.setSelection(0,0); mInputManager.hideSoftInputFromWindow(getWindowToken(), 0); if (url == null) { mListener.onDismiss(); } else { - mListener.onAction(url); + mListener.onAction(url, extra); } } @@ -157,15 +157,15 @@ public class UrlInputView extends AutoCompleteTextView } @Override - public void onSelect(String url) { - finishInput(url); + public void onSelect(String url, String extra) { + finishInput(url, extra); } @Override public boolean onKeyPreIme(int keyCode, KeyEvent evt) { if (keyCode == KeyEvent.KEYCODE_BACK) { // catch back key in order to do slightly more cleanup than usual - finishInput(null); + finishInput(null, null); return true; } return super.onKeyPreIme(keyCode, evt); @@ -175,7 +175,7 @@ public class UrlInputView extends AutoCompleteTextView public void onDismiss(); - public void onAction(String text); + public void onAction(String text, String extra); public void onEdit(String text); |