Java Code Examples for android.view.KeyEvent#KEYCODE_SYM

The following examples show how to use android.view.KeyEvent#KEYCODE_SYM . 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: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles presses of the meta keys.
 */
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        press(content, CAP);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        press(content, ALT);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        press(content, SYM);
        return true;
    }

    return false; // no super to call through to
}
 
Example 2
Source File: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles release of the meta keys.
 */
public boolean onKeyUp(View view, Editable content, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        release(content, CAP, event);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        release(content, ALT, event);
        return true;
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        release(content, SYM, event);
        return true;
    }

    return false; // no super to call through to
}
 
Example 3
Source File: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles presses of the meta keys.
 */
public static long handleKeyDown(long state, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        return press(state, META_SHIFT_ON, META_SHIFT_MASK,
                META_CAP_LOCKED, META_CAP_PRESSED, META_CAP_RELEASED, META_CAP_USED);
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        return press(state, META_ALT_ON, META_ALT_MASK,
                META_ALT_LOCKED, META_ALT_PRESSED, META_ALT_RELEASED, META_ALT_USED);
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        return press(state, META_SYM_ON, META_SYM_MASK,
                META_SYM_LOCKED, META_SYM_PRESSED, META_SYM_RELEASED, META_SYM_USED);
    }
    return state;
}
 
Example 4
Source File: MetaKeyKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Handles release of the meta keys.
 */
public static long handleKeyUp(long state, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        return release(state, META_SHIFT_ON, META_SHIFT_MASK,
                META_CAP_PRESSED, META_CAP_RELEASED, META_CAP_USED, event);
    }

    if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        return release(state, META_ALT_ON, META_ALT_MASK,
                META_ALT_PRESSED, META_ALT_RELEASED, META_ALT_USED, event);
    }

    if (keyCode == KeyEvent.KEYCODE_SYM) {
        return release(state, META_SYM_ON, META_SYM_MASK,
                META_SYM_PRESSED, META_SYM_RELEASED, META_SYM_USED, event);
    }
    return state;
}
 
