diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/preference/VolumePreference.java | 21 | ||||
-rwxr-xr-x | core/java/android/view/KeyEvent.java | 17 | ||||
-rw-r--r-- | core/java/android/widget/MediaController.java | 3 | ||||
-rw-r--r-- | core/java/android/widget/VideoView.java | 1 |
4 files changed, 37 insertions, 5 deletions
diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java index 970d520..66c9ba1 100644 --- a/core/java/android/preference/VolumePreference.java +++ b/core/java/android/preference/VolumePreference.java @@ -92,6 +92,11 @@ public class VolumePreference extends SeekBarPreference implements mSeekBarVolumizer.changeVolumeBy(1); } return true; + case KeyEvent.KEYCODE_VOLUME_MUTE: + if (isdown) { + mSeekBarVolumizer.muteVolume(); + } + return true; default: return false; } @@ -225,6 +230,7 @@ public class VolumePreference extends SeekBarPreference implements private int mLastProgress = -1; private SeekBar mSeekBar; + private int mVolumeBeforeMute = -1; private ContentObserver mVolumeObserver = new ContentObserver(mHandler) { @Override @@ -336,6 +342,21 @@ public class VolumePreference extends SeekBarPreference implements sample(); } postSetVolume(mSeekBar.getProgress()); + mVolumeBeforeMute = -1; + } + + public void muteVolume() { + if (mVolumeBeforeMute != -1) { + mSeekBar.setProgress(mVolumeBeforeMute); + sample(); + postSetVolume(mVolumeBeforeMute); + mVolumeBeforeMute = -1; + } else { + mVolumeBeforeMute = mSeekBar.getProgress(); + mSeekBar.setProgress(0); + stopSample(); + postSetVolume(0); + } } public void onSaveInstanceState(VolumeStore volumeStore) { diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 0e75682..04c331f 100755 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -125,9 +125,11 @@ public class KeyEvent extends InputEvent implements Parcelable { /** Key code constant: Directional Pad Center key. * May also be synthesized from trackball motions. */ public static final int KEYCODE_DPAD_CENTER = 23; - /** Key code constant: Volume Up key. */ + /** Key code constant: Volume Up key. + * Adjusts the speaker volume up. */ public static final int KEYCODE_VOLUME_UP = 24; - /** Key code constant: Volume Down key. */ + /** Key code constant: Volume Down key. + * Adjusts the speaker volume down. */ public static final int KEYCODE_VOLUME_DOWN = 25; /** Key code constant: Power key. */ public static final int KEYCODE_POWER = 26; @@ -269,7 +271,8 @@ public class KeyEvent extends InputEvent implements Parcelable { public static final int KEYCODE_MEDIA_REWIND = 89; /** Key code constant: Fast Forward media key. */ public static final int KEYCODE_MEDIA_FAST_FORWARD = 90; - /** Key code constant: Mute key. */ + /** Key code constant: Mute key. + * Mutes the microphone, unlike {@link #KEYCODE_VOLUME_MUTE}. */ public static final int KEYCODE_MUTE = 91; /** Key code constant: Page Up key. */ public static final int KEYCODE_PAGE_UP = 92; @@ -455,8 +458,13 @@ public class KeyEvent extends InputEvent implements Parcelable { public static final int KEYCODE_NUMPAD_LEFT_PAREN = 162; /** Key code constant: Numeric keypad ')' key. */ public static final int KEYCODE_NUMPAD_RIGHT_PAREN = 163; + /** Key code constant: Volume Mute key. + * Mutes the speaker, unlike {@link #KEYCODE_MUTE}. + * This key should normally be implemented as a toggle such that the first press + * mutes the speaker and the second press restores the original volume. */ + public static final int KEYCODE_VOLUME_MUTE = 164; - private static final int LAST_KEYCODE = KEYCODE_NUMPAD_RIGHT_PAREN; + private static final int LAST_KEYCODE = KEYCODE_VOLUME_MUTE; // NOTE: If you add a new keycode here you must also add it to: // isSystem() @@ -640,6 +648,7 @@ public class KeyEvent extends InputEvent implements Parcelable { "KEYCODE_NUMPAD_EQUALS", "KEYCODE_NUMPAD_LEFT_PAREN", "KEYCODE_NUMPAD_RIGHT_PAREN", + "KEYCODE_VOLUME_MUTE", }; // Symbolic names of all metakeys in bit order from least significant to most significant. diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java index be1234d..27a6ad3 100644 --- a/core/java/android/widget/MediaController.java +++ b/core/java/android/widget/MediaController.java @@ -442,7 +442,8 @@ public class MediaController extends FrameLayout { } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN - || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { + || keyCode == KeyEvent.KEYCODE_VOLUME_UP + || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) { // don't show the controls for volume adjustment return super.dispatchKeyEvent(event); } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index 2be7bca..ec31dd4 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -515,6 +515,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && + keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL; |