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.oakesville.mythling.MediaPagerActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN) { if ((getCurrentFocus().getParent() instanceof View && ((View) getCurrentFocus().getParent()).getId() == R.id.button_bar) || getCurrentFocus().getId() == R.id.title_text) { findViewById(R.id.pager_position).requestFocus(); return true; }/*from www. j a va 2s. co m*/ } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) { if (getCurrentFocus().getId() == R.id.pager_position) { if (pager.getCurrentItem() < getListables().size() - 1) { pager.setCurrentItem(pager.getCurrentItem() + 1); positionBar.setProgress(pager.getCurrentItem()); return true; } } } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) { if (getCurrentFocus().getId() == R.id.pager_position) { if (pager.getCurrentItem() > 0) { pager.setCurrentItem(pager.getCurrentItem() - 1); positionBar.setProgress(pager.getCurrentItem()); return true; } } } else if (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { pager.setCurrentItem(getListables().size() - 1); positionBar.setProgress(getListables().size() - 1); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_REWIND) { pager.setCurrentItem(0); positionBar.setProgress(0); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PLAY) { Listable listable = getListables().get(pager.getCurrentItem()); if (listable instanceof Item) { playItem((Item) listable); return true; } } } return super.dispatchKeyEvent(event); }
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;//from w w w. jav a 2 s.c o 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 w w w. j a v a 2s .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 }/*from w w w . j ava 2s . 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: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 }/*from w w w. jav a 2 s.c om*/ 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.duy.pascal.ui.editor.view.CodeSuggestsEditText.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (!hasFocus()) { requestFocus();// ww w .jav a 2s.c om } if (mPopup.onKeyDown(keyCode, event)) { return true; } if (!isPopupShowing()) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: if (event.hasNoModifiers()) { performValidation(); } } } if (isPopupShowing() && keyCode == KeyEvent.KEYCODE_TAB && event.hasNoModifiers()) { return true; } mLastKeyCode = keyCode; boolean handled = super.onKeyDown(keyCode, event); mLastKeyCode = KeyEvent.KEYCODE_UNKNOWN; if (handled && isPopupShowing()) { clearListSelection(); } return handled; }
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 w ww.jav a2 s .co m*/ 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 {/*ww w . j a v a2s .c o 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. *///from w w w. j av a2 s . c o 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; }