Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ffcd088 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Add plumbing for volume mute key."

parents d4bb9b37 b0418da0
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -196846,6 +196846,17 @@
 visibility="public"
>
</field>
<field name="KEYCODE_VOLUME_MUTE"
 type="int"
 transient="false"
 volatile="false"
 value="164"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="KEYCODE_VOLUME_UP"
 type="int"
 transient="false"
@@ -245598,7 +245609,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
+21 −0
Original line number Diff line number Diff line
@@ -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) {
+13 −4
Original line number Diff line number Diff line
@@ -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.
+2 −1
Original line number Diff line number Diff line
@@ -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) {
+1 −0
Original line number Diff line number Diff line
@@ -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;
Loading