summaryrefslogtreecommitdiff
path: root/core/java/android/widget/AutoCompleteTextView.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-09-14 21:21:52 -0700
committerDianne Hackborn <hackbod@google.com>2009-09-14 21:21:52 -0700
commit8d37426c754e9822feaa8c6cc0b7c13e8523e217 (patch)
tree188470dc3254756b9a6bc345f9cf39171a6b3725 /core/java/android/widget/AutoCompleteTextView.java
parent83fe3f559249451706957b1a5f660b2b8272f114 (diff)
Various fixed for back key handling.
My last change was far from perfect. Hopefully this gets us a little closer. Change-Id: I413e55b6af42400b565de3040859d25d668bc9d2
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 7891d3cf177e..4566c4cfa1ae 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -132,8 +132,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
private AutoCompleteTextView.PassThroughClickListener mPassThroughClickListener;
- private int mDownKeyCode;
-
public AutoCompleteTextView(Context context) {
this(context, null);
}
@@ -605,19 +603,18 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
- if (event.getAction() == KeyEvent.ACTION_DOWN
- && event.getRepeatCount() == 0) {
- mDownKeyCode = keyCode;
- }
- if (isPopupShowing()) {
+ if (keyCode == KeyEvent.KEYCODE_BACK && isPopupShowing()
+ && !mDropDownAlwaysVisible) {
// special case for the back key, we do not even try to send it
// to the drop down list but instead, consume it immediately
- if (keyCode == KeyEvent.KEYCODE_BACK && !mDropDownAlwaysVisible) {
- if (event.getAction() == KeyEvent.ACTION_UP
- && mDownKeyCode == keyCode && !event.isCanceled()) {
- dismissDropDown();
- return true;
- }
+ if (event.getAction() == KeyEvent.ACTION_DOWN
+ && event.getRepeatCount() == 0) {
+ getKeyDispatcherState().startTracking(event, this);
+ return true;
+ } else if (event.getAction() == KeyEvent.ACTION_UP
+ && event.isTracking() && !event.isCanceled()) {
+ dismissDropDown();
+ return true;
}
}
return super.onKeyPreIme(keyCode, event);
@@ -1026,7 +1023,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
- mDownKeyCode = 0;
performValidation();
if (!hasWindowFocus && !mDropDownAlwaysVisible) {
dismissDropDown();
@@ -1036,7 +1032,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
- mDownKeyCode = 0;
performValidation();
if (!focused && !mDropDownAlwaysVisible) {
dismissDropDown();