List of usage examples for android.view KeyEvent getDisplayLabel
public char getDisplayLabel()
From source file:cx.ring.fragments.CallFragment.java
public void onKeyUp(int keyCode, KeyEvent event) { try {//from w w w .j av a 2 s . c o m switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: break; default: String toSend = Character.toString(event.getDisplayLabel()); toSend = toSend.toUpperCase(Locale.getDefault()); Log.d(TAG, "toSend " + toSend); mCallbacks.getRemoteService().playDtmf(toSend); break; } } catch (RemoteException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:com.android.screenspeak.KeyboardSearchManager.java
@Override public boolean onKeyEvent(KeyEvent event) { // Only handle single-key events here. The KeyComboManager will pass us combos. if (event.getModifiers() != 0 || !mNodeSearch.isActive()) { return false; }/*from www. j a v a 2 s.c o m*/ if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_ENTER: if (mHasNavigated || mNodeSearch.hasMatch()) { finishSearch(); mContext.getCursorController().clickCurrent(); } else { cancelSearch(); } return true; case KeyEvent.KEYCODE_DEL: resetHintTime(); final String queryText = mNodeSearch.getCurrentQuery(); if (queryText.isEmpty()) { cancelSearch(); } else { final String lastChar = queryText.substring(queryText.length() - 1); mNodeSearch.backspaceQueryText(); mSpeechController.speak(mContext.getString(R.string.template_text_removed, lastChar), SpeechController.QUEUE_MODE_FLUSH_ALL, FeedbackItem.FLAG_NO_HISTORY, null); } return true; case KeyEvent.KEYCODE_DPAD_UP: moveToEnd(NodeFocusFinder.SEARCH_BACKWARD); return true; case KeyEvent.KEYCODE_DPAD_LEFT: moveToNext(NodeFocusFinder.SEARCH_BACKWARD); return true; case KeyEvent.KEYCODE_DPAD_DOWN: moveToEnd(NodeFocusFinder.SEARCH_FORWARD); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: moveToNext(NodeFocusFinder.SEARCH_FORWARD); return true; case KeyEvent.KEYCODE_SPACE: resetHintTime(); if (mNodeSearch.tryAddQueryText(" ")) { mSpeechController.speak(mContext.getString(R.string.symbol_space), SpeechController.QUEUE_MODE_FLUSH_ALL, FeedbackItem.FLAG_NO_HISTORY, null); } else { mContext.getFeedbackController().playAuditory(R.raw.complete); } return true; default: if (event.isPrintingKey()) { resetHintTime(); final String key = String.valueOf(event.getDisplayLabel()); if (mNodeSearch.tryAddQueryText(key)) { mSpeechController.speak(key.toLowerCase(), SpeechController.QUEUE_MODE_FLUSH_ALL, FeedbackItem.FLAG_NO_HISTORY, null); } else { mContext.getFeedbackController().playAuditory(R.raw.complete); } return true; } break; } } return false; }