From df68999dc7de3893ca80e4c736704dcc9ed94e35 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Thu, 13 Nov 2014 12:59:37 -0800 Subject: [PATCH] Don't dismiss AutoCompleteTextView on focus change while temp detached This is consistent with how TextView handles focus changes while temporarily detached and prevents the suggestion popup from being dismissed during layout when the AutoCompleteTextView is used within a ListView. BUG: 18364277 Change-Id: I8ca6fb9dba63b49a84a60a606bc441446c083cee --- core/java/android/widget/AutoCompleteTextView.java | 6 ++++++ core/java/android/widget/TextView.java | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 3b16aba010e04..e6392b9d3a759 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -1005,6 +1005,12 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(focused, direction, previouslyFocusedRect); + + if (mTemporaryDetach) { + // If we are temporarily in the detach state, then do nothing. + return; + } + // Perform validation if the view is losing focus. if (!focused) { performValidation(); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 0917b32e89d48..5e83602bc3b04 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -287,9 +287,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private int mCurTextColor; private int mCurHintTextColor; private boolean mFreezesText; - private boolean mTemporaryDetach; private boolean mDispatchTemporaryDetach; + /** Whether this view is temporarily detached from the parent view. */ + boolean mTemporaryDetach; + private Editable.Factory mEditableFactory = Editable.Factory.getInstance(); private Spannable.Factory mSpannableFactory = Spannable.Factory.getInstance();