List of usage examples for android.view KeyEvent KEYCODE_VOLUME_DOWN
int KEYCODE_VOLUME_DOWN
To view the source code for android.view KeyEvent KEYCODE_VOLUME_DOWN.
Click Source Link
From source file:com.google.fpl.voltair.VoltAirActivity.java
/** * @brief Called to process (and possibly intercept) key events. * @param event @c KeyEvent to handle/*ww w. j a v a 2 s .c o m*/ * @returns @c true if @p event was handled */ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { // Since QtActivity does not handle volume (throwing the events on the floor) and we // cannot call super.super, we must handle managing of the volume here // TODO: Figure out how to get the volume Ui slide to show up without permanently // breaking immersive mode. switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_UP: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0 /* No flags */); break; case KeyEvent.KEYCODE_VOLUME_DOWN: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0 /* No flags */); break; } } // QtActivity (i.e. super) will convert all key events to QKeyEvents and *always* return // true saying it accepted the event -- even on Gamepad key events it doesn't understand. // This is annoying, and unfortunately means that we must always let controllers take a look // at the event even if QtActivity understood it and accepted it for use (e.g. in the UI). // However, we must be careful with events that are successfully translated (e.g. Keyboard // key events) so as to not spawn two separate controllers (one here with the Android // KeyEvent, and the other one in "InputArea" with the translated QKeyEvent). if (isGamepadEvent(event)) { if (onGamepadKeyEvent(event)) { return true; } } else if (isTouchNavigationEvent(event)) { if (onTouchNavigationKeyEvent(event)) { return true; } } else if (isKeyboardEvent(event)) { if (onKeyboardKeyEvent(event)) { return true; } } return super.dispatchKeyEvent(event); }
From source file:org.libreoffice.impressremote.activity.SlideShowActivity.java
@Override public boolean onKeyUp(int aKeyCode, KeyEvent aKeyEvent) { if (!areVolumeKeysActionsRequired()) { return super.onKeyUp(aKeyCode, aKeyEvent); }/*from w w w .j a v a 2 s . com*/ // Suppress sound of volume changing switch (aKeyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: return true; default: return super.onKeyUp(aKeyCode, aKeyEvent); } }
From source file:org.ulteo.ovd.AndRdpActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { AudioManager audioManager;// w w w. j a v a 2 s .c om if (Config.DEBUG) Log.i(Config.TAG, "AndRdpActivity.dispatchKeyEvent " + event); // Disable keypress if it is from a mouse or touchpad. if (event.getDeviceId() >= 0) { InputDevice dev = InputDevice.getDevice(event.getDeviceId()); if (dev.getSources() == InputDevice.SOURCE_MOUSE || dev.getSources() == InputDevice.SOURCE_TOUCHPAD) return true; } if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MENU: OnThreeFingers(null); return true; case KeyEvent.KEYCODE_BACK: Log.i(Config.TAG, "Back key pressed"); askLogoutDialog(); return true; case KeyEvent.KEYCODE_VOLUME_UP: audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MENU: case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: return true; } } if (isLoggedIn() && rdp.dispatchKeyEvent(event)) return true; return super.dispatchKeyEvent(event); }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java
@Override public boolean onKeyLongPress(int keyCode, KeyEvent event) { /*if (!MusubiBaseActivity.getInstance().isDeveloperModeEnabled()) { return false;//ww w . j a v a 2 s. c om }*/ if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { Intent record = new Intent(getActivity(), VoiceQuickRecordActivity.class); record.putExtra("feed_uri", mFeedUri); record.putExtra("keydown", true); startActivity(record); return true; } if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { Intent camera = new Intent(getActivity(), PhotoQuickTakeActivity.class); camera.putExtra("feed_uri", mFeedUri); startActivity(camera); return true; } return false; }
From source file:org.mozilla.gecko.AwesomeBar.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // This method is called only if the key event was not handled // by any of the views, which usually means the edit box lost focus if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return super.onKeyDown(keyCode, event); } else {//w w w. j a v a2 s . co m int selStart = -1; int selEnd = -1; if (mText.hasSelection()) { selStart = mText.getSelectionStart(); selEnd = mText.getSelectionEnd(); } // Return focus to the edit box, and dispatch the event to it mText.requestFocusFromTouch(); if (selStart >= 0) { // Restore the selection, which gets lost due to the focus switch mText.setSelection(selStart, selEnd); } mText.dispatchKeyEvent(event); return true; } }
From source file:com.shinymayhem.radiopresets.ActivityMain.java
public boolean onKeyUp(int keyCode, KeyEvent event) { FragmentPlayer fragment = (FragmentPlayer) this.getSupportFragmentManager() .findFragmentByTag(FragmentPlayer.FRAGMENT_TAG); if (fragment != null && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { fragment.updateSlider();/* w ww . j a va 2 s . co m*/ } return super.onKeyUp(keyCode, event); }
From source file:com.CrestronXPanelApp.CrestronXPanelApp.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { if (event.getRepeatCount() == 0 && specialList.containsKey("sideup")) { sendDigitalListMessage(specialList.get("sideup"), 0); }/* w w w . j av a 2 s . co m*/ return true; } if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { if (event.getRepeatCount() == 0 && specialList.containsKey("sidedown")) { sendDigitalListMessage(specialList.get("sidedown"), 0); } return true; } if (keyCode == KeyEvent.KEYCODE_BACK) { this.finish(); } return super.onKeyDown(keyCode, event); }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) { if (!event.isTracking()) { return true; }/*from w w w . j a v a2s. c o m*/ if (!event.isLongPress()) { AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); audio.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); return true; } } if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) { if (!event.isTracking()) { return true; } if (!event.isLongPress()) { AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); audio.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); return true; } } return false; }
From source file:paulscode.android.mupen64plusae.persistent.UserPrefs.java
/** * Instantiates a new user preferences wrapper. * //from w w w . ja v a 2 s.c om * @param context The application context. */ @SuppressWarnings("deprecation") @SuppressLint("InlinedApi") @TargetApi(17) public UserPrefs(Context context) { AppData appData = new AppData(context); mPreferences = PreferenceManager.getDefaultSharedPreferences(context); // Locale mLocaleCode = mPreferences.getString(KEY_LOCALE_OVERRIDE, DEFAULT_LOCALE_OVERRIDE); mLocale = TextUtils.isEmpty(mLocaleCode) ? Locale.getDefault() : createLocale(mLocaleCode); Locale[] availableLocales = Locale.getAvailableLocales(); String[] values = context.getResources().getStringArray(R.array.localeOverride_values); String[] entries = new String[values.length]; for (int i = values.length - 1; i > 0; i--) { Locale locale = createLocale(values[i]); // Get intersection of languages (available on device) and (translated for Mupen) if (ArrayUtils.contains(availableLocales, locale)) { // Get the name of the language, as written natively entries[i] = WordUtils.capitalize(locale.getDisplayName(locale)); } else { // Remove the item from the list entries = (String[]) ArrayUtils.remove(entries, i); values = (String[]) ArrayUtils.remove(values, i); } } entries[0] = context.getString(R.string.localeOverride_entrySystemDefault); mLocaleNames = entries; mLocaleCodes = values; // Files userDataDir = mPreferences.getString("pathGameSaves", ""); galleryDataDir = userDataDir + "/GalleryData"; profilesDir = userDataDir + "/Profiles"; crashLogDir = userDataDir + "/CrashLogs"; coreUserDataDir = userDataDir + "/CoreConfig/UserData"; coreUserCacheDir = userDataDir + "/CoreConfig/UserCache"; hiResTextureDir = coreUserDataDir + "/mupen64plus/hires_texture/"; // MUST match what rice assumes natively romInfoCache_cfg = galleryDataDir + "/romInfoCache.cfg"; controllerProfiles_cfg = profilesDir + "/controller.cfg"; touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; emulationProfiles_cfg = profilesDir + "/emulation.cfg"; customCheats_txt = profilesDir + "/customCheats.txt"; // Plug-ins audioPlugin = new Plugin(mPreferences, appData.libsDir, "audioPlugin"); // Touchscreen prefs isTouchscreenFeedbackEnabled = mPreferences.getBoolean("touchscreenFeedback", false); touchscreenRefresh = getSafeInt(mPreferences, "touchscreenRefresh", 0); touchscreenScale = ((float) mPreferences.getInt("touchscreenScale", 100)) / 100.0f; touchscreenTransparency = (255 * mPreferences.getInt("touchscreenTransparency", 100)) / 100; touchscreenSkin = appData.touchscreenSkinsDir + "/" + mPreferences.getString("touchscreenStyle", "Outline"); touchscreenAutoHold = getSafeInt(mPreferences, "touchscreenAutoHold", 0); // Xperia PLAY touchpad prefs isTouchpadEnabled = appData.hardwareInfo.isXperiaPlay && mPreferences.getBoolean("touchpadEnabled", true); isTouchpadFeedbackEnabled = mPreferences.getBoolean("touchpadFeedback", false); touchpadSkin = appData.touchpadSkinsDir + "/Xperia-Play"; ConfigFile touchpad_cfg = new ConfigFile(appData.touchpadProfiles_cfg); ConfigSection section = touchpad_cfg.get(mPreferences.getString("touchpadLayout", "")); if (section != null) touchpadProfile = new Profile(true, section); else touchpadProfile = null; // Video prefs displayOrientation = getSafeInt(mPreferences, "displayOrientation", 0); displayPosition = getSafeInt(mPreferences, "displayPosition", Gravity.CENTER_VERTICAL); int transparencyPercent = mPreferences.getInt("displayActionBarTransparency", 50); displayActionBarTransparency = (255 * transparencyPercent) / 100; displayFpsRefresh = getSafeInt(mPreferences, "displayFpsRefresh", 0); isFpsEnabled = displayFpsRefresh > 0; videoHardwareType = getSafeInt(mPreferences, "videoHardwareType", -1); videoPolygonOffset = SafeMethods.toFloat(mPreferences.getString("videoPolygonOffset", "-0.2"), -0.2f); isImmersiveModeEnabled = mPreferences.getBoolean("displayImmersiveMode", false); // Audio prefs audioSwapChannels = mPreferences.getBoolean("audioSwapChannels", false); audioSecondaryBufferSize = getSafeInt(mPreferences, "audioBufferSize", 2048); if (audioPlugin.enabled) isFramelimiterEnabled = mPreferences.getBoolean("audioSynchronize", true); else isFramelimiterEnabled = !mPreferences.getString("audioPlugin", "").equals("nospeedlimit"); // User interface modes String navMode = mPreferences.getString("navigationMode", "auto"); if (navMode.equals("bigscreen")) isBigScreenMode = true; else if (navMode.equals("standard")) isBigScreenMode = false; else isBigScreenMode = AppData.IS_OUYA_HARDWARE; // TODO: Add other systems as they enter market isActionBarAvailable = AppData.IS_HONEYCOMB && !isBigScreenMode; // Peripheral share mode isControllerShared = mPreferences.getBoolean("inputShareController", false); // Determine the key codes that should not be mapped to controls boolean volKeysMappable = mPreferences.getBoolean("inputVolumeMappable", false); List<Integer> unmappables = new ArrayList<Integer>(); unmappables.add(KeyEvent.KEYCODE_MENU); if (AppData.IS_HONEYCOMB) { // Back key is needed to show/hide the action bar in HC+ unmappables.add(KeyEvent.KEYCODE_BACK); } if (!volKeysMappable) { unmappables.add(KeyEvent.KEYCODE_VOLUME_UP); unmappables.add(KeyEvent.KEYCODE_VOLUME_DOWN); unmappables.add(KeyEvent.KEYCODE_VOLUME_MUTE); } unmappableKeyCodes = Collections.unmodifiableList(unmappables); // Determine the pixel dimensions of the rendering context and view surface { // Screen size final WindowManager windowManager = (WindowManager) context .getSystemService(android.content.Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); int stretchWidth; int stretchHeight; if (display == null) { stretchWidth = stretchHeight = 0; } else if (AppData.IS_KITKAT && isImmersiveModeEnabled) { DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); stretchWidth = metrics.widthPixels; stretchHeight = metrics.heightPixels; } else { stretchWidth = display.getWidth(); stretchHeight = display.getHeight(); } float aspect = 0.75f; // TODO: Handle PAL boolean isLetterboxed = ((float) stretchHeight / (float) stretchWidth) > aspect; int zoomWidth = isLetterboxed ? stretchWidth : Math.round((float) stretchHeight / aspect); int zoomHeight = isLetterboxed ? Math.round((float) stretchWidth * aspect) : stretchHeight; int cropWidth = isLetterboxed ? Math.round((float) stretchHeight / aspect) : stretchWidth; int cropHeight = isLetterboxed ? stretchHeight : Math.round((float) stretchWidth * aspect); int hResolution = getSafeInt(mPreferences, "displayResolution", 0); String scaling = mPreferences.getString("displayScaling", "zoom"); if (hResolution == 0) { // Native resolution if (scaling.equals("stretch")) { videoRenderWidth = videoSurfaceWidth = stretchWidth; videoRenderHeight = videoSurfaceHeight = stretchHeight; } else if (scaling.equals("crop")) { videoRenderWidth = videoSurfaceWidth = cropWidth; videoRenderHeight = videoSurfaceHeight = cropHeight; } else // scaling.equals( "zoom") || scaling.equals( "none" ) { videoRenderWidth = videoSurfaceWidth = zoomWidth; videoRenderHeight = videoSurfaceHeight = zoomHeight; } } else { // Non-native resolution switch (hResolution) { case 720: videoRenderWidth = 960; videoRenderHeight = 720; break; case 600: videoRenderWidth = 800; videoRenderHeight = 600; break; case 480: videoRenderWidth = 640; videoRenderHeight = 480; break; case 360: videoRenderWidth = 480; videoRenderHeight = 360; break; case 240: videoRenderWidth = 320; videoRenderHeight = 240; break; case 120: videoRenderWidth = 160; videoRenderHeight = 120; break; default: videoRenderWidth = Math.round((float) hResolution / aspect); videoRenderHeight = hResolution; break; } if (scaling.equals("zoom")) { videoSurfaceWidth = zoomWidth; videoSurfaceHeight = zoomHeight; } else if (scaling.equals("crop")) { videoSurfaceWidth = cropWidth; videoSurfaceHeight = cropHeight; } else if (scaling.equals("stretch")) { videoSurfaceWidth = stretchWidth; videoSurfaceHeight = stretchHeight; } else // scaling.equals( "none" ) { videoSurfaceWidth = videoRenderWidth; videoSurfaceHeight = videoRenderHeight; } } } }
From source file:com.BibleQuote.ui.ReaderActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP && PreferenceHelper.volumeButtonsToScroll()) || DevicesKeyCodes.KeyCodeUp(keyCode)) { vWeb.pageUp(false);// w w w .j a v a 2 s . co m viewChapterNav(); return true; } else if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && PreferenceHelper.volumeButtonsToScroll()) || DevicesKeyCodes.KeyCodeDown(keyCode)) { vWeb.pageDown(false); viewChapterNav(); return true; } else { return super.onKeyDown(keyCode, event); } }