Java Code Examples for android.view.KeyEvent#KEYCODE_NUMPAD_ENTER

The following examples show how to use android.view.KeyEvent#KEYCODE_NUMPAD_ENTER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatrixKeypadActivity.java    From drivers-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (USE_LAYOUT) {
        setContentView(R.layout.layout_main);
    }
    try {
        mMatrixKeypadDriver = new MatrixKeypadInputDriver(BoardDefaults.getRowPins(),
                BoardDefaults.getColPins(),
                new int[] {KeyEvent.KEYCODE_NUMPAD_1, KeyEvent.KEYCODE_NUMPAD_2,
                        KeyEvent.KEYCODE_NUMPAD_3, KeyEvent.KEYCODE_NUMPAD_4,
                        KeyEvent.KEYCODE_NUMPAD_5, KeyEvent.KEYCODE_NUMPAD_6,
                        KeyEvent.KEYCODE_NUMPAD_7, KeyEvent.KEYCODE_NUMPAD_8,
                        KeyEvent.KEYCODE_NUMPAD_9, KeyEvent.KEYCODE_NUMPAD_MULTIPLY,
                        KeyEvent.KEYCODE_NUMPAD_0, KeyEvent.KEYCODE_NUMPAD_ENTER});
        mMatrixKeypadDriver.register();
    } catch (IOException e) {
        Log.e(TAG, "Cannot register matrix keypad driver:", e);
    }
}
 
Example 2
Source File: HListView.java    From TV-HorizontalListView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean handled = false;
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = moveLeft();
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = moveRight();
            break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_ENTER:
            event.startTracking();
            handled = true;
            break;
    }
    return handled || super.onKeyDown(keyCode, event);
}
 
Example 3
Source File: HListView.java    From TV-HorizontalListView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    boolean handled = false;

    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_ENTER:
            long duration = event.getEventTime() - event.getDownTime();
            if (event.isTracking() && event.getDownTime() > mLastLongPress && duration < ViewConfiguration.getLongPressTimeout()) {
                performItemClick(getSelectedView(), getSelectedItemPosition(), getSelectedItemId());
            }
            handled = true;
            break;
    }

    return handled || super.onKeyUp(keyCode, event);
}
 
Example 4
Source File: HListView.java    From TV-HorizontalListView with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    boolean handled = false;

    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_ENTER:
            mLastLongPress = event.getEventTime();
            performItemLongClick(getSelectedView(), getSelectedItemPosition(), getSelectedItemId());
            handled = true;
            break;
    }

    return handled || super.onKeyLongPress(keyCode, event);
}
 
Example 5
Source File: KeyListener.java    From yubikit-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    InputDevice device = event.getDevice();
    if (device.getVendorId() != YUBICO_VID) {
        // do not handle anything that not from yubikey
        return false;
    }

    if (event.getAction() == KeyEvent.ACTION_UP) {
        // use id of keyboard device to distinguish current input device
        // in case of multiple keys inserted
        final int deviceId = event.getDeviceId();
        final StringBuilder otpBuffer = inputBuffers.get(deviceId, new StringBuilder());
        if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER) {
            // Carriage return seen. Assume this is the end of the OTP credential and notify immediately.
            listener.onOtpReceived(otpBuffer.toString());
            inputBuffers.delete(deviceId);
        } else {
            if (otpBuffer.length() == 0) {
                // in case if we never get keycode enter (which is pretty generic scenario) we set timer for 1 sec
                // upon expiration we assume that we have no more input from key
                handler.postDelayed(new InputTimerTask(deviceId), DEFAULT_KEY_DELAY_MS);
            }
            otpBuffer.append((char) event.getUnicodeChar());
            inputBuffers.put(deviceId, otpBuffer);
        }
    }
    return true;
}
 
Example 6
Source File: BaseEvaluatorActivity.java    From ncalc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_ENTER:
            if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
                clickEvaluate();
            }
            return true;
    }
    return false;
}
 
Example 7
Source File: GraphAddFunction.java    From ncalc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_NUMPAD_ENTER:
        case KeyEvent.KEYCODE_ENTER:
            if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
                updateRect();
                finish();
            }
            return true;
    }
    return false;
}
 
Example 8
Source File: PasscodeEditText.java    From passcode with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sendKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (keyCallback != null) {
            switch (event.getKeyCode()) {
                case KeyEvent.KEYCODE_DEL:
                    keyCallback.onDelete();
                    break;
                case KeyEvent.KEYCODE_0:
                case KeyEvent.KEYCODE_1:
                case KeyEvent.KEYCODE_2:
                case KeyEvent.KEYCODE_3:
                case KeyEvent.KEYCODE_4:
                case KeyEvent.KEYCODE_5:
                case KeyEvent.KEYCODE_6:
                case KeyEvent.KEYCODE_7:
                case KeyEvent.KEYCODE_8:
                case KeyEvent.KEYCODE_9:
                    keyCallback.onNext(event.getNumber());
                    break;
                case KeyEvent.KEYCODE_NUMPAD_ENTER:
                case KeyEvent.KEYCODE_ENTER:
                case KeyEvent.KEYCODE_DPAD_CENTER:
                    keyCallback.onDone();
                    break;
            }
        } else {
            throw new IllegalStateException("KeyCallback is null");
        }
    }
    return super.sendKeyEvent(event);
}
 
