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

Commit 021ef967 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-dev am: a2e448b2

parents 2a6a20b6 a2e448b2
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 ((keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE)
                && event.isTracking()
                && !event.isCanceled()
                && !WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)) {
                && (!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.
     *