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

Commit 798f9846 authored by Felix Stern's avatar Felix Stern
Browse files

Fix IME show delay when having a RemoteInsetsControlTarget

With the refactor in [1] and [2], the IME did not appear immediately when having a controlTarget that is not the app, but with 1-2s delay.
The IME leash is only dispatched when it is successfully drawn. To set that state, it has to be serverVisible and clientVisible. Before, we did not set the mClientVisible in the ImeInsetsSourceProvider.
By setting the clientVisibility directly (based on the requestedVisibility of the app for the IME), there will be no more delay.

[1]: I8e3a74ee579f085cb582040fdba725e7a63d6b85
[2]: I5aeb3ccfbfe7d4cd0b7b5f0e0400769e65bb70a4

Test: manual: Open Bubbles and try to show the IME. Verify that there is no noticeable delay between focussing and when the IME appears.
Flag: android.view.inputmethod.refactor_insets_controller
Fix: 362478040
Change-Id: I2d37f74a16205f6a75a2fa035b91641fc5246077
parent 617f5961
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -403,6 +403,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                // activity A is focussed), we will not get a call of #insetsControlChanged, and
                // therefore have to start the show animation from here
                startAnimation(mImeRequestedVisible /* show */, false /* forceRestart */);

                setVisibleDirectly(mImeRequestedVisible || mAnimation != null);
            }
        }

@@ -540,6 +542,10 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                    show ? ANIMATION_DURATION_SHOW_MS : ANIMATION_DURATION_HIDE_MS);
            if (seek) {
                mAnimation.setCurrentFraction((seekValue - startY) / (endY - startY));
            } else {
                // In some cases the value in onAnimationStart is zero, therefore setting it
                // explicitly to startY
                mAnimation.setCurrentFraction(0);
            }

            mAnimation.addUpdateListener(animation -> {
@@ -621,6 +627,9 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                                ImeTracker.PHASE_WM_ANIMATION_RUNNING);
                        t.hide(animatingLeash);
                        removeImeSurface(mDisplayId);
                        if (android.view.inputmethod.Flags.refactorInsetsController()) {
                            setVisibleDirectly(false /* visible */);
                        }
                        ImeTracker.forLogging().onHidden(mStatsToken);
                    } else if (mAnimationDirection == DIRECTION_SHOW && !mCancelled) {
                        ImeTracker.forLogging().onShown(mStatsToken);
@@ -645,13 +654,13 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                    animatingControl.release(SurfaceControl::release);
                }
            });
            if (!show) {
            if (!android.view.inputmethod.Flags.refactorInsetsController() && !show) {
                // When going away, queue up insets change first, otherwise any bounds changes
                // can have a "flicker" of ime-provided insets.
                setVisibleDirectly(false /* visible */);
            }
            mAnimation.start();
            if (show) {
            if (!android.view.inputmethod.Flags.refactorInsetsController() && show) {
                // When showing away, queue up insets change last, otherwise any bounds changes
                // can have a "flicker" of ime-provided insets.
                setVisibleDirectly(true /* visible */);