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

Commit c9c97a94 authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

Merge "Fix unnecessary slide-up movement for IME in flex split" into main

parents 1d8acf75 04618610
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -1543,11 +1543,28 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            }
        }

        /**
         * When IME is triggered on the bottom app in split screen, we want to translate the bottom
         * app up by a certain amount so that it's not covered too much by the IME. But there's also
         * an upper limit to the amount we want to translate (since we still need some of the top
         * app to be visible too). So this function essentially says "try to translate the bottom
         * app up, but stop before you make the top app too small."
         */
        private int getTargetYOffset() {
            final int desireOffset = Math.abs(mEndImeTop - mStartImeTop);
            // Make sure to keep at least 30% visible for the top split.
            final int maxOffset = (int) (getTopLeftBounds().height() * ADJUSTED_SPLIT_FRACTION_MAX);
            return -Math.min(desireOffset, maxOffset);
            // We want to translate up the bottom app by this amount.
            final int desiredOffset = Math.abs(mEndImeTop - mStartImeTop);

            // But we also want to keep this much of the top app visible.
            final float amountOfTopAppToKeepVisible =
                    getTopLeftBounds().height() * (1 - ADJUSTED_SPLIT_FRACTION_MAX);

            // So the current onscreen size of the top app, minus the minimum size, is the max
            // translation we will allow.
            final float currentOnScreenSizeOfTopApp = getTopLeftBounds().bottom;
            final int maxOffset =
                    (int) Math.max(currentOnScreenSizeOfTopApp - amountOfTopAppToKeepVisible, 0);

            return -Math.min(desiredOffset, maxOffset);
        }

        @SplitPosition