List of usage examples for android.view KeyEvent KEYCODE_DPAD_RIGHT
int KEYCODE_DPAD_RIGHT
To view the source code for android.view KeyEvent KEYCODE_DPAD_RIGHT.
Click Source Link
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
public void testNoInitialFocusable() throws Throwable { mInstrumentation = getInstrumentation(); Intent intent = new Intent(mInstrumentation.getContext(), GridActivity.class); intent.putExtra(GridActivity.EXTRA_LAYOUT_RESOURCE_ID, R.layout.horizontal_linear); final int numItems = 100; intent.putExtra(GridActivity.EXTRA_NUM_ITEMS, numItems); intent.putExtra(GridActivity.EXTRA_STAGGERED, false); mOrientation = BaseGridView.HORIZONTAL; mNumRows = 1;/* w w w.j a va2 s . co m*/ boolean[] focusable = new boolean[numItems]; final int firstFocusableIndex = 10; for (int i = 0; i < firstFocusableIndex; i++) { focusable[i] = false; } for (int i = firstFocusableIndex; i < focusable.length; i++) { focusable[i] = true; } intent.putExtra(GridActivity.EXTRA_ITEMS_FOCUSABLE, focusable); initActivity(intent); assertTrue(mGridView.isFocused()); if (mGridView.getLayoutDirection() == ViewGroup.LAYOUT_DIRECTION_RTL) { sendKeys(KeyEvent.KEYCODE_DPAD_LEFT); } else { sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT); } waitForScrollIdle(mVerifyLayout); assertEquals(firstFocusableIndex, mGridView.getSelectedPosition()); assertTrue(mGridView.getLayoutManager().findViewByPosition(firstFocusableIndex).hasFocus()); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { Logger.d(TAG, "onKeyUp keycode=%d", keyCode); switch (keyCode) { // Issue 248//from w ww .ja va2s . c o m case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: if (!isInputViewShown()) { return super.onKeyUp(keyCode, event); } if (mAskPrefs.useVolumeKeyForLeftRight()) { // no need of vol up/down sound return true; } case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: if (getInputView() != null && getInputView().isShown() && getInputView().isShifted()) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event); return true; } break; case KeyEvent.KEYCODE_ALT_LEFT: case KeyEvent.KEYCODE_ALT_RIGHT: case KeyEvent.KEYCODE_SHIFT_LEFT: case KeyEvent.KEYCODE_SHIFT_RIGHT: case KeyEvent.KEYCODE_SYM: mMetaState = MyMetaKeyKeyListener.handleKeyUp(mMetaState, keyCode, event); Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyUp")); setInputConnectionMetaStateAsCurrentMetaKeyKeyListenerState(); break; } return super.onKeyUp(keyCode, event); }
From source file:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: scroll((int) (-1 * mCoverWidth * mSpacing) - mCenterItemOffset); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: scroll((int) (mCoverWidth * mSpacing) - mCenterItemOffset); return true; default://from w w w . jav a2 s . com break; } return super.onKeyDown(keyCode, event); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) { if (mKeyboardSwitcher.getInputView().handleBack()) { return true; } else if (mTutorial != null) { mTutorial.close();//from w w w . ja v a 2 s .c o m mTutorial = null; } } break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // If tutorial is visible, don't allow dpad to work if (mTutorial != null) { return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return true; } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java
@Override public boolean onKeyDown(int keyCode, final KeyEvent event) { if (mDebug)/*from w ww. jav a2s . co m*/ Log.d("DosBoxTurbo", "onKeyDown keyCode=" + keyCode + " mEnableDpad=" + mEnableDpad); if (mEnableDpad) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) { y[0] -= mDpadRate; DosBoxControl.nativeMouse((int) x[0], (int) y[0], (int) x[0], (int) y[0] + mDpadRate, 2, -1); return true; } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(0, -1024, 2, -1); return true; } break; case KeyEvent.KEYCODE_DPAD_DOWN: if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) { y[0] += mDpadRate; DosBoxControl.nativeMouse((int) x[0], (int) y[0], (int) x[0], (int) y[0] - mDpadRate, 2, -1); return true; } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(0, 1024, 2, -1); return true; } break; case KeyEvent.KEYCODE_DPAD_LEFT: if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) { x[0] -= mDpadRate; DosBoxControl.nativeMouse((int) x[0], (int) y[0], (int) x[0] + mDpadRate, (int) y[0], 2, -1); return true; } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(-1024, 0, 2, -1); return true; } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) { x[0] += mDpadRate; DosBoxControl.nativeMouse((int) x[0], (int) y[0], (int) x[0] - mDpadRate, (int) y[0], 2, -1); return true; } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(1024, 0, 2, -1); return true; } break; case KeyEvent.KEYCODE_DPAD_CENTER: // button if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) { DosBoxControl.nativeMouse(0, 0, 0, 0, 0, BTN_A); return true; } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(0, 0, 0, BTN_A); return true; } break; } } return handleKey(keyCode, event); }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); // Enable shift key and DPAD to do selections if (inputView != null && inputView.isShown() && inputView.getShiftState() == Keyboard.SHIFT_ON) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event);// w ww. java2 s .c om return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolUpAction); } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolDownAction); } break; } return super.onKeyUp(keyCode, event); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // If tutorial is visible, don't allow dpad to work if (mTutorial != null) { return true; }/*from www .jav a 2 s . co m*/ TKKeyboardView inputView = mKeyboardSwitcher.getInputView(); // Enable shift key and DPAD to do selections if (inputView != null && inputView.isShown() && inputView.getShiftState() == Keyboard.SHIFT_ON) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event); return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolUpAction); } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolDownAction); } break; } return super.onKeyUp(keyCode, event); }
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
public void testRtlFocusOutStartDisabled() throws Throwable { final int numItems = 200; mInstrumentation = getInstrumentation(); Intent intent = new Intent(mInstrumentation.getContext(), GridActivity.class); intent.putExtra(GridActivity.EXTRA_LAYOUT_RESOURCE_ID, R.layout.vertical_grid_rtl); intent.putExtra(GridActivity.EXTRA_NUM_ITEMS, numItems); intent.putExtra(GridActivity.EXTRA_STAGGERED, false); mOrientation = BaseGridView.VERTICAL; mNumRows = 1;/* w w w. j a v a 2 s .co m*/ initActivity(intent); runTestOnUiThread(new Runnable() { @Override public void run() { mGridView.requestFocus(); mGridView.setSelectedPositionSmooth(0); } }); waitForScrollIdle(mVerifyLayout); sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT); waitForScrollIdle(mVerifyLayout); assertTrue(mGridView.hasFocus()); }
From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java
@Override public boolean onKeyUp(int keyCode, final KeyEvent event) { if (mDebug)//from w ww. j a v a2 s .c o m Log.d("DosBoxTurbo", "onKeyUp keyCode=" + keyCode); if (mEnableDpad) { switch (keyCode) { // DPAD / TRACKBALL case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(0, 0, 2, -1); } return true; case KeyEvent.KEYCODE_DPAD_CENTER: // button if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) { DosBoxControl.nativeMouse(0, 0, 0, 0, 1, BTN_A); } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) { DosBoxControl.nativeJoystick(0, 0, 1, BTN_A); } return true; } } return handleKey(keyCode, event); }
From source file:com.yek.keyboard.anysoftkeyboard.AnySoftKeyboard.java
private void onFunctionKey(final int primaryCode, final Keyboard.Key key, final int multiTapIndex, final int[] nearByKeyCodes, final boolean fromUI) { if (BuildConfig.DEBUG) Logger.d(TAG, "onFunctionKey %d", primaryCode); final InputConnection ic = getCurrentInputConnection(); switch (primaryCode) { case KeyCodes.DELETE: if (ic == null)// if we don't want to do anything, lets check null first. break; // we do backword if the shift is pressed while pressing // backspace (like in a PC) if (mAskPrefs.useBackword() && mShiftKeyState.isPressed() && !mShiftKeyState.isLocked()) { handleBackWord(ic);//from w w w .j a va2 s . c om } else { handleDeleteLastCharacter(false); } break; case KeyCodes.SHIFT: if (fromUI) { handleShift(); } else { //not from UI (user not actually pressed that button) onPress(primaryCode); onRelease(primaryCode); } break; case KeyCodes.SHIFT_LOCK: mShiftKeyState.toggleLocked(); handleShift(); break; case KeyCodes.DELETE_WORD: if (ic == null)// if we don't want to do anything, lets check // null first. break; handleBackWord(ic); break; case KeyCodes.CLEAR_INPUT: if (ic != null) { ic.beginBatchEdit(); abortCorrectionAndResetPredictionState(false); ic.deleteSurroundingText(Integer.MAX_VALUE, Integer.MAX_VALUE); ic.endBatchEdit(); } break; case KeyCodes.CTRL: if (fromUI) { handleControl(); } else { //not from UI (user not actually pressed that button) onPress(primaryCode); onRelease(primaryCode); } break; case KeyCodes.CTRL_LOCK: mControlKeyState.toggleLocked(); handleControl(); break; case KeyCodes.ARROW_LEFT: case KeyCodes.ARROW_RIGHT: final int keyEventKeyCode = primaryCode == KeyCodes.ARROW_LEFT ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT; if (!handleSelectionExpending(keyEventKeyCode, ic, mGlobalSelectionStartPosition, mGlobalCursorPosition)) { sendDownUpKeyEvents(keyEventKeyCode); } break; case KeyCodes.ARROW_UP: sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_UP); break; case KeyCodes.ARROW_DOWN: sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_DOWN); break; case KeyCodes.MOVE_HOME: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { sendDownUpKeyEvents(0x0000007a/*API 11:KeyEvent.KEYCODE_MOVE_HOME*/); } else { if (ic != null) { CharSequence textBefore = ic.getTextBeforeCursor(1024, 0); if (!TextUtils.isEmpty(textBefore)) { int newPosition = textBefore.length() - 1; while (newPosition > 0) { char chatAt = textBefore.charAt(newPosition - 1); if (chatAt == '\n' || chatAt == '\r') { break; } newPosition--; } if (newPosition < 0) newPosition = 0; ic.setSelection(newPosition, newPosition); } } } break; case KeyCodes.MOVE_END: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //API 11: KeyEvent.KEYCODE_MOVE_END sendDownUpKeyEvents(0x0000007b); } else { if (ic != null) { CharSequence textAfter = ic.getTextAfterCursor(1024, 0); if (!TextUtils.isEmpty(textAfter)) { int newPosition = 1; while (newPosition < textAfter.length()) { char chatAt = textAfter.charAt(newPosition); if (chatAt == '\n' || chatAt == '\r') { break; } newPosition++; } if (newPosition > textAfter.length()) newPosition = textAfter.length(); try { CharSequence textBefore = ic.getTextBeforeCursor(Integer.MAX_VALUE, 0); if (!TextUtils.isEmpty(textBefore)) { newPosition = newPosition + textBefore.length(); } ic.setSelection(newPosition, newPosition); } catch (Throwable e/*I'm using Integer.MAX_VALUE, it's scary.*/) { Logger.w(TAG, "Failed to getTextBeforeCursor.", e); } } } } break; case KeyCodes.VOICE_INPUT: if (mVoiceRecognitionTrigger.isInstalled()) { mVoiceRecognitionTrigger .startVoiceRecognition(getCurrentAlphabetKeyboard().getDefaultDictionaryLocale()); } else { Intent voiceInputNotInstalledIntent = new Intent(getApplicationContext(), VoiceInputNotInstalledActivity.class); voiceInputNotInstalledIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(voiceInputNotInstalledIntent); } break; case KeyCodes.CANCEL: handleClose(); break; case KeyCodes.SETTINGS: showOptionsMenu(); break; case KeyCodes.SPLIT_LAYOUT: case KeyCodes.MERGE_LAYOUT: case KeyCodes.COMPACT_LAYOUT_TO_RIGHT: case KeyCodes.COMPACT_LAYOUT_TO_LEFT: if (getInputView() != null) { mKeyboardInCondensedMode = CondenseType.fromKeyCode(primaryCode); setKeyboardForView(getCurrentKeyboard()); } break; case KeyCodes.DOMAIN: onText(key, mAskPrefs.getDomainText()); break; case KeyCodes.QUICK_TEXT: onQuickTextRequested(key); break; case KeyCodes.QUICK_TEXT_POPUP: onQuickTextKeyboardRequested(key); break; case KeyCodes.MODE_SYMOBLS: nextKeyboard(getCurrentInputEditorInfo(), KeyboardSwitcher.NextKeyboardType.Symbols); break; case KeyCodes.MODE_ALPHABET: if (getKeyboardSwitcher().shouldPopupForLanguageSwitch()) { showLanguageSelectionDialog(); } else { nextKeyboard(getCurrentInputEditorInfo(), KeyboardSwitcher.NextKeyboardType.Alphabet); } break; case KeyCodes.UTILITY_KEYBOARD: getInputView().openUtilityKeyboard(); break; case KeyCodes.MODE_ALPHABET_POPUP: showLanguageSelectionDialog(); break; case KeyCodes.ALT: nextAlterKeyboard(getCurrentInputEditorInfo()); break; case KeyCodes.KEYBOARD_CYCLE: nextKeyboard(getCurrentInputEditorInfo(), KeyboardSwitcher.NextKeyboardType.Any); break; case KeyCodes.KEYBOARD_REVERSE_CYCLE: nextKeyboard(getCurrentInputEditorInfo(), KeyboardSwitcher.NextKeyboardType.PreviousAny); break; case KeyCodes.KEYBOARD_CYCLE_INSIDE_MODE: nextKeyboard(getCurrentInputEditorInfo(), KeyboardSwitcher.NextKeyboardType.AnyInsideMode); break; case KeyCodes.KEYBOARD_MODE_CHANGE: nextKeyboard(getCurrentInputEditorInfo(), KeyboardSwitcher.NextKeyboardType.OtherMode); break; case KeyCodes.CLIPBOARD_COPY: case KeyCodes.CLIPBOARD_PASTE: case KeyCodes.CLIPBOARD_CUT: case KeyCodes.CLIPBOARD_SELECT_ALL: case KeyCodes.CLIPBOARD_PASTE_POPUP: case KeyCodes.CLIPBOARD_SELECT: handleClipboardOperation(key, primaryCode, ic); //not allowing undo on-text in clipboard paste operations. if (primaryCode == KeyCodes.CLIPBOARD_PASTE) mCommittedWord = ""; break; default: if (BuildConfig.DEBUG) { //this should not happen! We should handle ALL function keys. throw new RuntimeException("UNHANDLED FUNCTION KEY! primary code " + primaryCode); } else { Logger.w(TAG, "UNHANDLED FUNCTION KEY! primary code %d. Ignoring.", primaryCode); } } }