List of usage examples for android.view KeyEvent ACTION_UP
int ACTION_UP
To view the source code for android.view KeyEvent ACTION_UP.
Click Source Link
From source file:self.philbrown.droidQuery.$.java
/** * Refreshes the listeners for key events *//*ww w . j a v a2 s. c om*/ private void setupKeyListener() { for (View view : views) { view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean retVal = false; switch (event.getKeyCode()) { case KeyEvent.ACTION_DOWN: { if (keyDown != null) { keyDown.invoke($.with(v), keyCode, event); retVal = true; } break; } case KeyEvent.ACTION_UP: { if (keyUp != null) { keyUp.invoke($.with(v), keyCode, event); retVal = true; } break; } } if (keyPress != null) { keyPress.invoke($.with(v), keyCode, event); retVal = true; } return retVal; } }); } }
From source file:android.support.v7ox.app.AppCompatActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { final int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { final int action = event.getAction(); if (action == KeyEvent.ACTION_DOWN) { if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) { final ActionBar actionBar = getSupportActionBar(); if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) { mEatKeyUpEvent = true; return true; }// w w w . j a v a 2s. co m } } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) { mEatKeyUpEvent = false; return true; } } return super.dispatchKeyEvent(event); }
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 ww w. j a v a2 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:su.comp.bk.ui.BkEmuActivity.java
@Override public void onBackPressed() { KeyboardController keyboardController = this.computer.getKeyboardController(); if (keyboardController.isOnScreenKeyboardVisible()) { keyboardController.setOnScreenKeyboardVisibility(false); } else {// ww w. j a va2 s .co m this.computer.pause(); new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.exit_confirm_title).setMessage(R.string.exit_confirm_message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BkEmuActivity.this.computer.resume(); } }).setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { BkEmuActivity.this.computer.resume(); } return false; } }).show(); } }
From source file:org.appcelerator.titanium.TiBaseActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { boolean handled = false; TiViewProxy window;/*from w ww . j a v a 2 s .co m*/ if (this.window != null) { window = this.window; } else { window = this.view; } if (window == null) { return super.dispatchKeyEvent(event); } switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: { if (event.getAction() == KeyEvent.ACTION_UP) { String backEvent = "android:back"; KrollProxy proxy = null; //android:back could be fired from a tabGroup window (activityProxy) //or hw window (window).This event is added specifically to the activity //proxy of a tab group in window.js if (activityProxy.hasListeners(backEvent)) { proxy = activityProxy; } else if (window.hasListeners(backEvent)) { proxy = window; } if (proxy != null) { proxy.fireEvent(backEvent, null); handled = true; } } break; } case KeyEvent.KEYCODE_CAMERA: { if (window.hasListeners(TiC.EVENT_ANDROID_CAMERA)) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent(TiC.EVENT_ANDROID_CAMERA, null); } handled = true; } // TODO: Deprecate old event if (window.hasListeners("android:camera")) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent("android:camera", null); } handled = true; } break; } case KeyEvent.KEYCODE_FOCUS: { if (window.hasListeners(TiC.EVENT_ANDROID_FOCUS)) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent(TiC.EVENT_ANDROID_FOCUS, null); } handled = true; } // TODO: Deprecate old event if (window.hasListeners("android:focus")) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent("android:focus", null); } handled = true; } break; } case KeyEvent.KEYCODE_SEARCH: { if (window.hasListeners(TiC.EVENT_ANDROID_SEARCH)) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent(TiC.EVENT_ANDROID_SEARCH, null); } handled = true; } // TODO: Deprecate old event if (window.hasListeners("android:search")) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent("android:search", null); } handled = true; } break; } case KeyEvent.KEYCODE_VOLUME_UP: { if (window.hasListeners(TiC.EVENT_ANDROID_VOLUP)) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent(TiC.EVENT_ANDROID_VOLUP, null); } handled = true; } // TODO: Deprecate old event if (window.hasListeners("android:volup")) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent("android:volup", null); } handled = true; } break; } case KeyEvent.KEYCODE_VOLUME_DOWN: { if (window.hasListeners(TiC.EVENT_ANDROID_VOLDOWN)) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent(TiC.EVENT_ANDROID_VOLDOWN, null); } handled = true; } // TODO: Deprecate old event if (window.hasListeners("android:voldown")) { if (event.getAction() == KeyEvent.ACTION_UP) { window.fireEvent("android:voldown", null); } handled = true; } break; } } if (!handled) { handled = super.dispatchKeyEvent(event); } return handled; }
From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java
@Override public boolean dispatchKeyEventPreIme(KeyEvent event) { if (isMenuOpen() && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && event.getRepeatCount() == 0) { closeMenu();//from ww w. java 2s.c o m return true; } return super.dispatchKeyEventPreIme(event); }
From source file:com.todoroo.astrid.activity.TaskListFragment.java
protected void setUpUiComponents() { // set listener for quick-changing task priority getListView().setOnKeyListener(new OnKeyListener() { @Override//from ww w . ja va 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); }
From source file:com.owen.tvrecyclerview.widget.TvRecyclerView.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { boolean result = super.dispatchKeyEvent(event); if (!result) { switch (event.getAction()) { case KeyEvent.ACTION_DOWN: result = onKeyDown(event.getKeyCode(), event); break; case KeyEvent.ACTION_UP: result = onKeyUp(event.getKeyCode(), event); break; }/*from ww w . j av a 2 s. c om*/ } return result; }
From source file:org.akop.ararat.view.CrosswordView.java
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_UP) { if (keyCode == KeyEvent.KEYCODE_SPACE) { switchWordDirection();/*from ww w . j a v a2 s .c o m*/ handled = true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { handleBackspace(); handled = true; } else { int uniChar = event.getUnicodeChar(); if (uniChar != 0) { handleInput((char) event.getUnicodeChar()); handled = true; } } } return handled; }