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

Commit 24fb8168 authored by Michael Bestas's avatar Michael Bestas Committed by Steve Kondik
Browse files

Map long press of MUTE to KEYCODE_MEDIA_PLAY_PAUSE

Change-Id: I5f416565c3a9b5a16f9ba0bf5c20ae3f6029ea77
parent 2a164283
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -5107,13 +5107,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    boolean mayChangeVolume = false;

                    if (isMusicActive()) {
                        if (mVolBtnMusicControls && (keyCode != KeyEvent.KEYCODE_VOLUME_MUTE)) {
                        if (mVolBtnMusicControls) {
                            // Detect long key presses.
                            if (down) {
                                mIsLongPress = false;
                                // TODO: Long press of MUTE could be mapped to KEYCODE_MEDIA_PLAY_PAUSE
                                int newKeyCode = event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP ?
                                        KeyEvent.KEYCODE_MEDIA_NEXT : KeyEvent.KEYCODE_MEDIA_PREVIOUS;
                                // Map MUTE key to MEDIA_PLAY_PAUSE
                                int newKeyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE;
                                switch (keyCode) {
                                    case KeyEvent.KEYCODE_VOLUME_DOWN:
                                        newKeyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS;
                                        break;
                                    case KeyEvent.KEYCODE_VOLUME_UP:
                                        newKeyCode = KeyEvent.KEYCODE_MEDIA_NEXT;
                                        break;
                                }
                                scheduleLongPressKeyEvent(event, newKeyCode);
                                // Consume key down events of all presses.
                                break;