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

Commit 143a535a authored by Felix Stern's avatar Felix Stern
Browse files

Dispatch correct position on update in DisplayImeController

With the changes in [1], we don't rely on the initially set position, but use the current surface position of the control. However, we didn't dispatch the adjusted position to the listeners.
This CL also fixes the seekValue when an ongoing animation was cancelled (show -> hide; hide -> show).

[1]: Ia3acf63e2a2ec7518ba5587ca44c5cede72574d4

Fix: 421000153
Test: Hide IME in lower app in split screen
Flag: EXEMPT Bugfix
Change-Id: I2709d128530dd7ae6372df3570197ed65da1f605
parent 9ef40417
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -563,7 +563,11 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            float seekValue = 0;
            if (mAnimation != null) {
                if (mAnimation.isRunning()) {
                    seekValue = (float) mAnimation.getAnimatedValue();
                    seekValue = mAnimationDirection == DIRECTION_SHOW && !show
                            // If we were showing previously (and now hiding), we need to use the
                            // inverse.
                            ? 1f - (float) mAnimation.getAnimatedValue()
                            : (float) mAnimation.getAnimatedValue();
                    seek = true;
                }
                mAnimation.cancel();
@@ -578,7 +582,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            final float endY = show ? shownY : hiddenY;
            if (mAnimationDirection == DIRECTION_NONE && mImeShowing && show) {
                // IME is already showing, so set seek to end
                seekValue = shownY;
                seekValue = 1f;
                seek = true;
            }
            mAnimationDirection = show ? DIRECTION_SHOW : DIRECTION_HIDE;
@@ -589,7 +593,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            mAnimation.setDuration(
                    show ? ANIMATION_DURATION_SHOW_MS : ANIMATION_DURATION_HIDE_MS);
            if (seek) {
                mAnimation.setCurrentFraction((seekValue - startY) / (endY - startY));
                mAnimation.setCurrentFraction(seekValue);
            } else {
                // In some cases the value in onAnimationStart is zero, therefore setting it
                // explicitly to startY
@@ -600,13 +604,12 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                SurfaceControl.Transaction t = mTransactionPool.acquire();
                final float value = (float) animation.getAnimatedValue();
                final int x = mImeSourceControl.getSurfacePosition().x;
                final int y = (int) (mImeSourceControl.getSurfacePosition().y
                        + (1f - value) * mImeFrame.height());
                final int initialY = mImeSourceControl.getSurfacePosition().y;
                final int y = (int) (initialY + (1f - value) * mImeFrame.height());
                t.setPosition(animatingLeash, x, y);
                final float alpha = (mAnimateAlpha || isFloating)
                        ? (value - hiddenY) / (shownY - hiddenY) : 1f;
                final float alpha = (mAnimateAlpha || isFloating) ? value : 1f;
                t.setAlpha(animatingLeash, alpha);
                dispatchPositionChanged(mDisplayId, imeTop(value, defaultY), t);
                dispatchPositionChanged(mDisplayId, imeTop(y, initialY), t);
                t.apply();
                mTransactionPool.release(t);
            });
@@ -638,9 +641,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                            imeTop(shownY, defaultY), mAnimationDirection == DIRECTION_SHOW,
                            isFloating, t);
                    mAnimateAlpha = (flags & ImePositionProcessor.IME_ANIMATION_NO_ALPHA) == 0;
                    final float alpha = (mAnimateAlpha || isFloating)
                            ? (value - hiddenY) / (shownY - hiddenY)
                            : 1.f;
                    final float alpha = (mAnimateAlpha || isFloating) ? value : 1f;
                    t.setAlpha(animatingLeash, alpha);
                    if (mAnimationDirection == DIRECTION_SHOW) {
                        ImeTracker.forLogging().onProgress(mStatsToken,
@@ -681,7 +682,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                        final int y = mImeSourceControl.getSurfacePosition().y
                                + (show ? 0 : mImeFrame.height());
                        t.setPosition(animatingLeash, x, y);
                        t.setAlpha(animatingLeash, 1.f);
                        t.setAlpha(animatingLeash, 1f);
                    }
                    if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) {
                        setAnimating(false /* imeAnimationOngoing */,