Merge "SearchView API Review - bug 3370353 and bug 3370338" into honeycomb
diff --git a/api/11.xml b/api/11.xml
index 4f7bda3..ceb0631 100644
--- a/api/11.xml
+++ b/api/11.xml
@@ -253670,19 +253670,6 @@
<parameter name="listener" type="android.widget.SearchView.OnCloseListener">
</parameter>
</method>
-<method name="setOnQueryChangeListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="listener" type="android.widget.SearchView.OnQueryChangeListener">
-</parameter>
-</method>
<method name="setOnQueryTextFocusChangeListener"
return="void"
abstract="false"
@@ -253696,6 +253683,19 @@
<parameter name="listener" type="android.view.View.OnFocusChangeListener">
</parameter>
</method>
+<method name="setOnQueryTextListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.widget.SearchView.OnQueryTextListener">
+</parameter>
+</method>
<method name="setOnSearchClickListener"
return="void"
abstract="false"
@@ -253709,7 +253709,7 @@
<parameter name="listener" type="android.view.View.OnClickListener">
</parameter>
</method>
-<method name="setOnSuggestionSelectionListener"
+<method name="setOnSuggestionListener"
return="void"
abstract="false"
native="false"
@@ -253719,7 +253719,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="listener" type="android.widget.SearchView.OnSuggestionSelectionListener">
+<parameter name="listener" type="android.widget.SearchView.OnSuggestionListener">
</parameter>
</method>
<method name="setQuery"
@@ -253822,14 +253822,14 @@
>
</method>
</interface>
-<interface name="SearchView.OnQueryChangeListener"
+<interface name="SearchView.OnQueryTextListener"
abstract="true"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
-<method name="onQueryTextChanged"
+<method name="onQueryTextChange"
return="boolean"
abstract="true"
native="false"
@@ -253842,7 +253842,7 @@
<parameter name="newText" type="java.lang.String">
</parameter>
</method>
-<method name="onSubmitQuery"
+<method name="onQueryTextSubmit"
return="boolean"
abstract="true"
native="false"
@@ -253856,14 +253856,14 @@
</parameter>
</method>
</interface>
-<interface name="SearchView.OnSuggestionSelectionListener"
+<interface name="SearchView.OnSuggestionListener"
abstract="true"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
-<method name="onSuggestionClicked"
+<method name="onSuggestionClick"
return="boolean"
abstract="true"
native="false"
@@ -253876,7 +253876,7 @@
<parameter name="position" type="int">
</parameter>
</method>
-<method name="onSuggestionSelected"
+<method name="onSuggestionSelect"
return="boolean"
abstract="true"
native="false"
diff --git a/api/current.xml b/api/current.xml
index 4f7bda3..ceb0631 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -253670,19 +253670,6 @@
<parameter name="listener" type="android.widget.SearchView.OnCloseListener">
</parameter>
</method>
-<method name="setOnQueryChangeListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="listener" type="android.widget.SearchView.OnQueryChangeListener">
-</parameter>
-</method>
<method name="setOnQueryTextFocusChangeListener"
return="void"
abstract="false"
@@ -253696,6 +253683,19 @@
<parameter name="listener" type="android.view.View.OnFocusChangeListener">
</parameter>
</method>
+<method name="setOnQueryTextListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.widget.SearchView.OnQueryTextListener">
+</parameter>
+</method>
<method name="setOnSearchClickListener"
return="void"
abstract="false"
@@ -253709,7 +253709,7 @@
<parameter name="listener" type="android.view.View.OnClickListener">
</parameter>
</method>
-<method name="setOnSuggestionSelectionListener"
+<method name="setOnSuggestionListener"
return="void"
abstract="false"
native="false"
@@ -253719,7 +253719,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="listener" type="android.widget.SearchView.OnSuggestionSelectionListener">
+<parameter name="listener" type="android.widget.SearchView.OnSuggestionListener">
</parameter>
</method>
<method name="setQuery"
@@ -253822,14 +253822,14 @@
>
</method>
</interface>
-<interface name="SearchView.OnQueryChangeListener"
+<interface name="SearchView.OnQueryTextListener"
abstract="true"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
-<method name="onQueryTextChanged"
+<method name="onQueryTextChange"
return="boolean"
abstract="true"
native="false"
@@ -253842,7 +253842,7 @@
<parameter name="newText" type="java.lang.String">
</parameter>
</method>
-<method name="onSubmitQuery"
+<method name="onQueryTextSubmit"
return="boolean"
abstract="true"
native="false"
@@ -253856,14 +253856,14 @@
</parameter>
</method>
</interface>
-<interface name="SearchView.OnSuggestionSelectionListener"
+<interface name="SearchView.OnSuggestionListener"
abstract="true"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
-<method name="onSuggestionClicked"
+<method name="onSuggestionClick"
return="boolean"
abstract="true"
native="false"
@@ -253876,7 +253876,7 @@
<parameter name="position" type="int">
</parameter>
</method>
-<method name="onSuggestionSelected"
+<method name="onSuggestionSelect"
return="boolean"
abstract="true"
native="false"
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 4d19b62..e95a23d 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -164,8 +164,8 @@
mSearchView = (SearchView) findViewById(com.android.internal.R.id.search_view);
mSearchView.setSubmitButtonEnabled(true);
mSearchView.setOnCloseListener(mOnCloseListener);
- mSearchView.setOnQueryChangeListener(mOnQueryChangeListener);
- mSearchView.setOnSuggestionSelectionListener(mOnSuggestionSelectionListener);
+ mSearchView.setOnQueryTextListener(mOnQueryChangeListener);
+ mSearchView.setOnSuggestionListener(mOnSuggestionSelectionListener);
// TODO: Move the badge logic to SearchView or move the badge to search_bar.xml
mBadgeLabel = (TextView) mSearchView.findViewById(com.android.internal.R.id.search_badge);
@@ -678,27 +678,27 @@
}
};
- private final SearchView.OnQueryChangeListener mOnQueryChangeListener =
- new SearchView.OnQueryChangeListener() {
+ private final SearchView.OnQueryTextListener mOnQueryChangeListener =
+ new SearchView.OnQueryTextListener() {
- public boolean onSubmitQuery(String query) {
+ public boolean onQueryTextSubmit(String query) {
dismiss();
return false;
}
- public boolean onQueryTextChanged(String newText) {
+ public boolean onQueryTextChange(String newText) {
return false;
}
};
- private final SearchView.OnSuggestionSelectionListener mOnSuggestionSelectionListener =
- new SearchView.OnSuggestionSelectionListener() {
+ private final SearchView.OnSuggestionListener mOnSuggestionSelectionListener =
+ new SearchView.OnSuggestionListener() {
- public boolean onSuggestionSelected(int position) {
+ public boolean onSuggestionSelect(int position) {
return false;
}
- public boolean onSuggestionClicked(int position) {
+ public boolean onSuggestionClick(int position) {
dismiss();
return false;
}
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 585dcf2..b86366c 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -72,10 +72,10 @@
private static final boolean DBG = false;
private static final String LOG_TAG = "SearchView";
- private OnQueryChangeListener mOnQueryChangeListener;
+ private OnQueryTextListener mOnQueryChangeListener;
private OnCloseListener mOnCloseListener;
private OnFocusChangeListener mOnQueryTextFocusChangeListener;
- private OnSuggestionSelectionListener mOnSuggestionListener;
+ private OnSuggestionListener mOnSuggestionListener;
private OnClickListener mOnSearchClickListener;
private boolean mIconifiedByDefault;
@@ -109,7 +109,7 @@
/**
* Callbacks for changes to the query text.
*/
- public interface OnQueryChangeListener {
+ public interface OnQueryTextListener {
/**
* Called when the user submits the query. This could be due to a key press on the
@@ -123,7 +123,7 @@
* @return true if the query has been handled by the listener, false to let the
* SearchView perform the default action.
*/
- boolean onSubmitQuery(String query);
+ boolean onQueryTextSubmit(String query);
/**
* Called when the query text is changed by the user.
@@ -133,7 +133,7 @@
* @return false if the SearchView should perform the default action of showing any
* suggestions if available, true if the action was handled by the listener.
*/
- boolean onQueryTextChanged(String newText);
+ boolean onQueryTextChange(String newText);
}
public interface OnCloseListener {
@@ -151,7 +151,7 @@
* Callback interface for selection events on suggestions. These callbacks
* are only relevant when a SearchableInfo has been specified by {@link #setSearchableInfo}.
*/
- public interface OnSuggestionSelectionListener {
+ public interface OnSuggestionListener {
/**
* Called when a suggestion was selected by navigating to it.
@@ -160,7 +160,7 @@
* @return true if the listener handles the event and wants to override the default
* behavior of possibly rewriting the query based on the selected item, false otherwise.
*/
- boolean onSuggestionSelected(int position);
+ boolean onSuggestionSelect(int position);
/**
* Called when a suggestion was clicked.
@@ -170,7 +170,7 @@
* behavior of launching any intent or submitting a search query specified on that item.
* Return false otherwise.
*/
- boolean onSuggestionClicked(int position);
+ boolean onSuggestionClick(int position);
}
public SearchView(Context context) {
@@ -282,7 +282,7 @@
* @param listener the listener object that receives callbacks when the user performs
* actions in the SearchView such as clicking on buttons or typing a query.
*/
- public void setOnQueryChangeListener(OnQueryChangeListener listener) {
+ public void setOnQueryTextListener(OnQueryTextListener listener) {
mOnQueryChangeListener = listener;
}
@@ -309,7 +309,7 @@
*
* @param listener the listener to inform of suggestion selection events.
*/
- public void setOnSuggestionSelectionListener(OnSuggestionSelectionListener listener) {
+ public void setOnSuggestionListener(OnSuggestionListener listener) {
mOnSuggestionListener = listener;
}
@@ -865,7 +865,7 @@
updateCloseButton();
updateSubmitArea();
if (mOnQueryChangeListener != null) {
- mOnQueryChangeListener.onQueryTextChanged(newText.toString());
+ mOnQueryChangeListener.onQueryTextChange(newText.toString());
}
}
@@ -873,7 +873,7 @@
CharSequence query = mQueryTextView.getText();
if (!TextUtils.isEmpty(query)) {
if (mOnQueryChangeListener == null
- || !mOnQueryChangeListener.onSubmitQuery(query.toString())) {
+ || !mOnQueryChangeListener.onQueryTextSubmit(query.toString())) {
if (mSearchable != null) {
launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, query.toString());
setImeVisibility(false);
@@ -940,7 +940,7 @@
private boolean onItemClicked(int position, int actionKey, String actionMsg) {
if (mOnSuggestionListener == null
- || !mOnSuggestionListener.onSuggestionClicked(position)) {
+ || !mOnSuggestionListener.onSuggestionClick(position)) {
launchSuggestion(position, KeyEvent.KEYCODE_UNKNOWN, null);
setImeVisibility(false);
dismissSuggestions();
@@ -951,7 +951,7 @@
private boolean onItemSelected(int position) {
if (mOnSuggestionListener == null
- || !mOnSuggestionListener.onSuggestionSelected(position)) {
+ || !mOnSuggestionListener.onSuggestionSelect(position)) {
rewriteQueryFromSuggestion(position);
return true;
}