diff options
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java index 720e8e53b218..b7867d0b81b5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java @@ -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 |