diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-07-31 17:38:20 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-07-31 17:38:20 -0700 |
commit | 5c1207be90fdf296c1b83034b7c68915e1749284 (patch) | |
tree | e5679f6183458d8179821d5615dabafcb959704d /core/java/android/widget/AutoCompleteTextView.java | |
parent | a8675f67e33bc7337d148358783b0fd138b501ff (diff) | |
download | frameworks_base-5c1207be90fdf296c1b83034b7c68915e1749284.zip frameworks_base-5c1207be90fdf296c1b83034b7c68915e1749284.tar.gz frameworks_base-5c1207be90fdf296c1b83034b7c68915e1749284.tar.bz2 |
donut snapshot
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 4bc00de..456f8ed 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -104,6 +104,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe private View mDropDownAnchorView; // view is retrieved lazily from id once needed private int mDropDownWidth; private int mDropDownHeight; + private final Rect mTempRect = new Rect(); private Drawable mDropDownListHighlight; @@ -116,6 +117,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe private boolean mDropDownAlwaysVisible = false; private boolean mDropDownDismissedOnCompletion = true; + + private boolean mForceIgnoreOutsideTouch = false; private int mLastKeyCode = KeyEvent.KEYCODE_UNKNOWN; private boolean mOpenBefore; @@ -205,11 +208,9 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe * Private hook into the on click event, dispatched from {@link PassThroughClickListener} */ private void onClickImpl() { - // if drop down should always visible, bring it back in front of the soft - // keyboard when the user touches the text field - if (mDropDownAlwaysVisible - && mPopup.isShowing() - && mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED) { + // If the dropdown is showing, bring it back in front of the soft + // keyboard when the user touches the text field. + if (mPopup.isShowing() && isInputMethodNotNeeded()) { ensureImeVisible(); } } @@ -1102,6 +1103,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } /** + * @hide internal used only here and SearchDialog + */ + public boolean isInputMethodNotNeeded() { + return mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; + } + + /** * <p>Displays the drop down on screen.</p> */ public void showDropDown() { @@ -1110,7 +1118,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe int widthSpec = 0; int heightSpec = 0; - boolean noInputMethod = mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED; + boolean noInputMethod = isInputMethodNotNeeded(); if (mPopup.isShowing()) { if (mDropDownWidth == ViewGroup.LayoutParams.FILL_PARENT) { @@ -1143,6 +1151,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe heightSpec = mDropDownHeight; } + mPopup.setOutsideTouchable(mForceIgnoreOutsideTouch ? false : !mDropDownAlwaysVisible); + mPopup.update(getDropDownAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec, heightSpec); } else { @@ -1171,7 +1181,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe // use outside touchable to dismiss drop down when touching outside of it, so // only set this if the dropdown is not always visible - mPopup.setOutsideTouchable(!mDropDownAlwaysVisible); + mPopup.setOutsideTouchable(mForceIgnoreOutsideTouch ? false : !mDropDownAlwaysVisible); mPopup.setTouchInterceptor(new PopupTouchIntercepter()); mPopup.showAsDropDown(getDropDownAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset); @@ -1180,6 +1190,17 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe post(mHideSelector); } } + + /** + * Forces outside touches to be ignored. Normally if {@link #isDropDownAlwaysVisible()} is + * false, we allow outside touch to dismiss the dropdown. If this is set to true, then we + * ignore outside touch even when the drop down is not set to always visible. + * + * @hide used only by SearchDialog + */ + public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch) { + mForceIgnoreOutsideTouch = forceIgnoreOutsideTouch; + } /** * <p>Builds the popup window's content and returns the height the popup @@ -1303,7 +1324,15 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe getDropDownAnchorView(), mDropDownVerticalOffset, ignoreBottomDecorations); if (mDropDownAlwaysVisible) { - return maxHeight; + // getMaxAvailableHeight() subtracts the padding, so we put it back, + // to get the available height for the whole window + int padding = 0; + Drawable background = mPopup.getBackground(); + if (background != null) { + background.getPadding(mTempRect); + padding = mTempRect.top + mTempRect.bottom; + } + return maxHeight + padding; } return mDropDownList.measureHeightOfChildren(MeasureSpec.UNSPECIFIED, |