Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4a5758b authored by Gilles Debunne's avatar Gilles Debunne
Browse files

The tab key completes text in AutoCompleteTextView.

Bug 3330651.

The first item in the list is not selected by default. From discussions
in other related bugs, there does not seem to be an agreement on this.

Supporting the actual token separator has also been punted. This would
require a new method in the Tokenizer, which could be ill-defined for
exotic tokenizer, plus typing a comma (for instance) to achieve a
completion is not a common pattern.

Change-Id: I30baf62077c412256175f871d21f4841e104f212
parent 63c9809e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -648,6 +648,12 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
                return true;
            }
        }

        if (isPopupShowing() && keyCode == KeyEvent.KEYCODE_TAB && event.hasNoModifiers()) {
            performCompletion();
            return true;
        }

        return super.onKeyUp(keyCode, event);
    }

@@ -666,6 +672,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
            }
        }

        if (isPopupShowing() && keyCode == KeyEvent.KEYCODE_TAB && event.hasNoModifiers()) {
            return true;
        }

        mLastKeyCode = keyCode;
        boolean handled = super.onKeyDown(keyCode, event);
        mLastKeyCode = KeyEvent.KEYCODE_UNKNOWN;
+2 −13
Original line number Diff line number Diff line
@@ -17,24 +17,13 @@
package android.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.Selection;
import android.text.Spanned;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.QwertyKeyListener;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.internal.R;
import android.widget.MultiAutoCompleteTextView.Tokenizer;

/**
 * An editable text view, extending {@link AutoCompleteTextView}, that