Add autocomplete to the browser UrlInputView.
Code and tests based on the google search app. A lot
less code would be duplicated if we could somehow
override AutoCompleteTextView but that is made impossible
by it calling a bunch of stuff in its constructor. To do
so would require changes to the existing API.
I've verified that the unit test passes, but other browser
tests appear to fail - even on a clean branch with none
of my changes.
Also fixes a minor bug in SearchEngines.getSearchableInfo( ).
Change-Id: Ic61bc6b8fa27cd210a45dc181ebf15accf503244
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 85935a0..1b33084 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -16,6 +16,7 @@
package com.android.browser;
+import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher;
import com.android.browser.search.SearchEngine;
import android.app.Activity;
@@ -23,10 +24,7 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
-import android.text.Editable;
import android.text.TextUtils;
-import android.text.TextWatcher;
-import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -45,8 +43,7 @@
* tabbed title bar for xlarge screen browser
*/
public class TitleBarXLarge extends TitleBarBase
- implements OnClickListener, OnFocusChangeListener,
- TextWatcher {
+ implements OnClickListener, OnFocusChangeListener, TextChangeWatcher {
private XLargeUi mUi;
@@ -136,7 +133,7 @@
mUrlInput.setController(mUiController);
mUrlInput.setOnFocusChangeListener(this);
mUrlInput.setSelectAllOnFocus(true);
- mUrlInput.addTextChangedListener(this);
+ mUrlInput.addQueryTextWatcher(this);
setFocusState(false);
}
@@ -372,7 +369,7 @@
// UrlInput text watcher
@Override
- public void afterTextChanged(Editable s) {
+ public void onTextChanged(String newText) {
if (mUrlInput.hasFocus()) {
// check if input field is empty and adjust voice search state
updateSearchMode(true);
@@ -381,14 +378,6 @@
}
}
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
// voicesearch
@Override