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

Commit 1b73a94f authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Automerger Merge Worker
Browse files

Merge "Do not register OnBackInvokedCallback for SoftInputWindow." into udc-qpr-dev am: 716fdd09

parents 6f435412 716fdd09
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -454,12 +454,11 @@ public class Dialog implements DialogInterface, Window.Callback,
     */
    protected void onStart() {
        if (mActionBar != null) mActionBar.setShowHideAnimationEnabled(true);
        if (mContext != null
        if (allowsRegisterDefaultOnBackInvokedCallback() && mContext != null
                && WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)) {
            // Add onBackPressed as default back behavior.
            mDefaultBackCallback = this::onBackPressed;
            getOnBackInvokedDispatcher().registerSystemOnBackInvokedCallback(mDefaultBackCallback);
            mDefaultBackCallback = null;
        }
    }

@@ -470,9 +469,18 @@ public class Dialog implements DialogInterface, Window.Callback,
        if (mActionBar != null) mActionBar.setShowHideAnimationEnabled(false);
        if (mDefaultBackCallback != null) {
            getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback(mDefaultBackCallback);
            mDefaultBackCallback = null;
        }
    }

    /**
     * Whether this dialog allows to register the default onBackInvokedCallback.
     * @hide
     */
    protected boolean allowsRegisterDefaultOnBackInvokedCallback() {
        return true;
    }

    private static final String DIALOG_SHOWING_TAG = "android:dialogShowing";
    private static final String DIALOG_HIERARCHY_TAG = "android:dialogHierarchy";

@@ -697,7 +705,8 @@ public class Dialog implements DialogInterface, Window.Callback,
        if (event.isTracking() && !event.isCanceled()) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_BACK:
                    if (!WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)) {
                    if (!WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)
                            || !allowsRegisterDefaultOnBackInvokedCallback()) {
                        onBackPressed();
                        return true;
                    }
+7 −0
Original line number Diff line number Diff line
@@ -79,6 +79,13 @@ final class SoftInputWindow extends Dialog {
    @WindowState
    private int mWindowState = WindowState.TOKEN_PENDING;

    @Override
    protected boolean allowsRegisterDefaultOnBackInvokedCallback() {
        // Do not register OnBackInvokedCallback from Dialog#onStart, InputMethodService will
        // register CompatOnBackInvokedCallback for input method window.
        return false;
    }

    /**
     * Set {@link IBinder} window token to the window.
     *