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

Commit c34bf943 authored by Evan Rosky's avatar Evan Rosky Committed by android-build-merger
Browse files

Merge "Don't consume all BACK keys in SearchView" into pi-dev

am: a1aa6abe

Change-Id: Iea6535861725fea6096d9c44409436b8207594f0
parents bde7a11a a1aa6abe
Loading
Loading
Loading
Loading
+8 −21
Original line number Diff line number Diff line
@@ -1990,28 +1990,15 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {

        @Override
        public boolean onKeyPreIme(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                // 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 (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
                    KeyEvent.DispatcherState state = getKeyDispatcherState();
                    if (state != null) {
                        state.startTracking(event, this);
                    }
                    return true;
                } else if (event.getAction() == KeyEvent.ACTION_UP) {
                    KeyEvent.DispatcherState state = getKeyDispatcherState();
                    if (state != null) {
                        state.handleUpEvent(event);
                    }
                    if (event.isTracking() && !event.isCanceled()) {
                        mSearchView.clearFocus();
            final boolean consume = super.onKeyPreIme(keyCode, event);
            if (consume && keyCode == KeyEvent.KEYCODE_BACK
                    && event.getAction() == KeyEvent.ACTION_UP) {
                // If AutoCompleteTextView closed its pop-up, it will return true, in which case
                // we should also close the IME. Otherwise, the popup is already closed and we can
                // leave the BACK event alone.
                setImeVisibility(false);
                        return true;
                    }
                }
            }
            return super.onKeyPreIme(keyCode, event);
            return consume;
        }

        /**