List of usage examples for android.view KeyEvent getNumber
public char getNumber()
From source file:com.csipsimple.ui.incall.DtmfDialogFragment.java
@Override public void onTrigger(int keyCode, int dialTone) { Log.i(TAG, "onTrigger, keyCode: " + keyCode + ", dialTone: " + dialTone); if (dialPadTextView != null) { // Update text view KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode); char nbr = event.getNumber(); StringBuilder sb = new StringBuilder(dialPadTextView.getText()); sb.append(nbr);/*from ww w . j a va 2s .c o m*/ dialPadTextView.setText(sb.toString()); } else { Log.e(TAG, "dialpadTextView is null"); } if (getActivity() instanceof OnDtmfListener) { Integer callId = getArguments().getInt(EXTRA_CALL_ID); if (callId != null) { ((OnDtmfListener) getActivity()).OnDtmf(callId, keyCode, dialTone); } else { Log.w(THIS_FILE, "Impossible to find the call associated to this view"); } } }
From source file:com.todoroo.astrid.activity.TaskListFragment.java
protected void setUpUiComponents() { // set listener for quick-changing task priority getListView().setOnKeyListener(new OnKeyListener() { @Override/*ww w .j av a 2 s. c o m*/ public boolean onKey(View view, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_UP || view == null) return false; boolean filterOn = getListView().isTextFilterEnabled(); View selected = getListView().getSelectedView(); // hot-key to set task priority - 1-4 or ALT + Q-R if (!filterOn && event.getUnicodeChar() >= '1' && event.getUnicodeChar() <= '4' && selected != null) { int importance = event.getNumber() - '1'; Task task = ((ViewHolder) selected.getTag()).task; task.setValue(Task.IMPORTANCE, importance); taskService.save(task); taskAdapter.setFieldContentsAndVisibility(selected); } // filter else if (!filterOn && event.getUnicodeChar() != 0) { getListView().setTextFilterEnabled(true); getListView().setFilterText(Character.toString((char) event.getUnicodeChar())); } // turn off filter if nothing is selected else if (filterOn && TextUtils.isEmpty(getListView().getTextFilter())) { getListView().setTextFilterEnabled(false); } return false; } }); SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(getActivity()); sortFlags = publicPrefs.getInt(SortHelper.PREF_SORT_FLAGS, 0); sortSort = publicPrefs.getInt(SortHelper.PREF_SORT_SORT, 0); sortFlags = SortHelper.setManualSort(sortFlags, isDraggable()); getView().findViewById(R.id.progressBar).setVisibility(View.GONE); }