List of usage examples for android.view KeyEvent KEYCODE_DPAD_UP
int KEYCODE_DPAD_UP
To view the source code for android.view KeyEvent KEYCODE_DPAD_UP.
Click Source Link
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
protected void scrollToBegin(Runnable verify) throws Throwable { int key;/*from w w w . j a v a2 s .c o m*/ if (mOrientation == BaseGridView.HORIZONTAL) { if (mGridView.getLayoutDirection() == ViewGroup.LAYOUT_DIRECTION_RTL) { key = KeyEvent.KEYCODE_DPAD_RIGHT; } else { key = KeyEvent.KEYCODE_DPAD_LEFT; } } else { key = KeyEvent.KEYCODE_DPAD_UP; } scroll(key, verify); }
From source file:com.mstar.tv.tvplayer.philips.setting.SettingSliderFragment.java
public void updateView(String data, int dataPositon, boolean isPicShift) { firstSelect = TvSettingMenuActivity.firstSelectPositon; mIsPicShift = isPicShift;/* w w w. j av a2 s. co m*/ if (firstSelect == SettingKarrays.SETTING_PHOTO) { if (mIsPicShift) { //??? switch (dataPositon) { case 0: currentIndex = K_TvPictureManager.getInstance().K_getPCHPos(); Log.v(TAG, "=========hpos===currentIndex=" + currentIndex); break; case 1: currentIndex = K_TvPictureManager.getInstance().K_getPCVPos(); Log.v(TAG, "=========vpos===currentIndex=" + currentIndex); break; case 2: currentIndex = K_TvPictureManager.getInstance().K_getPCClock(); Log.v(TAG, "=========clock===currentIndex=" + currentIndex); break; case 3: currentIndex = K_TvPictureManager.getInstance().K_getPCPhase(); Log.v(TAG, "=========phase===currentIndex=" + currentIndex); break; default: break; } } else { switch (dataPositon) { case 1: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_CONTRAST); break; case 2: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_BRIGHTNESS); break; case 3: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_SATURATION); break; case 4: currentIndex = K_TvPictureManager.getInstance().K_getVideoItem(K_Constants.PICTURE_SHARPNESS); break; default: break; } } } else if (firstSelect == SettingKarrays.SETTING_SOUND) { switch (dataPositon) { case 1: currentIndex = K_TvAudioManager.getInstance().K_getBass(); break; case 2: currentIndex = K_TvAudioManager.getInstance().K_getTreble(); ; break; case 3: currentIndex = K_TvAudioManager.getInstance().K_getBalance(); break; default: break; } } else if (firstSelect == SettingKarrays.SETTING_ECO) { switch (dataPositon) { case 1: currentIndex = K_SettingModel.getInstance().K_getAjustBacklightIndex(mCotext); break; default: break; } } else if (firstSelect == SettingKarrays.SETTING_TV) { switch (dataPositon) { case 4: currentIndex = getSleepModeProgressIndex(); break; default: break; } } if (firstSelect == SettingKarrays.SETTING_TV && dataPositon == 4) { vseekbar_title.setText(data + mCotext.getResources().getString(R.string.minute)); seekBar.setMax(240); cursor_top.setText(240 + ""); cursor_center.setText(120 + ""); cursor_button.setText("0"); } else if (firstSelect == SettingKarrays.SETTING_SOUND && dataPositon == 3) { vseekbar_title.setText(data); seekBar.setMax(100); cursor_top.setText("R50"); cursor_center.setText("0"); cursor_button.setText("L50"); } else { vseekbar_title.setText(data); seekBar.setMax(100); cursor_top.setText(100 + ""); cursor_center.setText(50 + ""); cursor_button.setText("0"); } seekBar.setProgress(currentIndex); if (firstSelect == SettingKarrays.SETTING_SOUND && dataPositon == 3) { if (seekBar.getProgress() < 50) { progressVal.setText("L" + (50 - seekBar.getProgress())); } else if (seekBar.getProgress() == 50) { progressVal.setText("0"); } else { progressVal.setText("R" + (seekBar.getProgress() - 50)); } } else { progressVal.setText(String.valueOf(seekBar.getProgress())); } up_img.setBackgroundResource(R.drawable.slider_arrow_up_highlighted); down_img.setBackgroundResource(R.drawable.slider_arrow_down_highlighted); final int flag = dataPositon; seekBar.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View arg0, int keyCode, KeyEvent keyevent) { if (keyevent.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: if (firstSelect == SettingKarrays.SETTING_SOUND && flag == 3) { seekBar.incrementProgressBy(1); if (seekBar.getProgress() < 50) { progressVal.setText("L" + (50 - seekBar.getProgress())); } else if (seekBar.getProgress() == 50) { progressVal.setText("0"); } else { progressVal.setText("R" + (seekBar.getProgress() - 50)); } } else if (firstSelect == SettingKarrays.SETTING_TV && flag == 4) { setSleepModeProgress(true); } else { seekBar.incrementProgressBy(1); progressVal.setText(String.valueOf(seekBar.getProgress())); } up_img.setBackgroundResource(R.drawable.slider_arrow_up_pressed); down_img.setBackgroundResource(R.drawable.slider_arrow_down_highlighted); updateSeekbarData(flag, seekBar); return true; case KeyEvent.KEYCODE_DPAD_DOWN: if (firstSelect == SettingKarrays.SETTING_SOUND && flag == 3) { seekBar.incrementProgressBy(-1); if (seekBar.getProgress() < 50) { progressVal.setText("L" + (50 - seekBar.getProgress())); } else if (seekBar.getProgress() == 50) { progressVal.setText("0"); } else { progressVal.setText("R" + (seekBar.getProgress() - 50)); } } else if (firstSelect == SettingKarrays.SETTING_TV && flag == 4) { setSleepModeProgress(false); } else { seekBar.incrementProgressBy(-1); progressVal.setText(String.valueOf(seekBar.getProgress())); } up_img.setBackgroundResource(R.drawable.slider_arrow_up_highlighted); down_img.setBackgroundResource(R.drawable.slider_arrow_down_pressed); updateSeekbarData(flag, seekBar); return true; case KeyEvent.KEYCODE_DPAD_LEFT: getActivity().onKeyDown(keyCode, keyevent); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: return true; default: break; } } return false; } private void setSleepModeProgress(boolean up) { int progress = 0; if (up) { switch (seekBar.getProgress()) { case 0: sleepMode = K_Constants.SLEEP_TIME_10MIN; progress = 10; break; case 10: sleepMode = K_Constants.SLEEP_TIME_20MIN; progress = 20; break; case 20: sleepMode = K_Constants.SLEEP_TIME_30MIN; progress = 30; break; case 30: sleepMode = K_Constants.SLEEP_TIME_60MIN; progress = 60; break; case 60: sleepMode = K_Constants.SLEEP_TIME_90MIN; progress = 90; break; case 90: sleepMode = K_Constants.SLEEP_TIME_120MIN; progress = 120; break; case 120: sleepMode = K_Constants.SLEEP_TIME_180MIN; progress = 180; break; case 180: sleepMode = K_Constants.SLEEP_TIME_240MIN; progress = 240; break; case 240: return; default: break; } } else { switch (seekBar.getProgress()) { case 240: sleepMode = K_Constants.SLEEP_TIME_180MIN; progress = 180; break; case 180: sleepMode = K_Constants.SLEEP_TIME_120MIN; progress = 120; break; case 120: sleepMode = K_Constants.SLEEP_TIME_90MIN; progress = 90; break; case 90: sleepMode = K_Constants.SLEEP_TIME_60MIN; progress = 60; break; case 60: sleepMode = K_Constants.SLEEP_TIME_30MIN; progress = 30; break; case 30: sleepMode = K_Constants.SLEEP_TIME_20MIN; progress = 20; break; case 20: sleepMode = K_Constants.SLEEP_TIME_10MIN; progress = 10; break; case 10: sleepMode = K_Constants.SLEEP_TIME_OFF; progress = 0; break; case 0: return; default: break; } } seekBar.setProgress(progress); progressVal.setText(String.valueOf(seekBar.getProgress())); } }); }
From source file:org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin.RemoteKeyboardPlugin.java
private boolean handleSpecialKey(int key, boolean shift, boolean ctrl, boolean alt) { int keyEvent = specialKeyMap.get(key, 0); if (keyEvent == 0) return false; InputConnection inputConn = RemoteKeyboardService.instance.getCurrentInputConnection(); // Log.d("RemoteKeyboardPlugin", "Handling special key " + key + " translated to " + keyEvent + " shift=" + shift + " ctrl=" + ctrl + " alt=" + alt); // special sequences: if (ctrl && (keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT)) { // Ctrl + right -> next word ExtractedText extractedText = inputConn.getExtractedText(new ExtractedTextRequest(), 0); int pos = getCharPos(extractedText, ' ', keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT); if (pos == -1) pos = currentTextLength(extractedText); else/*from ww w .j av a2s . co m*/ pos++; int startPos = pos; int endPos = pos; if (shift) { // Shift -> select word (otherwise jump) Pair<Integer, Integer> sel = currentSelection(extractedText); int cursor = currentCursorPos(extractedText); // Log.d("RemoteKeyboardPlugin", "Selection (to right): " + sel.first + " / " + sel.second + " cursor: " + cursor); startPos = cursor; if (sel.first < cursor || // active selection from left to right -> grow sel.first > sel.second) // active selection from right to left -> shrink startPos = sel.first; } inputConn.setSelection(startPos, endPos); } else if (ctrl && keyEvent == KeyEvent.KEYCODE_DPAD_LEFT) { // Ctrl + left -> previous word ExtractedText extractedText = inputConn.getExtractedText(new ExtractedTextRequest(), 0); int pos = getCharPos(extractedText, ' ', keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT); if (pos == -1) pos = 0; else pos++; int startPos = pos; int endPos = pos; if (shift) { Pair<Integer, Integer> sel = currentSelection(extractedText); int cursor = currentCursorPos(extractedText); // Log.d("RemoteKeyboardPlugin", "Selection (to left): " + sel.first + " / " + sel.second + " cursor: " + cursor); startPos = cursor; if (cursor < sel.first || // active selection from right to left -> grow sel.first < sel.second) // active selection from right to left -> shrink startPos = sel.first; } inputConn.setSelection(startPos, endPos); } else if (shift && (keyEvent == KeyEvent.KEYCODE_DPAD_LEFT || keyEvent == KeyEvent.KEYCODE_DPAD_RIGHT || keyEvent == KeyEvent.KEYCODE_DPAD_UP || keyEvent == KeyEvent.KEYCODE_DPAD_DOWN || keyEvent == KeyEvent.KEYCODE_MOVE_HOME || keyEvent == KeyEvent.KEYCODE_MOVE_END)) { // Shift + up/down/left/right/home/end long now = SystemClock.uptimeMillis(); inputConn.sendKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0)); inputConn.sendKeyEvent( new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyEvent, 0, KeyEvent.META_SHIFT_LEFT_ON)); inputConn.sendKeyEvent( new KeyEvent(now, now, KeyEvent.ACTION_UP, keyEvent, 0, KeyEvent.META_SHIFT_LEFT_ON)); inputConn.sendKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0)); } else if (keyEvent == KeyEvent.KEYCODE_NUMPAD_ENTER || keyEvent == KeyEvent.KEYCODE_ENTER) { // Enter key EditorInfo editorInfo = RemoteKeyboardService.instance.getCurrentInputEditorInfo(); // Log.d("RemoteKeyboardPlugin", "Enter: " + editorInfo.imeOptions); if (editorInfo != null && (((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0) || ctrl)) { // Ctrl+Return overrides IME_FLAG_NO_ENTER_ACTION (FIXME: make configurable?) // check for special DONE/GO/etc actions first: int[] actions = { EditorInfo.IME_ACTION_GO, EditorInfo.IME_ACTION_NEXT, EditorInfo.IME_ACTION_SEND, EditorInfo.IME_ACTION_SEARCH, EditorInfo.IME_ACTION_DONE }; // note: DONE should be last or we might hide the ime instead of "go" for (int i = 0; i < actions.length; i++) { if ((editorInfo.imeOptions & actions[i]) == actions[i]) { // Log.d("RemoteKeyboardPlugin", "Enter-action: " + actions[i]); inputConn.performEditorAction(actions[i]); return true; } } } else { // else: fall back to regular Enter-event: // Log.d("RemoteKeyboardPlugin", "Enter: normal keypress"); inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyEvent)); inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent)); } } else { // default handling: inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyEvent)); inputConn.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEvent)); } return true; }
From source file:com.android2.calculator3.EventListener.java
@Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { int action = keyEvent.getAction(); // Work-around for spurious key event from IME, bug #1639445 if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) { return true; // eat it }// ww w . j ava2s . com if (keyEvent.getUnicodeChar() == '=') { if (action == KeyEvent.ACTION_UP) { mHandler.onEnter(); } return true; } if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP && keyCode != KeyEvent.KEYCODE_DPAD_DOWN && keyCode != KeyEvent.KEYCODE_ENTER) { if (keyEvent.isPrintingKey() && action == KeyEvent.ACTION_UP) { // Tell the handler that text was updated. mHandler.onTextChanged(); } return false; } /* * We should act on KeyEvent.ACTION_DOWN, but strangely sometimes the DOWN event isn't received, only the UP. So the workaround is to act on UP... http://b/issue?id=1022478 */ if (action == KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: mHandler.onEnter(); break; case KeyEvent.KEYCODE_DPAD_UP: mHandler.onUp(); break; case KeyEvent.KEYCODE_DPAD_DOWN: mHandler.onDown(); break; } } return true; }
From source file:com.android.calculator2.EventListener.java
@Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { int action = keyEvent.getAction(); // Work-around for spurious key event from IME, bug #1639445 if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) { return true; // eat it }// ww w. j a v a2 s. c o m if (keyEvent.getUnicodeChar() == '=') { if (action == KeyEvent.ACTION_UP) { mHandler.onEnter(); } return true; } if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP && keyCode != KeyEvent.KEYCODE_DPAD_DOWN && keyCode != KeyEvent.KEYCODE_ENTER) { if (keyEvent.isPrintingKey() && action == KeyEvent.ACTION_UP) { // Tell the handler that text was updated. mHandler.onTextChanged(); } return false; } /* * We should act on KeyEvent.ACTION_DOWN, but strangely sometimes the * DOWN event isn't received, only the UP. So the workaround is to act * on UP... http://b/issue?id=1022478 */ if (action == KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: mHandler.onEnter(); break; case KeyEvent.KEYCODE_DPAD_UP: mHandler.onUp(); break; case KeyEvent.KEYCODE_DPAD_DOWN: mHandler.onDown(); break; } } return true; }
From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java
private static boolean isReadable(int keyCode, KeyEvent event) { if (KeyEvent.isModifierKey(keyCode) || event.isSystem()) { return false; }/*from ww w . ja v a2 s .c om*/ switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_ENTER: return false; } return true; }
From source file:org.mozilla.gecko.AwesomeBar.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // This method is called only if the key event was not handled // by any of the views, which usually means the edit box lost focus if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return super.onKeyDown(keyCode, event); } else {//from w w w. jav a 2 s . co m int selStart = -1; int selEnd = -1; if (mText.hasSelection()) { selStart = mText.getSelectionStart(); selEnd = mText.getSelectionEnd(); } // Return focus to the edit box, and dispatch the event to it mText.requestFocusFromTouch(); if (selStart >= 0) { // Restore the selection, which gets lost due to the focus switch mText.setSelection(selStart, selEnd); } mText.dispatchKeyEvent(event); return true; } }
From source file:uk.org.downiesoft.slideshow.SlidesFragment.java
/** * Called by parent activity to handle cursor key events. * @param keyCode The keycode associated with the key pressed. * @return true if the keycode was consumed. *///ww w .j a v a 2 s .co m public boolean onKeyUp(int keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: prevImage(1); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_SPACE: nextImage(-1); return true; case KeyEvent.KEYCODE_DPAD_UP: mUiHider.hideUi(); return true; case KeyEvent.KEYCODE_DPAD_DOWN: mUiHider.showUi(false); return true; } return false; }
From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java
private boolean onInterceptInputEvent(InputEvent event) { final boolean controlsHidden = !mControlVisible; if (DEBUG)//www . j a v a 2 s .com Log.v(TAG, "onInterceptInputEvent hidden " + controlsHidden + " " + event); boolean consumeEvent = false; int keyCode = KeyEvent.KEYCODE_UNKNOWN; int keyAction = 0; if (event instanceof KeyEvent) { keyCode = ((KeyEvent) event).getKeyCode(); keyAction = ((KeyEvent) event).getAction(); if (mInputEventHandler != null) { consumeEvent = mInputEventHandler.onKey(getView(), keyCode, (KeyEvent) event); } } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // Event may be consumed; regardless, if controls are hidden then these keys will // bring up the controls. if (controlsHidden) { consumeEvent = true; } if (keyAction == KeyEvent.ACTION_DOWN) { tickle(); } break; case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_ESCAPE: if (mInSeek) { // when in seek, the SeekUi will handle the BACK. return false; } // If controls are not hidden, back will be consumed to fade // them out (even if the key was consumed by the handler). if (!controlsHidden) { consumeEvent = true; if (((KeyEvent) event).getAction() == KeyEvent.ACTION_UP) { hideControlsOverlay(true); } } break; default: if (consumeEvent) { if (keyAction == KeyEvent.ACTION_DOWN) { tickle(); } } } return consumeEvent; }