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

Commit 98c094c2 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Fix IME not dismissed with back gesture" into main

parents 70657ee8 33a2865b
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
    static final int RESULT_CODE_UNREGISTER = 1;
    @NonNull
    private final ResultReceiver mResultReceiver;
    // The handler to run callbacks on. This should be on the same thread
    // the ViewRootImpl holding IME's WindowOnBackInvokedDispatcher is created on.
    private Handler mHandler;

    public ImeOnBackInvokedDispatcher(Handler handler) {
        mResultReceiver = new ResultReceiver(handler) {
@@ -68,6 +71,10 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
        };
    }

    void setHandler(@NonNull Handler handler) {
        mHandler = handler;
    }

    /**
     * Override this method to return the {@link WindowOnBackInvokedDispatcher} of the window
     * that should receive the forwarded callback.
@@ -326,7 +333,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

        @Override
        public void onBackInvoked() {
            mCallback.onBackInvoked();
            mHandler.post(mCallback::onBackInvoked);
        }

        @Override
@@ -336,7 +343,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

        private void maybeRunOnAnimationCallback(Consumer<OnBackAnimationCallback> block) {
            if (mCallback instanceof OnBackAnimationCallback) {
                block.accept((OnBackAnimationCallback) mCallback);
                mHandler.post(() -> block.accept((OnBackAnimationCallback) mCallback));
            }
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -550,6 +550,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
    public void setImeOnBackInvokedDispatcher(
            @NonNull ImeOnBackInvokedDispatcher imeDispatcher) {
        mImeDispatcher = imeDispatcher;
        mImeDispatcher.setHandler(mHandler);
    }

    /** Returns true if a non-null {@link ImeOnBackInvokedDispatcher} has been set. **/