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

Commit 24d36f59 authored by Michael Wright's avatar Michael Wright
Browse files

Take advantage of KeyEvent.isConfirmKey

Change-Id: I2925c624338a5c622a7b3fef05b62099465b6389
parent 25b0c309
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -2925,9 +2925,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
        if (KeyEvent.isConfirmKey(keyCode)) {
            if (!isEnabled()) {
                return true;
            }
@@ -2943,7 +2941,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                setPressed(false);
                return true;
            }
            break;
        }
        return super.onKeyUp(keyCode, event);
    }
+3 −10
Original line number Diff line number Diff line
@@ -1228,13 +1228,9 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER: {
            
        if (KeyEvent.isConfirmKey(keyCode)) {
            if (mReceivedInvokeKeyDown) {
                if (mItemCount > 0) {
    
                    dispatchPress(mSelectedChild);
                    postDelayed(new Runnable() {
                        @Override
@@ -1251,11 +1247,8 @@ public class Gallery extends AbsSpinner implements GestureDetector.OnGestureList

            // Clear the flag
            mReceivedInvokeKeyDown = false;
            
            return true;
        }
        }

        return super.onKeyUp(keyCode, event);
    }
    
+5 −12
Original line number Diff line number Diff line
@@ -821,8 +821,7 @@ public class ListPopupWindow {
            // to select one of its items
            if (keyCode != KeyEvent.KEYCODE_SPACE
                    && (mDropDownList.getSelectedItemPosition() >= 0
                            || (keyCode != KeyEvent.KEYCODE_ENTER
                                    && keyCode != KeyEvent.KEYCODE_DPAD_CENTER))) {
                            || !KeyEvent.isConfirmKey(keyCode))) {
                int curIndex = mDropDownList.getSelectedItemPosition();
                boolean consumed;

@@ -910,16 +909,10 @@ public class ListPopupWindow {
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (isShowing() && mDropDownList.getSelectedItemPosition() >= 0) {
            boolean consumed = mDropDownList.onKeyUp(keyCode, event);
            if (consumed) {
                switch (keyCode) {
                    // if the list accepts the key events and the key event
                    // was a click, the text view gets the selected item
                    // from the drop down as its content
                    case KeyEvent.KEYCODE_ENTER:
                    case KeyEvent.KEYCODE_DPAD_CENTER:
            if (consumed && KeyEvent.isConfirmKey(keyCode)) {
                // if the list accepts the key events and the key event was a click, the text view
                // gets the selected item from the drop down as its content
                dismiss();
                        break;
                }
            }
            return consumed;
        }