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

Commit f02853f2 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Fix down arrow in AutoCompleteTextView." into honeycomb

parents d529d0df 8d6d3b83
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -4467,15 +4467,14 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    }
    
    /**
     * If there is a selection returns true.
     * Otherwise resurrects the selection and returns false.
     * If there is a selection returns false.
     * Otherwise resurrects the selection and returns true if resurrected.
     */
    boolean ensureSelectionOnMovementKey() {
    boolean resurrectSelectionIfNeeded() {
        if (mSelectedPosition < 0) {
            resurrectSelection();
            return false;
            return resurrectSelection();
        }
        return true;
        return false;
    }

    /**
+41 −37
Original line number Diff line number Diff line
@@ -1486,77 +1486,79 @@ public class GridView extends AbsListView {
            switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && arrowScroll(FOCUS_LEFT);
                        handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_LEFT);
                    }
                    break;

                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && arrowScroll(FOCUS_RIGHT);
                        handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_RIGHT);
                    }
                    break;

                case KeyEvent.KEYCODE_DPAD_UP:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && arrowScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP);
                    } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                        handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
                    }
                    break;

                case KeyEvent.KEYCODE_DPAD_DOWN:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && arrowScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN);
                    } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                        handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
                    }
                    break;

                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER: {
                    if (event.hasNoModifiers()
                case KeyEvent.KEYCODE_ENTER:
                    if (event.hasNoModifiers()) {
                        handled = resurrectSelectionIfNeeded();
                        if (!handled
                                && event.getRepeatCount() == 0 && getChildCount() > 0) {
                        ensureSelectionOnMovementKey();
                            keyPressed();
                            handled = true;
                        }
                    return true;
                    }
                    break;

                case KeyEvent.KEYCODE_SPACE:
                    if (mPopup == null || !mPopup.isShowing()) {
                        if (event.hasNoModifiers()) {
                            handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_DOWN);
                            handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
                        } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                            handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_UP);
                            handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
                        }
                    }
                    break;

                case KeyEvent.KEYCODE_PAGE_UP:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
                    } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                        handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
                    }
                    break;

                case KeyEvent.KEYCODE_PAGE_DOWN:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
                    } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                        handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
                    }
                    break;

                case KeyEvent.KEYCODE_MOVE_HOME:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
                    }
                    break;

                case KeyEvent.KEYCODE_MOVE_END:
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
                    }
                    break;

@@ -1569,22 +1571,25 @@ public class GridView extends AbsListView {
                    //     perhaps it should be configurable (and more comprehensive).
                    if (false) {
                        if (event.hasNoModifiers()) {
                            handled = ensureSelectionOnMovementKey() && sequenceScroll(FOCUS_FORWARD);
                            handled = resurrectSelectionIfNeeded()
                                    || sequenceScroll(FOCUS_FORWARD);
                        } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                            handled = ensureSelectionOnMovementKey() && sequenceScroll(FOCUS_BACKWARD);
                            handled = resurrectSelectionIfNeeded()
                                    || sequenceScroll(FOCUS_BACKWARD);
                        }
                    }
                    break;
            }
        }

        if (!handled) {
            handled = sendToTextFilter(keyCode, count, event);
        if (handled) {
            return true;
        }

        if (handled) {
        if (sendToTextFilter(keyCode, count, event)) {
            return true;
        } else {
        }

        switch (action) {
            case KeyEvent.ACTION_DOWN:
                return super.onKeyDown(keyCode, event);
@@ -1596,7 +1601,6 @@ public class GridView extends AbsListView {
                return false;
        }
    }
    }

    /**
     * Scrolls up or down by the number of items currently present on screen.
+1 −1
Original line number Diff line number Diff line
@@ -774,7 +774,7 @@ public class ListPopupWindow {
    }

    /**
     * Filter key down events. By forwarding key up events to this function,
     * Filter key down events. By forwarding key down events to this function,
     * views using non-modal ListPopupWindow can have it handle key selection of items.
     *  
     * @param keyCode keyCode param passed to the host view's onKeyDown
+47 −34
Original line number Diff line number Diff line
@@ -2081,25 +2081,35 @@ public class ListView extends AbsListView {
            switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (event.hasNoModifiers()) {
                    if (ensureSelectionOnMovementKey()) {
                    handled = resurrectSelectionIfNeeded();
                    if (!handled) {
                        while (count-- > 0) {
                            handled |= arrowScroll(FOCUS_UP);
                            if (arrowScroll(FOCUS_UP)) {
                                handled = true;
                            } else {
                                break;
                            }
                        }
                    }
                } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                    handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_UP);
                    handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
                }
                break;

            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (event.hasNoModifiers()) {
                    if (ensureSelectionOnMovementKey()) {
                    handled = resurrectSelectionIfNeeded();
                    if (!handled) {
                        while (count-- > 0) {
                            handled |= arrowScroll(FOCUS_DOWN);
                            if (arrowScroll(FOCUS_DOWN)) {
                                handled = true;
                            } else {
                                break;
                            }
                        }
                    }
                } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                    handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_DOWN);
                    handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
                }
                break;

@@ -2117,19 +2127,22 @@ public class ListView extends AbsListView {

            case KeyEvent.KEYCODE_DPAD_CENTER:
            case KeyEvent.KEYCODE_ENTER:
                if (mItemCount > 0 && event.getRepeatCount() == 0) {
                    ensureSelectionOnMovementKey();
                if (event.hasNoModifiers()) {
                    handled = resurrectSelectionIfNeeded();
                    if (!handled
                            && event.getRepeatCount() == 0 && getChildCount() > 0) {
                        keyPressed();
                }
                        handled = true;
                    }
                }
                break;

            case KeyEvent.KEYCODE_SPACE:
                if (mPopup == null || !mPopup.isShowing()) {
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
                    } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                        handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
                    }
                    handled = true;
                }
@@ -2137,29 +2150,29 @@ public class ListView extends AbsListView {

            case KeyEvent.KEYCODE_PAGE_UP:
                if (event.hasNoModifiers()) {
                    handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_UP);
                    handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
                } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                    handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_UP);
                    handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
                }
                break;

            case KeyEvent.KEYCODE_PAGE_DOWN:
                if (event.hasNoModifiers()) {
                    handled = ensureSelectionOnMovementKey() && pageScroll(FOCUS_DOWN);
                    handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
                } else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
                    handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_DOWN);
                    handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
                }
                break;

            case KeyEvent.KEYCODE_MOVE_HOME:
                if (event.hasNoModifiers()) {
                    handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_UP);
                    handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
                }
                break;

            case KeyEvent.KEYCODE_MOVE_END:
                if (event.hasNoModifiers()) {
                    handled = ensureSelectionOnMovementKey() && fullScroll(FOCUS_DOWN);
                    handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
                }
                break;

@@ -2172,22 +2185,23 @@ public class ListView extends AbsListView {
                //     perhaps it should be configurable (and more comprehensive).
                if (false) {
                    if (event.hasNoModifiers()) {
                        handled = ensureSelectionOnMovementKey() && arrowScroll(FOCUS_DOWN);
                        handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN);
                    } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                        handled = ensureSelectionOnMovementKey() && arrowScroll(FOCUS_UP);
                        handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP);
                    }
                }
                break;
            }
        }

        if (!handled) {
            handled = sendToTextFilter(keyCode, count, event);
        if (handled) {
            return true;
        }

        if (handled) {
        if (sendToTextFilter(keyCode, count, event)) {
            return true;
        } else {
        }

        switch (action) {
            case KeyEvent.ACTION_DOWN:
                return super.onKeyDown(keyCode, event);
@@ -2202,7 +2216,6 @@ public class ListView extends AbsListView {
                return false;
        }
    }
    }

    /**
     * Scrolls up or down by the number of items currently present on screen.