Java Code Examples for android.view.KeyEvent#META_META_ON
The following examples show how to use
android.view.KeyEvent#META_META_ON .
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: KeyComboManager.java From talkback with Apache License 2.0 | 6 votes |
private KeyEvent convertKeyEventInArc(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: case KeyEvent.KEYCODE_BACK: // In Arc, Search + X is sent as KEYCODE_X with META_META_ON in Android. Android // converts META_META_ON + KEYCODE_ENTER and META_META_ON + KEYCODE_DEL to // KEYCODE_HOME and KEYCODE_BACK without META_META_ON. We add META_META_ON to this // key event to satisfy trigger modifier condition. We don't need to do this in // non-Arc since Search + X is usually sent as KEYCODE_X with META_META_ON and // META_META_LEFT_ON or META_META_RIGHT_ON. return new KeyEvent( event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getMetaState() | KeyEvent.META_META_ON); default: return event; } }
Example 2
Source File: DefaultKeyComboModel.java From talkback with Apache License 2.0 | 6 votes |
private void loadTriggerModifierFromPreferences() { SharedPreferences prefs = SharedPreferencesUtils.getSharedPreferences(mContext); int defaultTriggerModifier = mIsArc ? R.string.trigger_modifier_meta_entry_value : R.string.trigger_modifier_alt_entry_value; if (!prefs.contains(getPreferenceKeyForTriggerModifier())) { // Store default value in preferences to show it in preferences UI. prefs .edit() .putString( getPreferenceKeyForTriggerModifier(), mContext.getString(defaultTriggerModifier)) .apply(); } String triggerModifier = prefs.getString( getPreferenceKeyForTriggerModifier(), mContext.getString(defaultTriggerModifier)); if (triggerModifier.equals(mContext.getString(R.string.trigger_modifier_alt_entry_value))) { mTriggerModifier = KeyEvent.META_ALT_ON; } else if (triggerModifier.equals( mContext.getString(R.string.trigger_modifier_meta_entry_value))) { mTriggerModifier = KeyEvent.META_META_ON; } }
Example 3
Source File: LatinIME.java From hackerskeyboard with Apache License 2.0 | 5 votes |
private int getMetaState(boolean shifted) { int meta = 0; if (shifted) meta |= KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON; if (mModCtrl) meta |= KeyEvent.META_CTRL_ON | KeyEvent.META_CTRL_LEFT_ON; if (mModAlt) meta |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON; if (mModMeta) meta |= KeyEvent.META_META_ON | KeyEvent.META_META_LEFT_ON; return meta; }
Example 4
Source File: LatinIME.java From hackerskeyboard with Apache License 2.0 | 5 votes |
private void sendMetaKey(InputConnection ic, boolean isDown, boolean chording) { if (chording && delayChordingMetaModifier()) return; int key = sKeyboardSettings.chordingMetaKey; if (key == 0) key = KeyEvent.KEYCODE_META_LEFT; int meta = KeyEvent.META_META_ON | KeyEvent.META_META_LEFT_ON; if (isDown) { sendKeyDown(ic, key, meta); } else { sendKeyUp(ic, key, meta); } }
Example 5
Source File: KeyComboManager.java From talkback with Apache License 2.0 | 5 votes |
/** * Returns converted key code. This method converts the following key events. - Convert * KEYCODE_HOME with meta to KEYCODE_ENTER. - Convert KEYCODE_BACK with meta to KEYCODE_DEL. * * @param event Key event to be converted. * @return Converted key code. */ static int getConvertedKeyCode(KeyEvent event) { // We care only when meta key is pressed with. if ((event.getModifiers() & KeyEvent.META_META_ON) == 0) { return event.getKeyCode(); } if (event.getKeyCode() == KeyEvent.KEYCODE_HOME) { return KeyEvent.KEYCODE_ENTER; } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { return KeyEvent.KEYCODE_DEL; } else { return event.getKeyCode(); } }
Example 6
Source File: EmulatorView.java From Ansole with GNU General Public License v2.0 | 5 votes |
@Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (sTrapAltAndMeta) { boolean altEsc = mKeyListener.getAltSendsEsc(); boolean altOn = (event.getMetaState() & KeyEvent.META_ALT_ON) != 0; boolean metaOn = (event.getMetaState() & KeyEvent.META_META_ON) != 0; boolean altPressed = (keyCode == KeyEvent.KEYCODE_ALT_LEFT) || (keyCode == KeyEvent.KEYCODE_ALT_RIGHT); boolean altActive = mKeyListener.isAltActive(); if (altEsc && (altOn || altPressed || altActive || metaOn)) { if (event.getAction() == KeyEvent.ACTION_DOWN) { return onKeyDown(keyCode, event); } else { return onKeyUp(keyCode, event); } } } if (handleHardwareControlKey(keyCode, event)) { return true; } if (mKeyListener.isCtrlActive()) { if (event.getAction() == KeyEvent.ACTION_DOWN) { return onKeyDown(keyCode, event); } else { return onKeyUp(keyCode, event); } } return super.onKeyPreIme(keyCode, event); }
Example 7
Source File: KeyComboManager.java From talkback with Apache License 2.0 | 4 votes |
private boolean onKeyDown(KeyEvent event) { if (mIsArc) { event = convertKeyEventInArc(event); } mCurrentKeysDown.add(event.getKeyCode()); mCurrentKeyComboCode = getKeyComboCode(event); mCurrentKeyComboTime = event.getDownTime(); // Check modifier. int triggerModifier = mKeyComboModel.getTriggerModifier(); boolean hasModifier = triggerModifier != KeyComboModel.NO_MODIFIER; if (hasModifier && (triggerModifier & event.getModifiers()) != triggerModifier) { // Do nothing if condition of modifier is not met. mPassedKeys.addAll(mCurrentKeysDown); return false; } boolean isServiceActive = (mServiceState == SERVICE_STATE_ACTIVE); // If the current set of keys is a partial combo, consume the event. mHasPartialMatch = false; for (Map.Entry<String, Long> entry : mKeyComboModel.getKeyComboCodeMap().entrySet()) { if (!isServiceActive && !alwaysProcessCombo(entry.getKey())) { continue; } final int match = matchKeyEventWith(event, triggerModifier, entry.getValue()); if (match == EXACT_MATCH) { int comboId = getActionIdFromKey(entry.getKey()); EventId eventId = Performance.getInstance().onKeyComboEventReceived(comboId); // Checks interrupt events if matches key combos. To prevent interrupting actions generated // by key combos, we should send interrupt events // before performing key combos. interrupt(comboId); for (KeyComboListener listener : mListeners) { if (listener.onComboPerformed(comboId, eventId)) { mPerformedCombo = true; return true; } } } if (match == PARTIAL_MATCH) { mHasPartialMatch = true; } } // Do not handle key event if user has pressed search key (meta key) twice to open search // app. if (hasModifier && triggerModifier == KeyEvent.META_META_ON) { if (mPreviousKeyComboCode == mCurrentKeyComboCode && mCurrentKeyComboTime - mPreviousKeyComboTime < TIME_TO_DETECT_DOUBLE_TAP && (mCurrentKeyComboCode == KeyComboManager.getKeyComboCode( KeyEvent.META_META_ON, KeyEvent.KEYCODE_META_RIGHT) || mCurrentKeyComboCode == KeyComboManager.getKeyComboCode( KeyEvent.META_META_ON, KeyEvent.KEYCODE_META_LEFT))) { // Set KEY_COMBO_CODE_UNASSIGNED not to open search app again with following search // key event. mCurrentKeyComboCode = KeyComboModel.KEY_COMBO_CODE_UNASSIGNED; mPassedKeys.addAll(mCurrentKeysDown); return false; } } if (!mHasPartialMatch) { mPassedKeys.addAll(mCurrentKeysDown); } return mHasPartialMatch; }