List of usage examples for android.view KeyEvent META_SYM_ON
int META_SYM_ON
To view the source code for android.view KeyEvent META_SYM_ON.
Click Source Link
This mask is used to check whether the SYM meta key is pressed.
From source file:com.volosyukivan.WiFiInputMethod.java
void resetModifiers() { InputConnection conn = getCurrentInputConnection(); if (conn == null) { return;// w w w. j a va2 s . com } conn.clearMetaKeyStates(KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON); }
From source file:com.volosyukivan.WiFiInputMethod.java
void sendKey(int code, boolean down, boolean resetModifiers) { long time = System.currentTimeMillis(); if (time - lastWake > 5000) { wakeLock.acquire();//from w ww. j a v a 2s. co m wakeLock.release(); lastWake = time; } InputConnection conn = getCurrentInputConnection(); if (conn == null) { // Debug.d("connection closed"); return; } if (code < 0) { if (down == false) return; switch (code) { case KEY_HOME: keyHome(conn); break; case KEY_END: keyEnd(conn); break; case KEY_DEL: keyDel(conn); break; } return; } if (code == KeyEvent.KEYCODE_DPAD_LEFT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordLeft(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_RIGHT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordRight(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_CENTER) { if (pressedKeys.contains(KEY_CONTROL)) { if (!down) return; copy(conn); return; } if (pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT)) { if (!down) return; paste(conn); return; } } // if (pressedKeys.contains(KEY_CONTROL)) { // if (down == false) return; // switch (code) { // case KeyEvent.KEYCODE_A: selectAll(conn); break; // case KeyEvent.KEYCODE_X: cut(conn); break; // case KeyEvent.KEYCODE_C: copy(conn); break; // case KeyEvent.KEYCODE_V: paste(conn); break; // } // return; // } conn.sendKeyEvent(new KeyEvent(down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP, code)); if (resetModifiers) { conn.clearMetaKeyStates(KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON); } }
From source file:com.actionbarsherlock.internal.view.menu.MenuBuilder.java
@SuppressWarnings("deprecation") void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) { final boolean qwerty = isQwertyMode(); final int metaState = event.getMetaState(); final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); // Get the chars associated with the keyCode (i.e using any chording combo) final boolean isKeyCodeMapped = event.getKeyData(possibleChars); // The delete key is not mapped to '\b' so we treat it specially if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { return;/*from www . j a v a2 s . c o m*/ } // Look for an item whose shortcut is this key. final int N = mItems.size(); for (int i = 0; i < N; i++) { MenuItemImpl item = mItems.get(i); if (item.hasSubMenu()) { ((MenuBuilder) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); } final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && (shortcutChar != 0) && (shortcutChar == possibleChars.meta[0] || shortcutChar == possibleChars.meta[2] || (qwerty && shortcutChar == '\b' && keyCode == KeyEvent.KEYCODE_DEL)) && item.isEnabled()) { items.add(item); } } }
From source file:androidv7.rmenu.MBuilder.java
@SuppressWarnings("deprecation") void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) { final boolean qwerty = isQwertyMode(); final int metaState = event.getMetaState(); final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); // Get the chars associated with the keyCode (i.e using any chording combo) final boolean isKeyCodeMapped = event.getKeyData(possibleChars); // The delete key is not mapped to '\b' so we treat it specially if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { return;/*from w ww .ja va 2s.c om*/ } // Look for an item whose shortcut is this key. final int N = mItems.size(); for (int i = 0; i < N; i++) { MenuItemImpl item = mItems.get(i); if (item.hasSubMenu()) { ((MBuilder) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); } final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && (shortcutChar != 0) && (shortcutChar == possibleChars.meta[0] || shortcutChar == possibleChars.meta[2] || (qwerty && shortcutChar == '\b' && keyCode == KeyEvent.KEYCODE_DEL)) && item.isEnabled()) { items.add(item); } } }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
private void setInputConnectionMetaStateAsCurrentMetaKeyKeyListenerState() { InputConnection ic = getCurrentInputConnection(); if (ic != null) { int clearStatesFlags = 0; if (MyMetaKeyKeyListener.getMetaState(mMetaState, MyMetaKeyKeyListener.META_ALT_ON) == 0) clearStatesFlags += KeyEvent.META_ALT_ON; if (MyMetaKeyKeyListener.getMetaState(mMetaState, MyMetaKeyKeyListener.META_SHIFT_ON) == 0) clearStatesFlags += KeyEvent.META_SHIFT_ON; if (MyMetaKeyKeyListener.getMetaState(mMetaState, MyMetaKeyKeyListener.META_SYM_ON) == 0) clearStatesFlags += KeyEvent.META_SYM_ON; ic.clearMetaKeyStates(clearStatesFlags); }/*from w w w . ja v a 2 s . c o m*/ }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
public void updateShiftKeyState(EditorInfo attr) { InputConnection ic = getCurrentInputConnection(); if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()) { int oldState = getShiftState(); boolean isShifted = mShiftKeyState.isChording(); boolean isCapsLock = (oldState == Keyboard.SHIFT_CAPS_LOCKED || oldState == Keyboard.SHIFT_LOCKED); boolean isCaps = isCapsLock || getCursorCapsMode(ic, attr) != 0; //Log.i(TAG, "updateShiftKeyState isShifted=" + isShifted + " isCaps=" + isCaps + " isMomentary=" + mShiftKeyState.isMomentary() + " cursorCaps=" + getCursorCapsMode(ic, attr)); int newState = Keyboard.SHIFT_OFF; if (isShifted) { newState = (mSavedShiftState == Keyboard.SHIFT_LOCKED) ? Keyboard.SHIFT_CAPS : Keyboard.SHIFT_ON; } else if (isCaps) { newState = isCapsLock ? getCapsOrShiftLockState() : Keyboard.SHIFT_CAPS; }/*from www . j av a2 s .c o m*/ //Log.i(TAG, "updateShiftKeyState " + oldState + " -> " + newState); mKeyboardSwitcher.setShiftState(newState); } if (ic != null) { // Clear modifiers other than shift, to avoid them getting stuck int states = KeyEvent.META_FUNCTION_ON | KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK | KeyEvent.META_META_MASK | KeyEvent.META_SYM_ON; ic.clearMetaKeyStates(states); } }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
public void sendModifiableKeyChar(char ch) { // Support modified key events boolean modShift = isShiftMod(); if ((modShift || mModCtrl || mModAlt || mModMeta) && ch > 0 && ch < 127) { InputConnection ic = getCurrentInputConnection(); if (isConnectbot()) { if (mModAlt) { // send ESC prefix ic.commitText(Character.toString((char) 27), 1); }/* w w w . j a v a 2s . co m*/ if (mModCtrl) { int code = ch & 31; if (code == 9) { sendTab(); } else { ic.commitText(Character.toString((char) code), 1); } } else { ic.commitText(Character.toString(ch), 1); } handleModifierKeysUp(false, false); return; } // Non-ConnectBot // Restrict Shift modifier to ENTER and SPACE, supporting Shift-Enter etc. // Note that most special keys such as DEL or cursor keys aren't handled // by this charcode-based method. int combinedCode = asciiToKeyCode[ch]; if (combinedCode > 0) { int code = combinedCode & KF_MASK; boolean shiftable = (combinedCode & KF_SHIFTABLE) > 0; boolean upper = (combinedCode & KF_UPPER) > 0; boolean letter = (combinedCode & KF_LETTER) > 0; boolean shifted = modShift && (upper || shiftable); if (letter && !mModCtrl && !mModAlt && !mModMeta) { // Try workaround for issue 179 where letters don't get upcased ic.commitText(Character.toString(ch), 1); handleModifierKeysUp(false, false); } else { sendModifiedKeyDownUp(code, shifted); } return; } } if (ch >= '0' && ch <= '9') { //WIP InputConnection ic = getCurrentInputConnection(); ic.clearMetaKeyStates(KeyEvent.META_SHIFT_ON | KeyEvent.META_ALT_ON | KeyEvent.META_SYM_ON); //EditorInfo ei = getCurrentInputEditorInfo(); //Log.i(TAG, "capsmode=" + ic.getCursorCapsMode(ei.inputType)); //sendModifiedKeyDownUp(KeyEvent.KEYCODE_0 + ch - '0'); //return; } // Default handling for anything else, including unmodified ENTER and SPACE. sendKeyChar(ch); }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
public void sendModifiableKeyChar(char ch) { // Support modified key events boolean modShift = isShiftMod(); if ((modShift || mModCtrl || mModAlt || mModMeta) && ch > 0 && ch < 127) { InputConnection ic = getCurrentInputConnection(); if (isConnectbot()) { if (mModAlt) { // send ESC prefix ic.commitText(Character.toString((char) 27), 1); }//from w w w.j a v a 2 s. com if (mModCtrl) { int code = ch & 31; if (code == 9) { sendTab(); } else { ic.commitText(Character.toString((char) code), 1); } } else { ic.commitText(Character.toString(ch), 1); } handleModifierKeysUp(false, false); return; } // Non-ConnectBot // Restrict Shift modifier to ENTER and SPACE, supporting Shift-Enter etc. // Note that most special keys such as DEL or cursor keys aren't handled // by this charcode-based method. int combinedCode = asciiToKeyCode[ch]; if (combinedCode > 0) { int code = combinedCode & KF_MASK; boolean shiftable = (combinedCode & KF_SHIFTABLE) > 0; boolean upper = (combinedCode & KF_UPPER) > 0; boolean letter = (combinedCode & KF_LETTER) > 0; boolean shifted = modShift && (upper || shiftable); if (letter && !mModCtrl && !mModAlt && !mModMeta) { // Try workaround for issue 179 where letters don't get upcased ic.commitText(Character.toString(ch), 1); handleModifierKeysUp(false, false); } else if ((ch == 'a' || ch == 'A') && mModCtrl) { // Special case for Ctrl-A to work around accidental select-all-then-replace. if (sKeyboardSettings.ctrlAOverride == 0) { // Ignore Ctrl-A, treat Ctrl-Alt-A as Ctrl-A. if (mModAlt) { boolean isChordingAlt = mAltKeyState.isChording(); setModAlt(false); sendModifiedKeyDownUp(code, shifted); if (isChordingAlt) setModAlt(true); } else { Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_ctrl_a_override_info), Toast.LENGTH_LONG).show(); // Clear the Ctrl modifier (and others) sendModifierKeysDown(shifted); sendModifierKeysUp(shifted); return; // ignore the key } } else if (sKeyboardSettings.ctrlAOverride == 1) { // Clear the Ctrl modifier (and others) sendModifierKeysDown(shifted); sendModifierKeysUp(shifted); return; // ignore the key } else { // Standard Ctrl-A behavior. sendModifiedKeyDownUp(code, shifted); } } else { sendModifiedKeyDownUp(code, shifted); } return; } } if (ch >= '0' && ch <= '9') { //WIP InputConnection ic = getCurrentInputConnection(); ic.clearMetaKeyStates(KeyEvent.META_SHIFT_ON | KeyEvent.META_ALT_ON | KeyEvent.META_SYM_ON); //EditorInfo ei = getCurrentInputEditorInfo(); //Log.i(TAG, "capsmode=" + ic.getCursorCapsMode(ei.inputType)); //sendModifiedKeyDownUp(KeyEvent.KEYCODE_0 + ch - '0'); //return; } // Default handling for anything else, including unmodified ENTER and SPACE. sendKeyChar(ch); }