Java Code Examples for android.view.KeyEvent#ACTION_MULTIPLE
The following examples show how to use
android.view.KeyEvent#ACTION_MULTIPLE .
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: BaseMovementMethod.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public boolean onKeyOther(TextView widget, Spannable text, KeyEvent event) { final int movementMetaState = getMovementMetaState(text, event); final int keyCode = event.getKeyCode(); if (keyCode != KeyEvent.KEYCODE_UNKNOWN && event.getAction() == KeyEvent.ACTION_MULTIPLE) { final int repeat = event.getRepeatCount(); boolean handled = false; for (int i = 0; i < repeat; i++) { if (!handleMovementKey(widget, text, keyCode, movementMetaState, event)) { break; } handled = true; } if (handled) { MetaKeyKeyListener.adjustMetaAfterKeypress(text); MetaKeyKeyListener.resetLockedMeta(text); } return handled; } return false; }
Example 2
Source File: BaseKeyListener.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting * the event's text into the content. */ public boolean onKeyOther(View view, Editable content, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_MULTIPLE || event.getKeyCode() != KeyEvent.KEYCODE_UNKNOWN) { // Not something we are interested in. return false; } int selectionStart = Selection.getSelectionStart(content); int selectionEnd = Selection.getSelectionEnd(content); if (selectionEnd < selectionStart) { int temp = selectionEnd; selectionEnd = selectionStart; selectionStart = temp; } CharSequence text = event.getCharacters(); if (text == null) { return false; } content.replace(selectionStart, selectionEnd, text); return true; }
Example 3
Source File: KeyComboManager.java From talkback with Apache License 2.0 | 6 votes |
/** * Handles incoming key events. May intercept keys if the user seems to be performing a key combo. * * @param event The key event. * @return {@code true} if the key was intercepted. */ @Override public boolean onKeyEvent(KeyEvent event, EventId eventId) { if (mKeyEventDelegate != null) { if (mKeyEventDelegate.onKeyEvent(event, eventId)) { return true; } } if (!mHasPartialMatch && !mPerformedCombo && (!mMatchKeyCombo || mListeners.isEmpty())) { return false; } switch (event.getAction()) { case KeyEvent.ACTION_DOWN: return onKeyDown(event); case KeyEvent.ACTION_MULTIPLE: return mHasPartialMatch; case KeyEvent.ACTION_UP: return onKeyUp(event); default: return false; } }
Example 4
Source File: ArrowKeyMovementMethod.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public boolean onKeyOther(TextView view, Spannable text, KeyEvent event) { int code = event.getKeyCode(); if (code != KeyEvent.KEYCODE_UNKNOWN && event.getAction() == KeyEvent.ACTION_MULTIPLE) { int repeat = event.getRepeatCount(); boolean handled = false; while ((--repeat) > 0) { handled |= executeDown(view, text, code,event); } return handled; } return false; }
Example 5
Source File: PDevice.java From PHONK with GNU General Public License v3.0 | 5 votes |
private ReturnObject keyEventToJs(KeyEvent event) { ReturnObject o = new ReturnObject(); o.put("key", event.getKeyCode()); o.put("id", event.getDeviceId()); String action = "unknown"; switch (event.getAction()) { case KeyEvent.ACTION_DOWN: action = "down"; break; case KeyEvent.ACTION_UP: action = "up"; break; case KeyEvent.ACTION_MULTIPLE: action = "multiple"; break; } o.put("action", action); o.put("alt", event.isAltPressed()); o.put("ctrl", event.isCtrlPressed()); o.put("fn", event.isFunctionPressed()); o.put("meta", event.isMetaPressed()); o.put("chars", event.getCharacters()); o.put("number", event.getNumber()); return o; }
Example 6
Source File: CapacitorWebView.java From OsmGo with MIT License | 5 votes |
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_MULTIPLE) { evaluateJavascript("document.activeElement.value = document.activeElement.value + '" + event.getCharacters() + "';", null); return false; } return super.dispatchKeyEvent(event); }
Example 7
Source File: PlusMinusEditText.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean isKeyOfInterest = keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER; boolean isReleased = event.getAction() == KeyEvent.ACTION_UP; boolean isPressed = event.getAction() == KeyEvent.ACTION_DOWN && event.getAction() != KeyEvent.ACTION_MULTIPLE; if (isKeyOfInterest && isReleased) { stopUpdating(); } else if (isKeyOfInterest && isPressed) { startUpdating(v == plusImage); } return false; }
Example 8
Source File: NumberPicker.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean isKeyOfInterest = keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER; boolean isReleased = event.getAction() == KeyEvent.ACTION_UP; boolean isPressed = event.getAction() == KeyEvent.ACTION_DOWN && event.getAction() != KeyEvent.ACTION_MULTIPLE; if (isKeyOfInterest && isReleased) { stopUpdating(); } else if (isKeyOfInterest && isPressed) { startUpdating(v == plusButton); } return false; }
Example 9
Source File: ArrowKeyMovementMethod.java From JotaTextEditor with Apache License 2.0 | 5 votes |
public boolean onKeyOther(TextView view, Spannable text, KeyEvent event) { int code = event.getKeyCode(); if (code != KeyEvent.KEYCODE_UNKNOWN && event.getAction() == KeyEvent.ACTION_MULTIPLE) { int repeat = event.getRepeatCount(); boolean handled = false; while ((--repeat) > 0) { handled |= executeDown(view, text, code,event); } return handled; } return false; }
Example 10
Source File: AbstractUniversalDateWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean isKeyOfInterest = keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER; boolean isReleased = event.getAction() == KeyEvent.ACTION_UP; boolean isPressed = event.getAction() == KeyEvent.ACTION_DOWN && event.getAction() != KeyEvent.ACTION_MULTIPLE; if (isKeyOfInterest && isReleased) { stopUpdating(); } else if (isKeyOfInterest && isPressed) { startUpdating(v == mView, mHandler); } return false; }
Example 11
Source File: UnityPlayerActivity.java From android-unity with MIT License | 4 votes |
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_MULTIPLE) return mUnityPlayer.injectEvent(event); return super.dispatchKeyEvent(event); }
Example 12
Source File: TwoWayGridView.java From recent-images with MIT License | 4 votes |
private boolean commonKey(int keyCode, int count, KeyEvent event) { if (mAdapter == null) { return false; } if (mDataChanged) { layoutChildren(); } boolean handled = false; int action = event.getAction(); if (action != KeyEvent.ACTION_UP) { if (mSelectedPosition < 0) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: case KeyEvent.KEYCODE_ENTER: resurrectSelection(); return true; } } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (!event.isAltPressed()) { handled = mGridBuilder.arrowScroll(FOCUS_LEFT); } else { handled = fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!event.isAltPressed()) { handled = mGridBuilder.arrowScroll(FOCUS_RIGHT); } else { handled = fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_DPAD_UP: if (!event.isAltPressed()) { handled = mGridBuilder.arrowScroll(FOCUS_UP); } else { handled = fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (!event.isAltPressed()) { handled = mGridBuilder.arrowScroll(FOCUS_DOWN); } else { handled = fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: { if (getChildCount() > 0 && event.getRepeatCount() == 0) { keyPressed(); } return true; } case KeyEvent.KEYCODE_SPACE: //if (mPopup == null || !mPopup.isShowing()) { if (!event.isShiftPressed()) { handled = pageScroll(FOCUS_DOWN); } else { handled = pageScroll(FOCUS_UP); } //} break; } } //if (!handled) { // handled = sendToTextFilter(keyCode, count, event); //} if (handled) { return true; } else { switch (action) { case KeyEvent.ACTION_DOWN: return super.onKeyDown(keyCode, event); case KeyEvent.ACTION_UP: return super.onKeyUp(keyCode, event); case KeyEvent.ACTION_MULTIPLE: return super.onKeyMultiple(keyCode, count, event); default: return false; } } }
Example 13
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 4 votes |
@Override public boolean onKey(View v, final int keyCode, KeyEvent event) { LOGI("VolumePanel", "onKey(" + keyCode + ")"); // Don't handle ANYTHING when a call is in progress! if (mCallState != TelephonyManager.CALL_STATE_IDLE) return super.onKey(v, keyCode, event); switch (keyCode) { // Handle the DOWN + MULTIPLE action (holding down). case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: final int adjust = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER); switch (event.getAction()) { case KeyEvent.ACTION_DOWN: // If another key was pressed while holding on to // one volume key, we'll need to abort mission. if (mKeyCodeDown != 0) { mIgnoreNextKeyUp = true; mHandler.removeMessages(MSG_VOLUME_LONG_PRESS); return super.onKey(v, keyCode, event); } mKeyCodeDown = event.getKeyCode(); mKeyTimeDown = System.currentTimeMillis(); event.startTracking(); // NOTE: we'll allow long press events if we've set an action. boolean callIdle = (mCallState == TelephonyManager.CALL_STATE_IDLE); if (!noLongPress || hasLongPressAction(keyCode)) { mHandler.sendMessageDelayed(mHandler.obtainMessage( MSG_VOLUME_LONG_PRESS, event), ((callIdle && hasLongPressAction(keyCode)) ? mLongPressTimeout : mLongPressTimeout / 2)); } break; case KeyEvent.ACTION_UP: case KeyEvent.ACTION_MULTIPLE: boolean hasLongPress = mHandler.hasMessages(MSG_VOLUME_LONG_PRESS); mHandler.removeMessages(MSG_VOLUME_LONG_PRESS); boolean ignoreNextKeyUp = mIgnoreNextKeyUp; mIgnoreNextKeyUp = false; mKeyCodeDown = 0; // We've been told to let this one go. if (ignoreNextKeyUp || event.isCanceled()) { mKeyTimeDown = 0; return true; } if ((hasLongPress || noLongPress) && (System.currentTimeMillis() - mKeyTimeDown) < mLongPressTimeout) { mVolumeDirty = true; mKeyTimeDown = 0; if (!firstReveal || (firstReveal && isShowing())) { adjustVolume(adjust); show(); } else { reveal(); } } break; } break; case KeyEvent.KEYCODE_VOLUME_MUTE: switch (event.getAction()) { case KeyEvent.ACTION_UP: boolean mute = isMuted(STREAM_RING); mAudioManager.setStreamMute(STREAM_RING, !mute); mAudioManager.setStreamMute(STREAM_NOTIFICATION, !mute); mVolumeDirty = true; show(); break; } break; } return super.onKey(v, keyCode, event); }
Example 14
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 4 votes |
@Override public boolean onKey(View v, final int keyCode, KeyEvent event) { LOGI("VolumePanel", "onKey(" + keyCode + ")"); // Don't handle ANYTHING when a call is in progress! if (mCallState != TelephonyManager.CALL_STATE_IDLE) return super.onKey(v, keyCode, event); switch (keyCode) { // Handle the DOWN + MULTIPLE action (holding down). case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: final int adjust = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER); switch (event.getAction()) { case KeyEvent.ACTION_DOWN: // If another key was pressed while holding on to // one volume key, we'll need to abort mission. if (mKeyCodeDown != 0) { mIgnoreNextKeyUp = true; mHandler.removeMessages(MSG_VOLUME_LONG_PRESS); return super.onKey(v, keyCode, event); } mKeyCodeDown = event.getKeyCode(); mKeyTimeDown = System.currentTimeMillis(); event.startTracking(); // NOTE: we'll allow long press events if we've set an action. boolean callIdle = (mCallState == TelephonyManager.CALL_STATE_IDLE); if (!noLongPress || hasLongPressAction(keyCode)) { mHandler.sendMessageDelayed(mHandler.obtainMessage( MSG_VOLUME_LONG_PRESS, event), ((callIdle && hasLongPressAction(keyCode)) ? mLongPressTimeout : mLongPressTimeout / 2)); } break; case KeyEvent.ACTION_UP: case KeyEvent.ACTION_MULTIPLE: boolean hasLongPress = mHandler.hasMessages(MSG_VOLUME_LONG_PRESS); mHandler.removeMessages(MSG_VOLUME_LONG_PRESS); boolean ignoreNextKeyUp = mIgnoreNextKeyUp; mIgnoreNextKeyUp = false; mKeyCodeDown = 0; // We've been told to let this one go. if (ignoreNextKeyUp || event.isCanceled()) { mKeyTimeDown = 0; return true; } if ((hasLongPress || noLongPress) && (System.currentTimeMillis() - mKeyTimeDown) < mLongPressTimeout) { mVolumeDirty = true; mKeyTimeDown = 0; if (!firstReveal || (firstReveal && isShowing())) { adjustVolume(adjust); show(); } else { reveal(); } } break; } break; case KeyEvent.KEYCODE_VOLUME_MUTE: switch (event.getAction()) { case KeyEvent.ACTION_UP: boolean mute = isMuted(STREAM_RING); mAudioManager.setStreamMute(STREAM_RING, !mute); mAudioManager.setStreamMute(STREAM_NOTIFICATION, !mute); mVolumeDirty = true; show(); break; } break; } return super.onKey(v, keyCode, event); }