List of usage examples for android.view KeyEvent KEYCODE_DPAD_LEFT
int KEYCODE_DPAD_LEFT
To view the source code for android.view KeyEvent KEYCODE_DPAD_LEFT.
Click Source Link
From source file:com.stoyanr.feeder.activity.ItemsActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (KeyUtils.interpretDirection(keyCode)) { case KeyEvent.KEYCODE_DPAD_LEFT: return prevChannel(); case KeyEvent.KEYCODE_DPAD_RIGHT: return nextChannel(); default:/*from ww w . j ava 2 s . c o m*/ return super.onKeyUp(keyCode, event); } }
From source file:com.lib.media.widget.seekbar.VerticalSeekBar.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (isEnabled()) { final boolean handled; int direction = 0; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: direction = (mRotationAngle == ROTATION_ANGLE_CW_90) ? 1 : -1; handled = true;/*from w w w. j av a2 s .c om*/ break; case KeyEvent.KEYCODE_DPAD_UP: direction = (mRotationAngle == ROTATION_ANGLE_CW_270) ? 1 : -1; handled = true; break; case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // move view focus to previous/next view return false; default: handled = false; break; } if (handled) { final int keyProgressIncrement = getKeyProgressIncrement(); int progress = getProgress(); progress += (direction * keyProgressIncrement); if (progress >= 0 && progress <= getMax()) { _setProgressFromUser(progress, true); } return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.anl.wxb.jieqi.view.VerticalSeekBar.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (isEnabled()) { final boolean handled; int direction = 0; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: direction = (mRotationAngle == ROTATION_ANGLE_CW_90) ? 1 : -1; handled = true;//from w ww .ja v a 2 s.co m break; case KeyEvent.KEYCODE_DPAD_UP: direction = (mRotationAngle == ROTATION_ANGLE_CW_270) ? 1 : -1; handled = true; break; case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: handled = true; break; default: handled = false; break; } if (handled) { final int keyProgressIncrement = getKeyProgressIncrement(); int progress = getProgress(); progress += (direction * keyProgressIncrement); if (progress >= 0 && progress <= getMax()) { setProgress(progress - keyProgressIncrement, true); } return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.stoyanr.feeder.activity.ViewItemActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (KeyUtils.interpretDirection(keyCode)) { case KeyEvent.KEYCODE_DPAD_LEFT: return newerItem(); case KeyEvent.KEYCODE_DPAD_RIGHT: return olderItem(); default://from www . j ava 2 s . c om return super.onKeyUp(keyCode, event); } }
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
protected void scrollToBegin(Runnable verify) throws Throwable { int key;/*from ww w.j a va2 s .co 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.option.OptionFirstFragment.java
public boolean onKeyDown(int keyCode, KeyEvent event) { int selectPositon = getSelectedItemPosition(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: break;// ww w . ja v a 2 s. c om case KeyEvent.KEYCODE_DPAD_RIGHT: if (selectPositon == -1) break; if (OptionKarrays.isFromLauncher) { if (selectPositon == 2 || selectPositon == 3) { mCallback.onFirstSelectedData(selectPositon); } } else { if (getSelectedItemPosition() != 2) mCallback.onFirstSelectedData(selectPositon); } break; } return false; }
From source file:com.volosyukivan.WiFiInputMethod.java
void sendKey(int code, boolean down, boolean resetModifiers) { long time = System.currentTimeMillis(); if (time - lastWake > 5000) { wakeLock.acquire();// w w w . j a v a 2 s . c o m wakeLock.release(); lastWake = time; } InputConnection conn = getCurrentInputConnection(); if (conn == null) { // Debug.d("connection closed"); return; } if (code < 0) { if (down == false) return; switch (code) { case KEY_HOME: keyHome(conn); break; case KEY_END: keyEnd(conn); break; case KEY_DEL: keyDel(conn); break; } return; } if (code == KeyEvent.KEYCODE_DPAD_LEFT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordLeft(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_RIGHT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordRight(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_CENTER) { if (pressedKeys.contains(KEY_CONTROL)) { if (!down) return; copy(conn); return; } if (pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT)) { if (!down) return; paste(conn); return; } } // if (pressedKeys.contains(KEY_CONTROL)) { // if (down == false) return; // switch (code) { // case KeyEvent.KEYCODE_A: selectAll(conn); break; // case KeyEvent.KEYCODE_X: cut(conn); break; // case KeyEvent.KEYCODE_C: copy(conn); break; // case KeyEvent.KEYCODE_V: paste(conn); break; // } // return; // } conn.sendKeyEvent(new KeyEvent(down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP, code)); if (resetModifiers) { conn.clearMetaKeyStates(KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON); } }
From source file:android.support.v17.leanback.widget.GridWidgetTest.java
protected void scrollToEnd(Runnable verify) throws Throwable { int key;//from w w w . j av a 2s .c om if (mOrientation == BaseGridView.HORIZONTAL) { if (mGridView.getLayoutDirection() == ViewGroup.LAYOUT_DIRECTION_RTL) { key = KeyEvent.KEYCODE_DPAD_LEFT; } else { key = KeyEvent.KEYCODE_DPAD_RIGHT; } } else { key = KeyEvent.KEYCODE_DPAD_DOWN; } scroll(key, verify); }
From source file:org.opensilk.video.tv.ui.playback.PlaybackControlsFragment.java
@Override protected boolean onInterceptInputEvent(InputEvent event) { boolean hidden = areControlsHidden(); Timber.d("onInterceptInputEvent(%s) hidden = %s", event, hidden); boolean consumeEvent = false; boolean handled = false; int keyCode = KeyEvent.KEYCODE_UNKNOWN; if (event instanceof KeyEvent) { keyCode = ((KeyEvent) event).getKeyCode(); }/* ww w. j a v a 2s. c o m*/ 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: if (hidden) { if (((KeyEvent) event).getAction() == KeyEvent.ACTION_DOWN) { int delta = keyCode == KeyEvent.KEYCODE_DPAD_LEFT ? -10000 : 15000; consumeEvent = seekDelta(delta); } handled = true; } break; } return handled ? consumeEvent : super.onInterceptInputEvent(event); }
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//w w w .ja v a2 s . com 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; }