Example 9
Source File: KeyboardWidget.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public boolean dispatchKeyEvent(final KeyEvent event) {
    final int keyCode = event.getKeyCode();
    final InputConnection connection = mInputConnection;
    if (connection != null) {
        if (isAttachToWindowWidget()) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
                return false;
            } else {
                connection.sendKeyEvent(event);
                hide(UIWidget.KEEP_WIDGET);
            }
            return true;
        }
        // Android Components do not support InputConnection.sendKeyEvent()
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            Log.e("reb", "key = " + KeyEvent.keyCodeToString(keyCode));

            switch (keyCode) {
                case KeyEvent.KEYCODE_DEL:
                    handleBackspace();
                    return true;
                case KeyEvent.KEYCODE_ENTER:
                case KeyEvent.KEYCODE_NUMPAD_ENTER:
                    handleDone();
                    return true;
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    moveCursor(-1);
                    return true;
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    moveCursor(1);
                    return true;
                default:
                    break;
            }
            if (event.getUnicodeChar() != 0) {
                KeyCharacterMap map = event.getKeyCharacterMap();
                String value = String.valueOf((char) map.get(keyCode, event.getMetaState()));
                connection.commitText(value, 1);
                return true;
            }
        }
    }
    return false;
}
 
Example 10
Source File: KeyEventProfileActivity.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
/**
 * Get Configure string.
 * 
 * @param keymode Key Mode.
 * @param keyId Key ID.
 * @return config Configure string.
 */
private String getConfig(final KeyMode keymode, final int keyId) {
    String config = "";
    int nIndex = -1;
    switch (keyId) {
    case KeyEvent.KEYCODE_NUMPAD_0:
        nIndex = 0;
        break;
    case KeyEvent.KEYCODE_NUMPAD_1:
        nIndex = 1;
        break;
    case KeyEvent.KEYCODE_NUMPAD_2:
        nIndex = 2;
        break;
    case KeyEvent.KEYCODE_NUMPAD_3:
        nIndex = 3;
        break;
    case KeyEvent.KEYCODE_NUMPAD_4:
        nIndex = 4;
        break;
    case KeyEvent.KEYCODE_NUMPAD_5:
        nIndex = 5;
        break;
    case KeyEvent.KEYCODE_NUMPAD_6:
        nIndex = 6;
        break;
    case KeyEvent.KEYCODE_NUMPAD_7:
        nIndex = 7;
        break;
    case KeyEvent.KEYCODE_NUMPAD_8:
        nIndex = 8;
        break;
    case KeyEvent.KEYCODE_NUMPAD_9:
        nIndex = 9;
        break;
    case KeyEvent.KEYCODE_NUMPAD_DOT:
        nIndex = 10;
        break;
    case KeyEvent.KEYCODE_NUMPAD_ENTER:
        nIndex = 11;
        break;
    default:
        nIndex = -1;
        break;
    }
    if (nIndex != -1) {
        switch (mKeyMode) {
        case MEDIA_CTRL:
            config = mConfigMediaCtrl[nIndex];
            break;
        case DPAD_BUTTON:
            config = mConfigDpad[nIndex];
            break;
        case USER:
            config = mConfigUser[nIndex];
            break;
        case STD_KEY:
        default:
            config = mConfigStdKey[nIndex];
            break;
        }
    } else {
        config = "";
    }

    return config;
}
 
Example 11
Source File: KeyNavigationUtil.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the given event is any of ENTER or NUMPAD ENTER.
 * @param event Event to be checked.
 * @return Whether the event should be processed as ENTER.
 */
public static boolean isEnter(KeyEvent event) {
    return isActionUp(event) && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
            || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER);
}
 
Example 12
Source File: KeyNavigationUtil.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the given event is any of ENTER or NUMPAD ENTER.
 * @param event Event to be checked.
 * @return Whether the event should be processed as ENTER.
 */
public static boolean isEnter(KeyEvent event) {
    return isActionUp(event) && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
            || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER);
}
 
Example 13
Source File: KeyNavigationUtil.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the given event is any of ENTER or NUMPAD ENTER.
 * @param event Event to be checked.
 * @return Whether the event should be processed as ENTER.
 */
public static boolean isEnter(KeyEvent event) {
    return isActionUp(event) && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
            || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER);
}