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

Commit 9a7f97aa authored by Josep del Río's avatar Josep del Río Committed by Android (Google) Code Review
Browse files

Merge "Finish certain activities when using Escape" into udc-qpr-dev

parents 9b6cc3a0 da2311c8
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -3882,7 +3882,9 @@ public class Activity extends ContextThemeWrapper
     * it will set up the dispatch to call {@link #onKeyUp} where the action
     * will be performed; for earlier applications, it will perform the
     * action immediately in on-down, as those versions of the platform
     * behaved.
     * behaved. This implementation will also take care of {@link KeyEvent#KEYCODE_ESCAPE}
     * by finishing the activity if it would be closed by touching outside
     * of it.
     *
     * <p>Other additional default key handling may be performed
     * if configured with {@link #setDefaultKeyMode}.
@@ -3904,6 +3906,11 @@ public class Activity extends ContextThemeWrapper
            return true;
        }

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

        if (mDefaultKeyMode == DEFAULT_KEYS_DISABLE) {
            return false;
        } else if (mDefaultKeyMode == DEFAULT_KEYS_SHORTCUT) {
@@ -3999,6 +4006,15 @@ public class Activity extends ContextThemeWrapper
                return true;
            }
        }

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

        return false;
    }

+5 −0
Original line number Diff line number Diff line
@@ -1481,6 +1481,11 @@ public abstract class Window {
        }
    }

    /** @hide */
    public boolean shouldCloseOnTouchOutside() {
        return mCloseOnTouchOutside;
    }

    /** @hide */
    @SuppressWarnings("HiddenAbstractMethod")
    @UnsupportedAppUsage