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

Commit 4601313a authored by Josep del Rio's avatar Josep del Rio Committed by Josep del Río
Browse files

Close dialogs and activity on Escape down

Currently closing dialogs and activities that look like dialogs
requires the user to release the Escape key, that is, the up
event; applying the action on the down event will increase
responsiveness.

Bug: 324221986
Test: Tested on Google Play voice search, and private DNS dialog
in the Settings app.

Change-Id: Ie1fd3a47955e0c693f9b5eaa6ba788a57e8973ed
parent c2471884
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -3927,6 +3927,7 @@ public class Activity extends ContextThemeWrapper

        if (keyCode == KeyEvent.KEYCODE_ESCAPE && mWindow.shouldCloseOnTouchOutside()) {
            event.startTracking();
            finish();
            return true;
        }

@@ -4027,10 +4028,7 @@ public class Activity extends ContextThemeWrapper
        }

        if (keyCode == KeyEvent.KEYCODE_ESCAPE
                && mWindow.shouldCloseOnTouchOutside()
                && event.isTracking()
                && !event.isCanceled()) {
            finish();
                && event.isTracking()) {
            return true;
        }

+10 −6
Original line number Diff line number Diff line
@@ -672,7 +672,16 @@ public class Dialog implements DialogInterface, Window.Callback,
     */
    @Override
    public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            event.startTracking();
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_ESCAPE) {
            if (mCancelable) {
                cancel();
            } else {
                dismiss();
            }
            event.startTracking();
            return true;
        }
@@ -712,11 +721,6 @@ public class Dialog implements DialogInterface, Window.Callback,
                    }
                    break;
                case KeyEvent.KEYCODE_ESCAPE:
                    if (mCancelable) {
                        cancel();
                    } else {
                        dismiss();
                    }
                    return true;
            }
        }