Prevent AutoCompleteTextView from opening a popup when it shouldn't

Bug #5553515

The People app is forcing ACTV to show the IME which had the side effect
of showing the drop down popup. ACTV was unfortunately not ready to show
the drop down if the filtering resulted in no results. Doing so was putting
ACTV in a weird state that in turn caused a window to be leaked and really
bad behavior to occur in the lower graphics levels.

Change-Id: I2ff146d5ae4e4a28edf6ea17039c9f8fdb710e4f
This commit is contained in:
Romain Guy
2012-02-15 18:34:37 -08:00
parent fe455af277
commit c27cc01f6a
2 changed files with 12 additions and 1 deletions

View File

@@ -1031,7 +1031,9 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
public void ensureImeVisible(boolean visible) {
mPopup.setInputMethodMode(visible
? ListPopupWindow.INPUT_METHOD_NEEDED : ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
showDropDown();
if (mPopup.isDropDownAlwaysVisible() || (mFilter != null && enoughToFilter())) {
showDropDown();
}
}
/**

View File

@@ -21,6 +21,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.text.TextPaint;
import android.view.View;
@SuppressWarnings({"UnusedDeclaration"})
@@ -39,6 +40,7 @@ public class TextActivity extends Activity {
private final Paint mScaledPaint;
private final Paint mSkewPaint;
private final Paint mHugePaint;
private final TextPaint mEventPaint;
CustomTextView(Context c) {
super(c);
@@ -70,6 +72,11 @@ public class TextActivity extends Activity {
mHugePaint.setAntiAlias(true);
mHugePaint.setColor(0xff000000);
mHugePaint.setTextSize(300f);
mEventPaint = new TextPaint();
mEventPaint.setFakeBoldText(true);
mEventPaint.setAntiAlias(true);
mEventPaint.setTextSize(14);
}
@Override
@@ -77,6 +84,8 @@ public class TextActivity extends Activity {
super.onDraw(canvas);
canvas.drawRGB(255, 255, 255);
canvas.drawText("Hello OpenGL renderer!", 300, 20, mEventPaint);
mMediumPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mMediumPaint.setStrokeWidth(2.0f);
canvas.drawText("Hello OpenGL renderer!", 100, 20, mMediumPaint);