diff options
author | Karl Rosaen <krosaen@google.com> | 2009-04-28 10:39:09 -0700 |
---|---|---|
committer | Karl Rosaen <krosaen@google.com> | 2009-04-28 15:52:30 -0700 |
commit | 98e333f551a4bf2ebb50bb97a2a56b14bfdcd74b (patch) | |
tree | 6d39ba2cfac9ab85dbbb81f88c15746ad6358a2e /core/java/android/widget/AutoCompleteTextView.java | |
parent | 4924ae8d1f7610b8639e55b1088f6b4a993bfd40 (diff) | |
download | frameworks_base-98e333f551a4bf2ebb50bb97a2a56b14bfdcd74b.zip frameworks_base-98e333f551a4bf2ebb50bb97a2a56b14bfdcd74b.tar.gz frameworks_base-98e333f551a4bf2ebb50bb97a2a56b14bfdcd74b.tar.bz2 |
Fix back key and ime behavior for search dialog.
The back key now dismisses the soft keyboard, and then the dialog.
The soft keyboard behavior is improved by having ACTV do the following when 'mDropdownAlwaysShowing' is true:
- touching outside of the drop down doesn't dismiss it
- touching the text field ensures the imei is brought in front of the drop down
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index e3186b0..1e122a7 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -127,6 +127,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe // The widget is attached to a window when mAttachCount > 0 private int mAttachCount; + private AutoCompleteTextView.PassThroughClickListener mPassThroughClickListener; + public AutoCompleteTextView(Context context) { this(context, null); } @@ -186,6 +188,28 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe setFocusable(true); addTextChangedListener(new MyWatcher()); + + mPassThroughClickListener = new PassThroughClickListener(); + super.setOnClickListener(mPassThroughClickListener); + } + + @Override + public void setOnClickListener(OnClickListener listener) { + mPassThroughClickListener.mWrapped = listener; + } + + /** + * 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) { + mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); + mPopup.update(); + } } /** @@ -1050,7 +1074,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } mPopup.setHeight(height); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); - mPopup.setOutsideTouchable(true); + + // 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.setTouchInterceptor(new PopupTouchIntercepter()); mPopup.showAsDropDown(getDropDownAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset); @@ -1367,4 +1394,21 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe */ CharSequence fixText(CharSequence invalidText); } + + /** + * Allows us a private hook into the on click event without preventing users from setting + * their own click listener. + */ + private class PassThroughClickListener implements OnClickListener { + + private View.OnClickListener mWrapped; + + /** {@inheritDoc} */ + public void onClick(View v) { + onClickImpl(); + + if (mWrapped != null) mWrapped.onClick(v); + } + } + } |