List of usage examples for android.view KeyEvent KEYCODE_UNKNOWN
int KEYCODE_UNKNOWN
To view the source code for android.view KeyEvent KEYCODE_UNKNOWN.
Click Source Link
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 ww w . ja v a2 s . 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.duy.pascal.ui.editor.view.CodeSuggestsEditText.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (!hasFocus()) { requestFocus();//from w w w.j av a 2 s . co m } 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:com.juce.JuceAppActivity.java
public final void setScreenSaver (boolean enabled) { if (isScreenSaverEnabled != enabled) {//from w ww . j av a 2 s . c o m isScreenSaverEnabled = enabled; if (keepAliveTimer != null) { keepAliveTimer.cancel(); keepAliveTimer = null; } if (enabled) { getWindow().clearFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().addFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // If no user input is received after about 3 seconds, the OS will lower the // task's priority, so this timer forces it to be kept active. keepAliveTimer = new java.util.Timer(); keepAliveTimer.scheduleAtFixedRate (new TimerTask() { @Override public void run() { android.app.Instrumentation instrumentation = new android.app.Instrumentation(); try { instrumentation.sendKeyDownUpSync (KeyEvent.KEYCODE_UNKNOWN); } catch (Exception e) { } } }, 2000, 2000); } } }
From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java
private boolean onInterceptInputEvent(InputEvent event) { final boolean controlsHidden = !mControlVisible; if (DEBUG)// ww w. ja va 2s . c o m 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; }
From source file:com.iiordanov.bVNC.RemoteCanvas.java
/** * Sends over the unix username and password if this is VNC over SSH connectio and automatic sending of * UNIX credentials is enabled for AutoX (for x11vnc's "-unixpw" option). *///from w w w. ja va2 s. c o m void sendUnixAuth() { // If the type of connection is ssh-tunneled and we are told to send the unix credentials, then do so. if (connection.getConnectionType() == Constants.CONN_TYPE_SSH && connection.getAutoXUnixAuth()) { keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_UNKNOWN, new KeyEvent(SystemClock.uptimeMillis(), connection.getSshUser(), 0, 0)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_UNKNOWN, new KeyEvent(SystemClock.uptimeMillis(), connection.getSshPassword(), 0, 0)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER)); } }
From source file:com.delexus.imitationzhihu.MySearchView.java
void onSubmitQuery() { CharSequence query = mSearchSrcTextView.getText(); if (query != null && TextUtils.getTrimmedLength(query) > 0) { if (mOnQueryChangeListener == null || !mOnQueryChangeListener.onQueryTextSubmit(query.toString())) { if (mSearchable != null) { launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, query.toString()); }//from w w w .ja v a 2 s . c om setImeVisibility(false); dismissSuggestions(); } } }
From source file:io.github.vomitcuddle.SearchViewAllowEmpty.SearchView.java
/** * React to the user typing while in the suggestions list. First, check for * action keys. If not handled, try refocusing regular characters into the * EditText./*from w ww . j a v a2 s. c o m*/ */ private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) { // guard against possible race conditions (late arrival after dismiss) if (mSearchable == null) { return false; } if (mSuggestionsAdapter == null) { return false; } if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) { // First, check for enter or search (both of which we'll treat as a // "click") if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_TAB) { int position = mQueryTextView.getListSelection(); return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null); } // Next, check for left/right moves, which we use to "return" the // user to the edit view if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { // give "focus" to text editor, with cursor at the beginning if // left key, at end if right key int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView.length(); mQueryTextView.setSelection(selPoint); mQueryTextView.setListSelection(0); mQueryTextView.clearListSelection(); HIDDEN_METHOD_INVOKER.ensureImeVisible(mQueryTextView, true); return true; } // Next, check for an "up and out" move if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) { // TODO: restoreUserQuery(); // let ACTV complete the move return false; } } return false; }
From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java
/** * React to the user typing while in the suggestions list. First, check for * action keys. If not handled, try refocusing regular characters into the * EditText./*from w w w. ja va 2 s .c o m*/ */ private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) { // guard against possible race conditions (late arrival after dismiss) if (mSearchable == null) { return false; } if (mSuggestionsAdapter == null) { return false; } if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) { // First, check for enter or search (both of which we'll treat as a // "click") if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_TAB) { int position = mQueryTextView.getListSelection(); return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null); } // Next, check for left/right moves, which we use to "return" the // user to the edit view if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { // give "focus" to text editor, with cursor at the beginning if // left key, at end if right key // TODO: Reverse left/right for right-to-left languages, e.g. // Arabic int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView.length(); mQueryTextView.setSelection(selPoint); mQueryTextView.setListSelection(0); mQueryTextView.clearListSelection(); ensureImeVisible(mQueryTextView, true); return true; } // Next, check for an "up and out" move if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) { // TODO: restoreUserQuery(); // let ACTV complete the move return false; } // Next, check for an "action key" // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode); // TODO if ((actionKey != null) // TODO && ((actionKey.getSuggestActionMsg() != null) || (actionKey // TODO .getSuggestActionMsgColumn() != null))) { // TODO // launch suggestion using action key column // TODO int position = mQueryTextView.getListSelection(); // TODO if (position != ListView.INVALID_POSITION) { // TODO Cursor c = mSuggestionsAdapter.getCursor(); // TODO if (c.moveToPosition(position)) { // TODO final String actionMsg = getActionKeyMessage(c, actionKey); // TODO if (actionMsg != null && (actionMsg.length() > 0)) { // TODO return onItemClicked(position, keyCode, actionMsg); // TODO } // TODO } // TODO } // TODO } } return false; }
From source file:android.support.v7.widget.SearchView.java
/** * React to the user typing while in the suggestions list. First, check for * action keys. If not handled, try refocusing regular characters into the * EditText./*from w w w . j a va 2 s .c om*/ */ private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) { // guard against possible race conditions (late arrival after dismiss) if (mSearchable == null) { return false; } if (mSuggestionsAdapter == null) { return false; } if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) { // First, check for enter or search (both of which we'll treat as a // "click") if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_TAB) { int position = mSearchSrcTextView.getListSelection(); return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null); } // Next, check for left/right moves, which we use to "return" the // user to the edit view if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { // give "focus" to text editor, with cursor at the beginning if // left key, at end if right key // TODO: Reverse left/right for right-to-left languages, e.g. // Arabic int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mSearchSrcTextView.length(); mSearchSrcTextView.setSelection(selPoint); mSearchSrcTextView.setListSelection(0); mSearchSrcTextView.clearListSelection(); HIDDEN_METHOD_INVOKER.ensureImeVisible(mSearchSrcTextView, true); return true; } // Next, check for an "up and out" move if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mSearchSrcTextView.getListSelection()) { // TODO: restoreUserQuery(); // let ACTV complete the move return false; } } return false; }
From source file:io.github.vomitcuddle.SearchViewAllowEmpty.SearchView.java
private void onSubmitQuery() { CharSequence query = mQueryTextView.getText(); if (query != null) { if (mOnQueryChangeListener == null || !mOnQueryChangeListener.onQueryTextSubmit(query.toString())) { if (mSearchable != null) { launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, query.toString()); setImeVisibility(false); }/*from w w w. j a v a 2s.co m*/ dismissSuggestions(); } } }