Example 5
Source File: InputMethodManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatches an input event to the IME.
 *
 * Returns {@link #DISPATCH_HANDLED} if the event was handled.
 * Returns {@link #DISPATCH_NOT_HANDLED} if the event was not handled.
 * Returns {@link #DISPATCH_IN_PROGRESS} if the event is in progress and the
 * callback will be invoked later.
 *
 * @hide
 */
public int dispatchInputEvent(InputEvent event, Object token,
        FinishedInputEventCallback callback, Handler handler) {
    synchronized (mH) {
        if (mCurMethod != null) {
            if (event instanceof KeyEvent) {
                KeyEvent keyEvent = (KeyEvent)event;
                if (keyEvent.getAction() == KeyEvent.ACTION_DOWN
                        && keyEvent.getKeyCode() == KeyEvent.KEYCODE_SYM
                        && keyEvent.getRepeatCount() == 0) {
                    showInputMethodPickerLocked();
                    return DISPATCH_HANDLED;
                }
            }

            if (DEBUG) Log.v(TAG, "DISPATCH INPUT EVENT: " + mCurMethod);

            PendingEvent p = obtainPendingEventLocked(
                    event, token, mCurId, callback, handler);
            if (mMainLooper.isCurrentThread()) {
                // Already running on the IMM thread so we can send the event immediately.
                return sendInputEventOnMainLooperLocked(p);
            }

            // Post the event to the IMM thread.
            Message msg = mH.obtainMessage(MSG_SEND_INPUT_EVENT, p);
            msg.setAsynchronous(true);
            mH.sendMessage(msg);
            return DISPATCH_IN_PROGRESS;
        }
    }
    return DISPATCH_NOT_HANDLED;
}
 
Example 6
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Let touch navigation method intercept key event first
    if (_navMethod.onKeyDown(keyCode, event)) {
        return true;
    }

    //check if direction or symbol key
    if (KeysInterpreter.isNavigationKey(event)) {
        handleNavigationKey(keyCode, event);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_SYM ||
            keyCode == KeyCharacterMap.PICKER_DIALOG_INPUT) {
        showCharacterPicker(
                PICKER_SETS.get(KeyCharacterMap.PICKER_DIALOG_INPUT), false);
        return true;
    }

    //check if character is printable
    char c = KeysInterpreter.keyEventToPrintableChar(event);
    if (c == Language.NULL_CHAR) {
        return super.onKeyDown(keyCode, event);
    }

    int repeatCount = event.getRepeatCount();
    //handle multiple (held) key presses
    if (repeatCount == 1) {
        if (_isLongPressCaps) {
            handleLongPressCaps(c);
        } else {
            handleLongPressDialogDisplay(c);
        }
    } else if (repeatCount == 0
            || _isLongPressCaps && !Character.isLowerCase(c)
            || !_isLongPressCaps && PICKER_SETS.get(c) == null) {
        _fieldController.onPrintableChar(c);
    }

    return true;
}
 
Example 7
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Let touch navigation method intercept key event first
    if (_navMethod.onKeyDown(keyCode, event)) {
        return true;
    }

    //check if direction or symbol key
    if (KeysInterpreter.isNavigationKey(event)) {
        handleNavigationKey(keyCode, event);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_SYM ||
            keyCode == KeyCharacterMap.PICKER_DIALOG_INPUT) {
        showCharacterPicker(
                PICKER_SETS.get(KeyCharacterMap.PICKER_DIALOG_INPUT), false);
        return true;
    }

    //check if character is printable
    char c = KeysInterpreter.keyEventToPrintableChar(event);
    if (c == Language.NULL_CHAR) {
        return super.onKeyDown(keyCode, event);
    }

    int repeatCount = event.getRepeatCount();
    //handle multiple (held) key presses
    if (repeatCount == 1) {
        if (_isLongPressCaps) {
            handleLongPressCaps(c);
        } else {
            handleLongPressDialogDisplay(c);
        }
    } else if (repeatCount == 0
            || _isLongPressCaps && !Character.isLowerCase(c)
            || !_isLongPressCaps && PICKER_SETS.get(c) == null) {
        _fieldController.onPrintableChar(c);
    }

    return true;
}
 
Example 8
Source File: FreeScrollingTextField.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Let touch navigation method intercept key event first
    if (_navMethod.onKeyDown(keyCode, event)) {
        return true;
    }

    //check if direction or symbol key
    if (KeysInterpreter.isNavigationKey(event)) {
        handleNavigationKey(keyCode, event);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_SYM ||
            keyCode == KeyCharacterMap.PICKER_DIALOG_INPUT) {
        showCharacterPicker(
                PICKER_SETS.get(KeyCharacterMap.PICKER_DIALOG_INPUT), false);
        return true;
    }

    //check if character is printable
    char c = KeysInterpreter.keyEventToPrintableChar(event);
    if (c == Language.NULL_CHAR) {
        return super.onKeyDown(keyCode, event);
    }

    int repeatCount = event.getRepeatCount();
    //handle multiple (held) key presses
    if (repeatCount == 1) {
        if (_isLongPressCaps) {
            handleLongPressCaps(c);
        } else {
            handleLongPressDialogDisplay(c);
        }
    } else if (repeatCount == 0
            || _isLongPressCaps && !Character.isLowerCase(c)
            || !_isLongPressCaps && PICKER_SETS.get(c) == null) {
        _fieldController.onPrintableChar(c);
    }

    return true;
}
 
Example 9
Source File: InputConnectionHacker.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sendKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT || keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
        isShiftPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    } else if (keyCode == KeyEvent.KEYCODE_ALT_LEFT || keyCode == KeyEvent.KEYCODE_ALT_RIGHT
            || keyCode == KeyEvent.KEYCODE_NUM) {
        isAltPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    } else if (keyCode == KeyEvent.KEYCODE_SYM) {
        isSymPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    } else if (keyCode == KeyEvent.KEYCODE_CTRL_LEFT || keyCode == KeyEvent.KEYCODE_CTRL_RIGHT) {
        isCtrlPressed = event.getAction() == KeyEvent.ACTION_DOWN;
    }
    return ic.sendKeyEvent(event);
}