List of usage examples for android.view KeyEvent KEYCODE_DPAD_CENTER
int KEYCODE_DPAD_CENTER
To view the source code for android.view KeyEvent KEYCODE_DPAD_CENTER.
Click Source Link
From source file:com.android.app.MediaPlaybackActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { int direction = -1; int repcnt = event.getRepeatCount(); if ((seekmethod == 0) ? seekMethod1(keyCode) : seekMethod2(keyCode)) return true; switch (keyCode) { /*/*ww w . ja v a2 s . co m*/ // image scale case KeyEvent.KEYCODE_Q: av.adjustParams(-0.05, 0.0, 0.0, 0.0, 0.0,-1.0); break; case KeyEvent.KEYCODE_E: av.adjustParams( 0.05, 0.0, 0.0, 0.0, 0.0, 1.0); break; // image translate case KeyEvent.KEYCODE_W: av.adjustParams( 0.0, 0.0,-1.0, 0.0, 0.0, 0.0); break; case KeyEvent.KEYCODE_X: av.adjustParams( 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); break; case KeyEvent.KEYCODE_A: av.adjustParams( 0.0,-1.0, 0.0, 0.0, 0.0, 0.0); break; case KeyEvent.KEYCODE_D: av.adjustParams( 0.0, 1.0, 0.0, 0.0, 0.0, 0.0); break; // camera rotation case KeyEvent.KEYCODE_R: av.adjustParams( 0.0, 0.0, 0.0, 0.0, 0.0,-1.0); break; case KeyEvent.KEYCODE_U: av.adjustParams( 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); break; // camera translate case KeyEvent.KEYCODE_Y: av.adjustParams( 0.0, 0.0, 0.0, 0.0,-1.0, 0.0); break; case KeyEvent.KEYCODE_N: av.adjustParams( 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); break; case KeyEvent.KEYCODE_G: av.adjustParams( 0.0, 0.0, 0.0,-1.0, 0.0, 0.0); break; case KeyEvent.KEYCODE_J: av.adjustParams( 0.0, 0.0, 0.0, 1.0, 0.0, 0.0); break; */ case KeyEvent.KEYCODE_SLASH: seekmethod = 1 - seekmethod; return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (!useDpadMusicControl()) { break; } if (!mPrevButton.hasFocus()) { mPrevButton.requestFocus(); } scanBackward(repcnt, event.getEventTime() - event.getDownTime()); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!useDpadMusicControl()) { break; } if (!mNextButton.hasFocus()) { mNextButton.requestFocus(); } scanForward(repcnt, event.getEventTime() - event.getDownTime()); return true; case KeyEvent.KEYCODE_S: toggleShuffle(); return true; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: doPauseResume(); return true; } return super.onKeyDown(keyCode, event); }
From source file:android.widget.Gallery.java
/** * Handles left, right, and clicking// w w w . j a va 2 s . c om * @see android.view.View#onKeyDown */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (movePrevious()) { playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT); return true; } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (moveNext()) { playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT); return true; } break; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: mReceivedInvokeKeyDown = true; // fallthrough to default handling } return super.onKeyDown(keyCode, event); }
From source file:android.widget.Gallery.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: { if (mReceivedInvokeKeyDown) { if (mItemCount > 0) { dispatchPress(mSelectedChild); postDelayed(new Runnable() { @Override/*from w w w . j a v a 2s.co m*/ public void run() { dispatchUnpress(); } }, ViewConfiguration.getPressedStateDuration()); int selectedIndex = mSelectedPosition - mFirstPosition; performItemClick(getChildAt(selectedIndex), mSelectedPosition, mAdapter.getItemId(mSelectedPosition)); } } // Clear the flag mReceivedInvokeKeyDown = false; return true; } } return super.onKeyUp(keyCode, event); }
From source file:org.appcelerator.titanium.view.TiUIView.java
/** * Registers a callback to be invoked when a hardware key is pressed in this view. * * @param v The view to have the key listener to attach to. */// w ww . j a v a 2 s . c o m protected void registerForKeyPressEvents(final View v) { if (v == null) { return; } v.setOnKeyListener(new OnKeyListener() { public boolean onKey(View view, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP) { KrollDict data = new KrollDict(); data.put(TiC.EVENT_PROPERTY_KEYCODE, keyCode); proxy.fireEvent(TiC.EVENT_KEY_PRESSED, data); switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: if (proxy.hasListeners(TiC.EVENT_CLICK)) { proxy.fireEvent(TiC.EVENT_CLICK, null); return true; } } } return false; } }); }
From source file:og.android.tether.MainActivity.java
public Dialog openLaunchedDialog(final boolean noroot) { final long value = noroot ? 1 : 0; EasyTracker.getTracker().trackEvent("ui_action", "create_dialog", "meshclient", value); Dialog dialog = new AlertDialog.Builder(this) .setMessage(noroot ? R.string.dialog_noroot_text : R.string.dialog_launched_text) .setTitle(getString(R.string.dialog_launched_title)).setIcon(R.drawable.og_app_icon) .setCancelable(false).setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) MainActivity.this.finish(); if (keyCode < KeyEvent.KEYCODE_DPAD_UP || keyCode > KeyEvent.KEYCODE_DPAD_CENTER) return true; else return false; }/*from ww w.ja v a 2s .c o m*/ }).setPositiveButton(getString(R.string.main_activity_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { EasyTracker.getTracker().trackEvent("ui_action", "button_press", "meshclient_positive", value); startGooglePlayMeshclient(noroot ? "fail_noroot" : "fail"); } }) .setNegativeButton(getString(R.string.main_activity_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { EasyTracker.getTracker().trackEvent("ui_action", "button_press", "meshclient_negative", value); } }).create(); dialog.show(); return dialog; }
From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java
@Override public boolean onKeyDown(int keyCode, final KeyEvent event) { if (mDebug)//from w w w. j a v a 2 s. 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:com.fishstix.dosboxfree.DBGLSurfaceView.java
@Override public boolean onKeyUp(int keyCode, final KeyEvent event) { if (mDebug)//w w w . j av a2s. co 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.android.ex.chips.RecipientEditTextView.java
/** * If there is a selected chip, delegate the key events to the selected chip. *///from w ww. j ava2 s . c o m @Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (mSelectedChip != null && keyCode == KeyEvent.KEYCODE_DEL) { /*if(mAlternatesPopup!=null&&mAlternatesPopup.isShowing()) mAlternatesPopup.dismiss();*/ removeChip(mSelectedChip, true); } switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: if (event.hasNoModifiers()) { if (commitDefault()) return true; if (mSelectedChip != null) { clearSelectedChip(); return true; } else if (focusNext()) return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:android.support.v7.widget.AbstractXpListPopupWindow.java
/** * Filter key down events. By forwarding key down events to this function, * views using non-modal ListPopupWindow can have it handle key selection of items. * * @param keyCode keyCode param passed to the host view's onKeyDown * @param event event param passed to the host view's onKeyDown * @return true if the event was handled, false if it was ignored. * @see #setModal(boolean)//ww w . j a v a 2 s .c o m */ public boolean onKeyDown(int keyCode, KeyEvent event) { // when the drop down is shown, we drive it directly if (isShowing()) { // the key events are forwarded to the list in the drop down view // note that ListView handles space but we don't want that to happen // also if selection is not currently in the drop down, then don't // let center or enter presses go there since that would cause it // to select one of its items if (keyCode != KeyEvent.KEYCODE_SPACE && (mDropDownList.getSelectedItemPosition() >= 0 || !isConfirmKey(keyCode))) { int curIndex = mDropDownList.getSelectedItemPosition(); boolean consumed; final boolean below = !mPopup.isAboveAnchor(); final ListAdapter adapter = mAdapter; boolean allEnabled; int firstItem = Integer.MAX_VALUE; int lastItem = Integer.MIN_VALUE; if (adapter != null) { allEnabled = adapter.areAllItemsEnabled(); firstItem = allEnabled ? 0 : mDropDownList.lookForSelectablePosition(0, true); lastItem = allEnabled ? adapter.getCount() - 1 : mDropDownList.lookForSelectablePosition(adapter.getCount() - 1, false); } if ((below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= firstItem) || (!below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && curIndex >= lastItem)) { // When the selection is at the top, we block the key // event to prevent focus from moving. clearListSelection(); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); show(); return true; } else { // WARNING: Please read the comment where mListSelectionHidden // is declared mDropDownList.setListSelectionHidden(false); } consumed = mDropDownList.onKeyDown(keyCode, event); if (DEBUG) Log.v(TAG, "Key down: code=" + keyCode + " list consumed=" + consumed); if (consumed) { // If it handled the key event, then the user is // navigating in the list, so we should put it in front. mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); // Here's a little trick we need to do to make sure that // the list view is actually showing its focus indicator, // by ensuring it has focus and getting its window out // of touch mode. mDropDownList.requestFocusFromTouch(); show(); switch (keyCode) { // avoid passing the focus from the text view to the // next component case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: return true; } } else { if (below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { // when the selection is at the bottom, we block the // event to avoid going to the next focusable widget if (curIndex == lastItem) { return true; } } else if (!below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex == firstItem) { return true; } } } } return false; }
From source file:com.appunite.list.GridView.java
private boolean commonKey(int keyCode, int count, KeyEvent event) { if (mAdapter == null) { return false; }/*from w w w . j a va2 s. c om*/ if (mDataChanged) { layoutChildren(); } boolean handled = false; int action = event.getAction(); if (action != KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_LEFT); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_RIGHT); } break; case KeyEvent.KEYCODE_DPAD_UP: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded(); if (!handled && event.getRepeatCount() == 0 && getChildCount() > 0) { keyPressed(); handled = true; } } break; case KeyEvent.KEYCODE_SPACE: if (mPopup == null || !mPopup.isShowing()) { if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP); } } break; case KeyEvent.KEYCODE_PAGE_UP: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_PAGE_DOWN: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_MOVE_HOME: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP); } break; case KeyEvent.KEYCODE_MOVE_END: if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN); } break; case KeyEvent.KEYCODE_TAB: // XXX Sometimes it is useful to be able to TAB through the items in // a GridView sequentially. Unfortunately this can create an // asymmetry in TAB navigation order unless the list selection // always reverts to the top or bottom when receiving TAB focus from // another widget. Leaving this behavior disabled for now but // perhaps it should be configurable (and more comprehensive). if (false) { if (KeyEventCompat.hasNoModifiers(event)) { handled = resurrectSelectionIfNeeded() || sequenceScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = resurrectSelectionIfNeeded() || sequenceScroll(FOCUS_BACKWARD); } } break; } } if (handled) { return true; } if (sendToTextFilter(keyCode, count, event)) { return true; } 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; } }