Skip to content

Commit 7a4be12

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Add some missing getters for XML/Java API consistency." into jb-dev
2 parents 16fb5d4 + eca59d3 commit 7a4be12

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

api/current.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27983,7 +27983,11 @@ package android.widget {
2798327983
public class SearchView extends android.widget.LinearLayout implements android.view.CollapsibleActionView {
2798427984
ctor public SearchView(android.content.Context);
2798527985
ctor public SearchView(android.content.Context, android.util.AttributeSet);
27986+
method public int getImeOptions();
27987+
method public int getInputType();
27988+
method public int getMaxWidth();
2798627989
method public java.lang.CharSequence getQuery();
27990+
method public java.lang.CharSequence getQueryHint();
2798727991
method public android.widget.CursorAdapter getSuggestionsAdapter();
2798827992
method public boolean isIconfiedByDefault();
2798927993
method public boolean isIconified();

core/java/android/widget/SearchView.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ public void setImeOptions(int imeOptions) {
380380
mQueryTextView.setImeOptions(imeOptions);
381381
}
382382

383+
/**
384+
* Returns the IME options set on the query text field.
385+
* @return the ime options
386+
* @see TextView#setImeOptions(int)
387+
*
388+
* @attr ref android.R.styleable#SearchView_imeOptions
389+
*/
390+
public int getImeOptions() {
391+
return mQueryTextView.getImeOptions();
392+
}
393+
383394
/**
384395
* Sets the input type on the query text field.
385396
*
@@ -392,6 +403,16 @@ public void setInputType(int inputType) {
392403
mQueryTextView.setInputType(inputType);
393404
}
394405

406+
/**
407+
* Returns the input type set on the query text field.
408+
* @return the input type
409+
*
410+
* @attr ref android.R.styleable#SearchView_inputType
411+
*/
412+
public int getInputType() {
413+
return mQueryTextView.getInputType();
414+
}
415+
395416
/** @hide */
396417
@Override
397418
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
@@ -513,6 +534,26 @@ public void setQueryHint(CharSequence hint) {
513534
updateQueryHint();
514535
}
515536

537+
/**
538+
* Gets the hint text to display in the query text field.
539+
* @return the query hint text, if specified, null otherwise.
540+
*
541+
* @attr ref android.R.styleable#SearchView_queryHint
542+
*/
543+
public CharSequence getQueryHint() {
544+
if (mQueryHint != null) {
545+
return mQueryHint;
546+
} else if (mSearchable != null) {
547+
CharSequence hint = null;
548+
int hintId = mSearchable.getHintId();
549+
if (hintId != 0) {
550+
hint = getContext().getString(hintId);
551+
}
552+
return hint;
553+
}
554+
return null;
555+
}
556+
516557
/**
517558
* Sets the default or resting state of the search field. If true, a single search icon is
518559
* shown by default and expands to show the text field and other buttons when pressed. Also,
@@ -651,6 +692,15 @@ public void setMaxWidth(int maxpixels) {
651692
requestLayout();
652693
}
653694

695+
/**
696+
* Gets the specified maximum width in pixels, if set. Returns zero if
697+
* no maximum width was specified.
698+
* @return the maximum width of the view
699+
*/
700+
public int getMaxWidth() {
701+
return mMaxWidth;
702+
}
703+
654704
@Override
655705
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
656706
// Let the standard measurements take effect in iconified state.

0 commit comments

Comments
 (0)