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:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating();// w ww . ja va2 s . com return true; } switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: // Yes, this is nasty: if the setting is true, we fall through to // the next case. if (!config.isVolumeKeyNavEnabled()) { return false; } case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_VOLUME_UP: // Same dirty trick. if (!config.isVolumeKeyNavEnabled()) { return false; } 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(); } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } else { this.finish(); } } } return false; }
From source file:net.olejon.spotcommander.WebViewActivity.java
@Override public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: { event.startTracking();/* w w w . jav a 2 s .c o m*/ return true; } case KeyEvent.KEYCODE_MENU: { return true; } case KeyEvent.KEYCODE_SEARCH: { return true; } case KeyEvent.KEYCODE_VOLUME_DOWN: { return true; } case KeyEvent.KEYCODE_VOLUME_UP: { return true; } default: { return super.onKeyDown(keyCode, event); } } }
From source file:org.liberty.android.fantastischmemo.ui.QACardActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (option.getVolumeKeyShortcut()) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { return onVolumeUpKeyPressed(); }// w w w . j a v a 2 s . co m if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return onVolumeDownKeyPressed(); } } return super.onKeyUp(keyCode, event); }
From source file:com.piusvelte.webcaster.MainActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { double currentVolume; if (mediaProtocolMessageStream != null) { currentVolume = mediaProtocolMessageStream.getVolume(); if (currentVolume < 1.0) { onSetVolume(currentVolume + VOLUME_INCREMENT); }//from www . ja va 2 s .co m } else { Log.e(TAG, "dispatchKeyEvent - volume up - mMPMS==null"); } } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { double currentVolume; if (mediaProtocolMessageStream != null) { currentVolume = mediaProtocolMessageStream.getVolume(); if (currentVolume > 0.0) { onSetVolume(currentVolume - VOLUME_INCREMENT); } } else { Log.e(TAG, "dispatchKeyEvent - volume down - mMPMS==null"); } } return true; default: return super.dispatchKeyEvent(event); } }
From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { int c = event.getUnicodeChar(); if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) { setVolume(mVolumeLevel + 20); } else {/*from ww w . jav a 2s . com*/ mMediaServer.status().command.volumeUp(); } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) { setVolume(mVolumeLevel - 20); } else { mMediaServer.status().command.volumeDown(); } return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { if (event.isAltPressed()) { mMediaServer.status().command.seek(Uri.encode("-".concat(Preferences.get(this).getSeekTime()))); return true; } else if (event.isShiftPressed()) { mMediaServer.status().command.seek(Uri.encode("-3")); return true; } else { mMediaServer.status().command.key("nav-left"); return true; } } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { if (event.isAltPressed()) { mMediaServer.status().command.seek(Uri.encode("+".concat(Preferences.get(this).getSeekTime()))); return true; } else if (event.isShiftPressed()) { mMediaServer.status().command.seek(Uri.encode("+3")); return true; } else { mMediaServer.status().command.key("nav-right"); return true; } } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { mMediaServer.status().command.key("nav-up"); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { mMediaServer.status().command.key("nav-down"); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { mMediaServer.status().command.key("nav-activate"); return true; } else if (c == ' ') { mMediaServer.status().command.playback.pause(); return true; } else if (c == 's') { mMediaServer.status().command.playback.stop(); return true; } else if (c == 'p') { mMediaServer.status().command.playback.previous(); return true; } else if (c == 'n') { mMediaServer.status().command.playback.next(); return true; } else if (c == '+') { // TODO: Play faster return super.onKeyDown(keyCode, event); } else if (c == '-') { // TODO: Play slower return super.onKeyDown(keyCode, event); } else if (c == 'f') { mMediaServer.status().command.fullscreen(); return true; } else if (c == 'm') { mute(); return true; } else { return super.onKeyDown(keyCode, event); } }
From source file:org.appcelerator.titanium.TiBaseActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { boolean handled = false; TiViewProxy window;//from w w w . j a va 2s . c o 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:com.ll.myapplication.vitamio.widget.VideoView.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL; if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE) { if (mMediaPlayer.isPlaying()) { pause();//from w w w .j av a2 s . c o m mMediaController.show(); } else { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (!mMediaPlayer.isPlaying()) { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } return true; } else { toggleMediaControlsVisiblity(); } } return super.onKeyDown(keyCode, event); }
From source file:com.fvd.nimbus.PaintActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { drawView.zoom(1.25f);//from w w w.j a v a 2s . com } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { drawView.zoom(0.75f); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); return true; } else if (findViewById(R.id.text_field).getVisibility() != View.GONE) { findViewById(R.id.text_field).setVisibility(View.GONE); drawView.hideCrop(); drawView.startEdit(); setSelectedFoot(0); return true; } else if (findViewById(R.id.color_menu).getVisibility() != View.GONE) { findViewById(R.id.color_menu).setVisibility(View.GONE); drawView.hideCrop(); drawView.startEdit(); setSelectedFoot(0); return true; } else if (findViewById(R.id.draw_tools).getVisibility() != View.GONE) { findViewById(R.id.draw_tools).setVisibility(View.GONE); drawView.hideCrop(); drawView.startEdit(); setSelectedFoot(0); return false; } else if (!drawView.hideCrop()) { if (!saved && storePath.length() == 0) showDialog(0); else { drawView.recycle(); finish(); return true; } } else { ((ImageButton) findViewById(R.id.bToolCrop)).setSelected(false); drawView.startEdit(); setSelectedFoot(0); return true; } } default: return super.dispatchKeyEvent(event); } }
From source file:net.olejon.spotcommander.WebViewActivity.java
@Override public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_MENU: { mWebView.loadUrl("javascript:nativeAppAction('menu')"); return true; }//ww w.j a v a 2 s. c o m case KeyEvent.KEYCODE_SEARCH: { mWebView.loadUrl("javascript:nativeAppAction('search')"); return true; } case KeyEvent.KEYCODE_BACK: { if (mHasLongPressedBack) return true; if (mWebView.canGoBack() && mWebView.getUrl().contains("accounts.spotify.com/") || mWebView.canGoBack() && mWebView.getUrl().contains("facebook.com/")) { mWebView.goBack(); return true; } else if (mWebView.canGoBack() || mTools.getSharedPreferencesBoolean("CAN_CLOSE_COVER")) { mWebView.loadUrl("javascript:nativeAppAction('back')"); return true; } mTools.showToast(getString(R.string.webview_back), 1); return true; } case KeyEvent.KEYCODE_VOLUME_DOWN: { mWebView.loadUrl("javascript:nativeAppAction('volume_down')"); return true; } case KeyEvent.KEYCODE_VOLUME_UP: { mWebView.loadUrl("javascript:nativeAppAction('volume_up')"); return true; } default: { return super.onKeyUp(keyCode, event); } } }
From source file:org.apache.cordova.AndroidWebView.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyDownCodes.contains(keyCode)) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { // only override default behavior is event bound LOG.d(TAG, "Down Key Hit"); this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');"); return true; }//ww w. j av a 2s . c o m // If volumeup key else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { LOG.d(TAG, "Up Key Hit"); this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');"); return true; } else { return super.onKeyDown(keyCode, event); } } else if (keyCode == KeyEvent.KEYCODE_BACK) { return !(this.startOfHistory()) || this.bound; } else if (keyCode == KeyEvent.KEYCODE_MENU) { //How did we get here? Is there a childView? View childView = this.getFocusedChild(); if (childView != null) { //Make sure we close the keyboard if it's present InputMethodManager imm = (InputMethodManager) cordova.getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(childView.getWindowToken(), 0); cordova.getActivity().openOptionsMenu(); return true; } else { return super.onKeyDown(keyCode, event); } } return super.onKeyDown(keyCode, event); }