List of usage examples for android.view KeyEvent KEYCODE_DPAD_DOWN
int KEYCODE_DPAD_DOWN
To view the source code for android.view KeyEvent KEYCODE_DPAD_DOWN.
Click Source Link
From source file:com.tct.mail.ui.ConversationListFragment.java
@Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { SwipeableListView list = (SwipeableListView) view; // Don't need to handle ENTER because it's auto-handled as a "click". if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { if (keyEvent.getAction() == KeyEvent.ACTION_UP) { if (mKeyInitiatedFromList) { onListItemSelected(list.getSelectedView(), list.getSelectedItemPosition()); }/*from w ww . j ava 2 s. co m*/ mKeyInitiatedFromList = false; } else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { mKeyInitiatedFromList = true; } return true; } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { final int position = list.getSelectedItemPosition(); final Object item = getAnimatedAdapter().getItem(position); if (item != null && item instanceof ConversationCursor) { final Conversation conv = ((ConversationCursor) item).getConversation(); mCallbacks.onConversationFocused(conv); } } } return false; }
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 w w . j a v a 2s . 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:android.support.v17.leanback.widget.GridWidgetTest.java
public void testFocusOutOfEmptyListView() 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;//from w w w. j ava2s.co m initActivity(intent); final View horizontalGridView = new HorizontalGridViewEx(mGridView.getContext()); runTestOnUiThread(new Runnable() { @Override public void run() { horizontalGridView.setFocusable(true); horizontalGridView.setFocusableInTouchMode(true); horizontalGridView.setLayoutParams(new ViewGroup.LayoutParams(100, 100)); ((ViewGroup) mGridView.getParent()).addView(horizontalGridView, 0); horizontalGridView.requestFocus(); } }); assertTrue(horizontalGridView.isFocused()); sendKeys(KeyEvent.KEYCODE_DPAD_DOWN); assertTrue(mGridView.hasFocus()); }
From source file:com.android.mail.ui.ConversationViewFragment.java
@Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { mOriginalKeyedView = view;//from w w w .j ava2 s. c om } if (mOriginalKeyedView != null) { final int id = mOriginalKeyedView.getId(); final boolean isRtl = ViewUtils.isViewRtl(mOriginalKeyedView); final boolean isActionUp = keyEvent.getAction() == KeyEvent.ACTION_UP; final boolean isStart = KeyboardUtils.isKeycodeDirectionStart(keyCode, isRtl); final boolean isEnd = KeyboardUtils.isKeycodeDirectionEnd(keyCode, isRtl); final boolean isUp = keyCode == KeyEvent.KEYCODE_DPAD_UP; final boolean isDown = keyCode == KeyEvent.KEYCODE_DPAD_DOWN; // First we run the event by the controller // We manually check if the view+direction combination should shift focus away from the // conversation view to the thread list in two-pane landscape mode. final boolean isTwoPaneLand = mNavigationController.isTwoPaneLandscape(); final boolean navigateAway = shouldNavigateAway(id, isStart, isTwoPaneLand); if (mNavigationController.onInterceptKeyFromCV(keyCode, keyEvent, navigateAway)) { return true; } // If controller didn't handle the event, check directional interception. if ((isStart || isEnd) && shouldInterceptLeftRightEvents(id, isStart, isEnd, isTwoPaneLand)) { return true; } else if (isUp || isDown) { // We don't do anything on up/down for overlay if (id == R.id.conversation_topmost_overlay) { return true; } // We manually handle up/down navigation through the overlay items because the // system's default isn't optimal for two-pane landscape since it's not a real list. final View next = mConversationContainer.getNextOverlayView(mOriginalKeyedView, isDown); if (next != null) { focusAndScrollToView(next); } else if (!isActionUp) { // Scroll in the direction of the arrow if next view isn't found. final int currentY = mWebView.getScrollY(); if (isUp && currentY > 0) { mWebView.scrollBy(0, -Math.min(currentY, DEFAULT_VERTICAL_SCROLL_DISTANCE_PX)); } else if (isDown) { final int webviewEnd = (int) (mWebView.getContentHeight() * mWebView.getScale()); final int currentEnd = currentY + mWebView.getHeight(); if (currentEnd < webviewEnd) { mWebView.scrollBy(0, Math.min(webviewEnd - currentEnd, DEFAULT_VERTICAL_SCROLL_DISTANCE_PX)); } } } return true; } // Finally we handle the special keys if (keyCode == KeyEvent.KEYCODE_BACK && id != R.id.conversation_topmost_overlay) { if (isActionUp) { mTopmostOverlay.requestFocus(); } return true; } else if (keyCode == KeyEvent.KEYCODE_ENTER && id == R.id.conversation_topmost_overlay) { if (isActionUp) { mWebView.scrollTo(0, 0); mConversationContainer.focusFirstMessageHeader(); } return true; } } return false; }
From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java
@Override public boolean onKeyDown(int keyCode, final KeyEvent event) { if (mDebug)//from w ww.j a v a 2s.c o 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:android.support.v17.leanback.widget.GridWidgetTest.java
public void testNonFocusableVertical() throws Throwable { final int numItems = 200; final int startPos = 44; final int skips = 20; final int numColumns = 3; final int endPos = startPos + numColumns * (skips + 1); mInstrumentation = getInstrumentation(); Intent intent = new Intent(mInstrumentation.getContext(), GridActivity.class); intent.putExtra(GridActivity.EXTRA_LAYOUT_RESOURCE_ID, R.layout.vertical_grid); intent.putExtra(GridActivity.EXTRA_NUM_ITEMS, numItems); intent.putExtra(GridActivity.EXTRA_STAGGERED, false); mOrientation = BaseGridView.VERTICAL; mNumRows = numColumns;/*from ww w .jav a 2s .co m*/ boolean[] focusable = new boolean[numItems]; for (int i = 0; i < focusable.length; i++) { focusable[i] = true; } for (int i = startPos + mNumRows, j = 0; j < skips; i += mNumRows, j++) { focusable[i] = false; } intent.putExtra(GridActivity.EXTRA_ITEMS_FOCUSABLE, focusable); initActivity(intent); mGridView.setSelectedPositionSmooth(startPos); waitForScrollIdle(mVerifyLayout); sendKeys(KeyEvent.KEYCODE_DPAD_DOWN); waitForScrollIdle(mVerifyLayout); assertEquals(endPos, mGridView.getSelectedPosition()); sendKeys(KeyEvent.KEYCODE_DPAD_UP); waitForScrollIdle(mVerifyLayout); assertEquals(startPos, mGridView.getSelectedPosition()); }
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 . j a 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: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);//from w w w.ja v a 2 s . co m 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 w ww .j ava 2s.c om*/ 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:com.fishstix.dosboxfree.DBGLSurfaceView.java
@Override public boolean onKeyUp(int keyCode, final KeyEvent event) { if (mDebug)/*from w w w.j av a 2 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); }