From 406911324b94d02823785959739796841537a2de Mon Sep 17 00:00:00 2001 From: Chilun Huang Date: Fri, 11 Nov 2022 15:41:30 +0800 Subject: [PATCH] Cancel divider dragging if IME showing Cancel divider dragging if IME showing to avoid abnormal state. Bug: 256180001 Test: atest WMShellUnitTests Change-Id: I184f3275a326ba5abe965f50217f07e27ee2f527 --- .../android/wm/shell/common/split/DividerView.java | 11 +++++++++++ .../android/wm/shell/common/split/SplitLayout.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java index 1474754fc7f73..e8b0f02653945 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerView.java @@ -76,6 +76,7 @@ public class DividerView extends FrameLayout implements View.OnTouchListener { private GestureDetector mDoubleTapDetector; private boolean mInteractive; private boolean mSetTouchRegion = true; + private int mLastDraggingPosition; /** * Tracks divider bar visible bounds in screen-based coordination. Used to calculate with @@ -298,6 +299,7 @@ public class DividerView extends FrameLayout implements View.OnTouchListener { } if (mMoving) { final int position = mSplitLayout.getDividePosition() + touchPos - mStartPos; + mLastDraggingPosition = position; mSplitLayout.updateDivideBounds(position); } break; @@ -372,6 +374,15 @@ public class DividerView extends FrameLayout implements View.OnTouchListener { "Set divider bar %s from %s", interactive ? "interactive" : "non-interactive", from); mInteractive = interactive; + if (!mInteractive && mMoving) { + final int position = mSplitLayout.getDividePosition(); + mSplitLayout.flingDividePosition( + mLastDraggingPosition, + position, + mSplitLayout.FLING_RESIZE_DURATION, + () -> mSplitLayout.setDividePosition(position, true /* applyLayoutChange */)); + mMoving = false; + } releaseTouching(); mHandle.setVisibility(mInteractive ? View.VISIBLE : View.INVISIBLE); } 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 ec9e6f7573bf0..ae496165028f5 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 @@ -81,7 +81,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange public static final int PARALLAX_DISMISSING = 1; public static final int PARALLAX_ALIGN_CENTER = 2; - private static final int FLING_RESIZE_DURATION = 250; + public static final int FLING_RESIZE_DURATION = 250; private static final int FLING_SWITCH_DURATION = 350; private static final int FLING_ENTER_DURATION = 450; private static final int FLING_EXIT_DURATION = 450;