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:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) { if (mKeyboardSwitcher.getInputView().handleBack()) { return true; }// w w w .j a va 2s. c o m } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return true; } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) { if (mKeyboardSwitcher.getInputView().handleBack()) { return true; } else if (mTutorial != null) { mTutorial.close();// w w w .j a va 2 s. c o m mTutorial = null; } } break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // If tutorial is visible, don't allow dpad to work if (mTutorial != null) { return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return true; } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return true; } break; } return super.onKeyDown(keyCode, event); }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); // Enable shift key and DPAD to do selections if (inputView != null && inputView.isShown() && inputView.getShiftState() == Keyboard.SHIFT_ON) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event);/*from w w w . j av a 2 s . c o m*/ return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolUpAction); } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolDownAction); } break; } return super.onKeyUp(keyCode, event); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: // If tutorial is visible, don't allow dpad to work if (mTutorial != null) { return true; }/*w w w.j a va2s. com*/ TKKeyboardView inputView = mKeyboardSwitcher.getInputView(); // Enable shift key and DPAD to do selections if (inputView != null && inputView.isShown() && inputView.getShiftState() == Keyboard.SHIFT_ON) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event); return true; } break; case KeyEvent.KEYCODE_VOLUME_UP: if (!mVolUpAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolUpAction); } break; case KeyEvent.KEYCODE_VOLUME_DOWN: if (!mVolDownAction.equals("none") && isKeyboardVisible()) { return doSwipeAction(mVolDownAction); } break; } return super.onKeyUp(keyCode, event); }
From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java
@TargetApi(Build.VERSION_CODES.FROYO) private boolean handleVolumeButtonEvent(KeyEvent event) { //Disable volume button handling during TTS if (!config.isVolumeKeyNavEnabled() || ttsIsRunning()) { return false; }/*from w ww. j av a 2 s .c om*/ Activity activity = getActivity(); if (activity == null) { return false; } boolean invert = false; int rotation = Surface.ROTATION_0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { Display display = activity.getWindowManager().getDefaultDisplay(); rotation = display.getRotation(); } switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: invert = false; break; case Surface.ROTATION_180: case Surface.ROTATION_270: invert = true; break; } if (event.getAction() != KeyEvent.ACTION_DOWN) { return true; } if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) { if (invert) { pageDown(Orientation.HORIZONTAL); } else { pageUp(Orientation.HORIZONTAL); } } else if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) { if (invert) { pageUp(Orientation.HORIZONTAL); } else { pageDown(Orientation.HORIZONTAL); } } return true; }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
@TargetApi(Build.VERSION_CODES.FROYO) private boolean handleVolumeButtonEvent(KeyEvent event) { // Disable volume button handling during TTS if (!config.isVolumeKeyNavEnabled() || ttsIsRunning()) { return false; }// w w w . java2s. co m Activity activity = getActivity(); if (activity == null) { return false; } boolean invert = false; int rotation = Surface.ROTATION_0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { Display display = activity.getWindowManager().getDefaultDisplay(); rotation = display.getRotation(); } switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: invert = false; break; case Surface.ROTATION_180: case Surface.ROTATION_270: invert = true; break; } if (event.getAction() != KeyEvent.ACTION_DOWN) { return true; } if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) { if (invert) { pageDown(Orientation.HORIZONTAL); } else { pageUp(Orientation.HORIZONTAL); } } else if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) { if (invert) { pageUp(Orientation.HORIZONTAL); } else { pageDown(Orientation.HORIZONTAL); } } return true; }
From source file:net.zorgblub.typhon.fragment.ReadingFragment.java
@TargetApi(Build.VERSION_CODES.FROYO) private boolean handleVolumeButtonEvent(KeyEvent event) { //Disable volume button handling during TTS if (!config.isVolumeKeyNavEnabled() || ttsIsRunning()) { return false; }/*from w ww . j a v a2 s. c om*/ Activity activity = getActivity(); if (activity == null) { return false; } boolean invert = false; int rotation = Surface.ROTATION_0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { Display display = activity.getWindowManager().getDefaultDisplay(); rotation = display.getRotation(); } switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: invert = false; break; case Surface.ROTATION_180: case Surface.ROTATION_270: invert = true; break; } if (event.getAction() != KeyEvent.ACTION_DOWN) { return true; } if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) { if (config.isVolumeKeyNavChaptersEnabled()) { if (invert) { bookView.navigateForward(); } else { bookView.navigateBack(); } } else { if (invert) { pageDown(Orientation.HORIZONTAL); } else { pageUp(Orientation.HORIZONTAL); } } } else if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) { if (config.isVolumeKeyNavChaptersEnabled()) { if (invert) { bookView.navigateBack(); } else { bookView.navigateForward(); } } else { if (invert) { pageUp(Orientation.HORIZONTAL); } else { pageDown(Orientation.HORIZONTAL); } } } return true; }
From source file:net.nightwhistler.pageturner.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 && searchMenuItem.isActionViewExpanded()) { boolean result = searchMenuItem.getActionView().dispatchKeyEvent(event); if (result) { return true; }/*from w w w. ja v a 2 s. c o m*/ } 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:net.nightwhistler.pageturner.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 w w w.j av a 2s . co m*/ } 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:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (volumeButtons && !vbListenerPause) { InputConnection ic = getCurrentInputConnection(); if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { ic.commitText("", -1); } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { ic.commitText("", 2); }// ww w. j a v a 2 s . c o m return true; } else { return super.onKeyDown(keyCode, event); } }