List of usage examples for android.view KeyEvent KEYCODE_VOLUME_UP
int KEYCODE_VOLUME_UP
To view the source code for android.view KeyEvent KEYCODE_VOLUME_UP.
Click Source Link
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (volumeButtons && (keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { return true; } else if (!vbListenerPause && keyCode == KeyEvent.KEYCODE_BACK) { screen = 1;/*from www . j a v a 2s.c o m*/ if (shakeDelete) { mShaker.pause(); } vbListenerPause = true; return true; } else { return super.onKeyUp(keyCode, event); } }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && searchMenuItem.isActionViewExpanded()) { boolean result = searchMenuItem.getActionView().dispatchKeyEvent(event); if (result) { return true; }//from ww w . jav a 2 s . c om } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, we want to be * able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: once * through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (!Configuration.IS_NOOK_TOUCH || action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:net.zorgblub.typhon.fragment.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && MenuItemCompat.isActionViewExpanded(searchMenuItem)) { boolean result = MenuItemCompat.getActionView(searchMenuItem).dispatchKeyEvent(event); if (result) { return true; }//from w ww.j a va2 s . com } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, * we want to be able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: * once through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:com.android.email.activity.MessageView.java
@Override public boolean onKeyDown(int keycode, KeyEvent event) { switch (keycode) { case KeyEvent.KEYCODE_VOLUME_DOWN: moveToOlder();/*from w ww .j a va 2 s . c o m*/ break; case KeyEvent.KEYCODE_VOLUME_UP: moveToNewer(); break; default: return super.onKeyDown(keycode, event); } return true; }
From source file:com.youku.player.base.YoukuBasePlayerActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { try {/*from ww w.j a va 2s . c o m*/ switch (keyCode) { case KeyEvent.KEYCODE_MENU: // ?menu? if (event.getRepeatCount() > 0) { return true; } return mediaPlayerDelegate.isFullScreen; case KeyEvent.KEYCODE_BACK: // ??? if (event.getRepeatCount() > 0) { return true; } if (!mediaPlayerDelegate.isDLNA) { if (mediaPlayerDelegate.isFullScreen && !isFromLocal() && (mediaPlayerDelegate.videoInfo != null && !mediaPlayerDelegate.videoInfo.isHLS)) { goSmall(); return true; } else { onkeyback(); return true; } } else { return true; } case KeyEvent.KEYCODE_VOLUME_DOWN: return volumeDown(); case KeyEvent.KEYCODE_VOLUME_UP: return volumeUp(); case KeyEvent.KEYCODE_SEARCH: return mediaPlayerDelegate.isFullScreen; case 125: /** popupwindow */ return true; } } catch (Exception e) { e.printStackTrace(); } return super.onKeyDown(keyCode, event); }
From source file:com.android.email.activity.MessageView.java
@Override public boolean onKeyUp(int keycode, KeyEvent event) { switch (keycode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: break;/*ww w. j a v a 2 s. c om*/ default: return super.onKeyUp(keycode, event); } return true; }
From source file:de.danoeh.antennapod.core.cast.CastManager.java
/** * Clients can call this method to delegate handling of the volume. Clients should override * {@code dispatchEvent} and call this method: * <pre>/*from w w w . jav a 2 s. c o m*/ public boolean dispatchKeyEvent(KeyEvent event) { if (mCastManager.onDispatchVolumeKeyEvent(event, VOLUME_DELTA)) { return true; } return super.dispatchKeyEvent(event); } * </pre> * @param event The dispatched event. * @param volumeDelta The amount by which volume should be increased or decreased in each step * @return <code>true</code> if volume is handled by the library, <code>false</code> otherwise. */ public boolean onDispatchVolumeKeyEvent(KeyEvent event, double volumeDelta) { if (isConnected()) { boolean isKeyDown = event.getAction() == KeyEvent.ACTION_DOWN; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_UP: return changeVolume(volumeDelta, isKeyDown); case KeyEvent.KEYCODE_VOLUME_DOWN: return changeVolume(-volumeDelta, isKeyDown); } } return false; }
From source file:com.plusot.senselib.SenseMain.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { final int action = event.getAction(); final int keyCode = event.getKeyCode(); boolean result = false; if ((lastAction == action && lastKeyCode == keyCode)) { switch (keyCode) { case KeyEvent.KEYCODE_CAMERA: newInterval();// ww w . j av a2s . c o m break; case KeyEvent.KEYCODE_POWER: //if (action == KeyEvent.) LLog.d(Globals.TAG, CLASSTAG + " Power button pressed"); break; case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { dimScreen(true); } result = true; break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { dimScreen(false); } result = true; break; } } else { AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE); switch (keyCode) { case KeyEvent.KEYCODE_CAMERA: newInterval(); break; case KeyEvent.KEYCODE_VOLUME_UP: if (sameActionKeyCode < 2 && lastAction == KeyEvent.ACTION_DOWN && action == KeyEvent.ACTION_UP && lastKeyCode == KeyEvent.KEYCODE_VOLUME_UP) { mgr.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND); } result = true; break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (sameActionKeyCode < 2 && lastAction == KeyEvent.ACTION_DOWN && action == KeyEvent.ACTION_UP && lastKeyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { mgr.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND); } result = true; break; } } if (!result) { // LLog.d(Globals.TAG, CLASSTAG + // ".distpatchKeyEvent: Calling super with " + delta); result = super.dispatchKeyEvent(event); } if (lastAction == action && lastKeyCode == keyCode) { sameActionKeyCode++; } else sameActionKeyCode = 0; lastKeyCode = keyCode; lastAction = action; return result; }
From source file:org.telegram.ui.Components.ChatAttachAlert.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (cameraOpened && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { shutterButton.getDelegate().shutterReleased(); return true; }//ww w. j a v a 2 s . c om return super.onKeyDown(keyCode, event); }