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

Commit 437a879a authored by Evan Rosky's avatar Evan Rosky
Browse files

Add support for floating IME to split-screen

This basically converts a floating IME into what looks like
an ime that has some small size below the bottom of the screen
so that it animates to 0.

Also added alpha for this case. Would add it for all cases,
but that doesn't work well for split-screen since it translates
windows rather than insetting them so you see black flickers.

Bug: 159459047
Test: Use an expanded-ui ime in landscape and see a shortened
      animation + fade-in.
Change-Id: Ib1da2750689a4bd4d3a3d4e9bc1e29aa8d41376c
parent d6b99a58
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -56,12 +56,14 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged

    private static final boolean DEBUG = false;

    // NOTE: All these constants came from InsetsController.
    public static final int ANIMATION_DURATION_SHOW_MS = 275;
    public static final int ANIMATION_DURATION_HIDE_MS = 340;
    public static final Interpolator INTERPOLATOR = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
    private static final int DIRECTION_NONE = 0;
    private static final int DIRECTION_SHOW = 1;
    private static final int DIRECTION_HIDE = 2;
    private static final int FLOATING_IME_BOTTOM_INSET = -80;

    SystemWindows mSystemWindows;
    final Handler mHandler;
@@ -271,8 +273,16 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            }
            // Set frame, but only if the new frame isn't empty -- this maintains continuity
            final Rect newFrame = imeSource.getFrame();
            if (newFrame.height() != 0) {
            mImeFrame.set(newFrame);
            final boolean isFloating = newFrame.height() == 0;
            if (isFloating) {
                // This is likely a "floating" or "expanded" IME, so to get animations, just
                // pretend the ime has some size just below the screen.
                mImeFrame.set(newFrame);
                final int floatingInset = (int) (
                        mSystemWindows.mDisplayController.getDisplayLayout(mDisplayId).density()
                                * FLOATING_IME_BOTTOM_INSET);
                mImeFrame.bottom -= floatingInset;
            }
            if (DEBUG) {
                Slog.d(TAG, "Run startAnim  show:" + show + "  was:"
@@ -316,6 +326,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                SurfaceControl.Transaction t = mTransactionPool.acquire();
                float value = (float) animation.getAnimatedValue();
                t.setPosition(mImeSourceControl.getLeash(), x, value);
                final float alpha = isFloating ? (value - hiddenY) / (shownY - hiddenY) : 1.f;
                t.setAlpha(mImeSourceControl.getLeash(), alpha);
                dispatchPositionChanged(mDisplayId, imeTop(value), t);
                t.apply();
                mTransactionPool.release(t);
@@ -327,6 +339,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                public void onAnimationStart(Animator animation) {
                    SurfaceControl.Transaction t = mTransactionPool.acquire();
                    t.setPosition(mImeSourceControl.getLeash(), x, startY);
                    final float alpha = isFloating ? (startY - hiddenY) / (shownY - hiddenY) : 1.f;
                    t.setAlpha(mImeSourceControl.getLeash(), alpha);
                    if (DEBUG) {
                        Slog.d(TAG, "onAnimationStart d:" + mDisplayId + " top:"
                                + imeTop(hiddenY) + "->" + imeTop(shownY)
@@ -351,6 +365,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                    SurfaceControl.Transaction t = mTransactionPool.acquire();
                    if (!mCancelled) {
                        t.setPosition(mImeSourceControl.getLeash(), x, endY);
                        t.setAlpha(mImeSourceControl.getLeash(), 1.f);
                    }
                    dispatchEndPositioning(mDisplayId, mCancelled, t);
                    if (mAnimationDirection == DIRECTION_HIDE && !mCancelled) {