Loading api/current.xml +37 −0 Original line number Diff line number Diff line Loading @@ -234035,6 +234035,17 @@ visibility="public" > </method> <method name="isIconified" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="isSubmitButtonEnabled" return="boolean" abstract="false" Loading @@ -234046,6 +234057,19 @@ visibility="public" > </method> <method name="setIconified" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="iconify" type="boolean"> </parameter> </method> <method name="setIconifiedByDefault" return="void" abstract="false" Loading @@ -234059,6 +234083,19 @@ <parameter name="iconified" type="boolean"> </parameter> </method> <method name="setOnCloseListener" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="listener" type="android.widget.SearchView.OnCloseListener"> </parameter> </method> <method name="setOnQueryChangeListener" return="void" abstract="false" core/java/android/widget/SearchView.java +52 −8 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ public class SearchView extends LinearLayout { private OnCloseListener mOnCloseListener; private boolean mIconifiedByDefault; private boolean mIconified; private CursorAdapter mSuggestionsAdapter; private View mSearchButton; private View mSubmitButton; Loading Loading @@ -139,8 +140,6 @@ public class SearchView extends LinearLayout { mQueryTextView.setOnItemClickListener(mOnItemClickListener); mQueryTextView.setOnItemSelectedListener(mOnItemSelectedListener); mSubmitButtonEnabled = false; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true)); a.recycle(); Loading Loading @@ -174,6 +173,15 @@ public class SearchView extends LinearLayout { mOnQueryChangeListener = listener; } /** * Sets a listener to inform when the user closes the SearchView. * * @param listener the listener to call when the user closes the SearchView. */ public void setOnCloseListener(OnCloseListener listener) { mOnCloseListener = listener; } /** * Sets a query string in the text field and optionally submits the query as well. * Loading Loading @@ -205,19 +213,53 @@ public class SearchView extends LinearLayout { * Sets the default or resting state of the search field. If true, a single search icon is * shown by default and expands to show the text field and other buttons when pressed. Also, * if the default state is iconified, then it collapses to that state when the close button * is pressed. * is pressed. Changes to this property will take effect immediately. * * @param iconified * <p>The default value is false.</p> * * @param iconified whether the search field should be iconified by default */ public void setIconifiedByDefault(boolean iconified) { mIconifiedByDefault = iconified; updateViewsVisibility(iconified); } /** * Returns the default iconified state of the search field. * @return */ public boolean isIconfiedByDefault() { return mIconifiedByDefault; } /** * Iconifies or expands the SearchView. Any query text is cleared when iconified. This is * a temporary state and does not override the default iconified state set by * {@link #setIconifiedByDefault(boolean)}. If the default state is iconified, then * a false here will only be valid until the user closes the field. And if the default * state is expanded, then a true here will only clear the text field and not close it. * * @param iconify a true value will collapse the SearchView to an icon, while a false will * expand it. */ public void setIconified(boolean iconify) { if (iconify) { onCloseClicked(); } else { onSearchClicked(); } } /** * Returns the current iconified state of the SearchView. * * @return true if the SearchView is currently iconified, false if the search field is * fully visible. */ public boolean isIconified() { return mIconified; } /** * Enables showing a submit button when the query is non-empty. In cases where the SearchView * is being used to filter the contents of the current activity and doesn't launch a separate Loading Loading @@ -263,11 +305,12 @@ public class SearchView extends LinearLayout { return mSuggestionsAdapter; } private void updateViewsVisibility(boolean collapsed) { private void updateViewsVisibility(final boolean collapsed) { mIconified = collapsed; // Visibility of views that are visible when collapsed int visCollapsed = collapsed? VISIBLE : GONE; final int visCollapsed = collapsed ? VISIBLE : GONE; // Visibility of views that are visible when expanded int visExpanded = collapsed? GONE : VISIBLE; final int visExpanded = collapsed ? GONE : VISIBLE; mSearchButton.setVisibility(visCollapsed); mSubmitButton.setVisibility(mSubmitButtonEnabled ? visExpanded : GONE); Loading Loading @@ -322,7 +365,8 @@ public class SearchView extends LinearLayout { // entered query with the action key SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode); if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) { launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView.getText().toString()); launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView.getText() .toString()); return true; } Loading Loading
api/current.xml +37 −0 Original line number Diff line number Diff line Loading @@ -234035,6 +234035,17 @@ visibility="public" > </method> <method name="isIconified" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="isSubmitButtonEnabled" return="boolean" abstract="false" Loading @@ -234046,6 +234057,19 @@ visibility="public" > </method> <method name="setIconified" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="iconify" type="boolean"> </parameter> </method> <method name="setIconifiedByDefault" return="void" abstract="false" Loading @@ -234059,6 +234083,19 @@ <parameter name="iconified" type="boolean"> </parameter> </method> <method name="setOnCloseListener" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="listener" type="android.widget.SearchView.OnCloseListener"> </parameter> </method> <method name="setOnQueryChangeListener" return="void" abstract="false"
core/java/android/widget/SearchView.java +52 −8 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ public class SearchView extends LinearLayout { private OnCloseListener mOnCloseListener; private boolean mIconifiedByDefault; private boolean mIconified; private CursorAdapter mSuggestionsAdapter; private View mSearchButton; private View mSubmitButton; Loading Loading @@ -139,8 +140,6 @@ public class SearchView extends LinearLayout { mQueryTextView.setOnItemClickListener(mOnItemClickListener); mQueryTextView.setOnItemSelectedListener(mOnItemSelectedListener); mSubmitButtonEnabled = false; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true)); a.recycle(); Loading Loading @@ -174,6 +173,15 @@ public class SearchView extends LinearLayout { mOnQueryChangeListener = listener; } /** * Sets a listener to inform when the user closes the SearchView. * * @param listener the listener to call when the user closes the SearchView. */ public void setOnCloseListener(OnCloseListener listener) { mOnCloseListener = listener; } /** * Sets a query string in the text field and optionally submits the query as well. * Loading Loading @@ -205,19 +213,53 @@ public class SearchView extends LinearLayout { * Sets the default or resting state of the search field. If true, a single search icon is * shown by default and expands to show the text field and other buttons when pressed. Also, * if the default state is iconified, then it collapses to that state when the close button * is pressed. * is pressed. Changes to this property will take effect immediately. * * @param iconified * <p>The default value is false.</p> * * @param iconified whether the search field should be iconified by default */ public void setIconifiedByDefault(boolean iconified) { mIconifiedByDefault = iconified; updateViewsVisibility(iconified); } /** * Returns the default iconified state of the search field. * @return */ public boolean isIconfiedByDefault() { return mIconifiedByDefault; } /** * Iconifies or expands the SearchView. Any query text is cleared when iconified. This is * a temporary state and does not override the default iconified state set by * {@link #setIconifiedByDefault(boolean)}. If the default state is iconified, then * a false here will only be valid until the user closes the field. And if the default * state is expanded, then a true here will only clear the text field and not close it. * * @param iconify a true value will collapse the SearchView to an icon, while a false will * expand it. */ public void setIconified(boolean iconify) { if (iconify) { onCloseClicked(); } else { onSearchClicked(); } } /** * Returns the current iconified state of the SearchView. * * @return true if the SearchView is currently iconified, false if the search field is * fully visible. */ public boolean isIconified() { return mIconified; } /** * Enables showing a submit button when the query is non-empty. In cases where the SearchView * is being used to filter the contents of the current activity and doesn't launch a separate Loading Loading @@ -263,11 +305,12 @@ public class SearchView extends LinearLayout { return mSuggestionsAdapter; } private void updateViewsVisibility(boolean collapsed) { private void updateViewsVisibility(final boolean collapsed) { mIconified = collapsed; // Visibility of views that are visible when collapsed int visCollapsed = collapsed? VISIBLE : GONE; final int visCollapsed = collapsed ? VISIBLE : GONE; // Visibility of views that are visible when expanded int visExpanded = collapsed? GONE : VISIBLE; final int visExpanded = collapsed ? GONE : VISIBLE; mSearchButton.setVisibility(visCollapsed); mSubmitButton.setVisibility(mSubmitButtonEnabled ? visExpanded : GONE); Loading Loading @@ -322,7 +365,8 @@ public class SearchView extends LinearLayout { // entered query with the action key SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode); if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) { launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView.getText().toString()); launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView.getText() .toString()); return true; } Loading