From 49b3cc5bd497f20b17b34f6b2c49c909f1cf0f70 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Fri, 14 May 2021 15:43:19 +0800 Subject: [PATCH] Fix not releasing touching state of the handle on divider bar After ag/14340443, the touching state of divider handle won't be reset after tapping on divider bar. This makes sure to reset touching state whenever received cancel/up touch event. Bug: 186626153 Test: atest WMShellUnitTests Test: check the touching of the handle on divider bar will be reset after single tapping on divider bar. Change-Id: I8645d17cda8833aa75b108f863e48655a7c87feb --- .../com/android/wm/shell/common/split/DividerView.java | 3 +-- .../android/wm/shell/legacysplitscreen/DividerView.java | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) 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 442e7a4c6796c..0e4746cba2bee 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 @@ -139,11 +139,10 @@ public class DividerView extends FrameLayout implements View.OnTouchListener, break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: - mVelocityTracker.addMovement(event); releaseTouching(); - if (!mMoving) break; + mVelocityTracker.addMovement(event); mVelocityTracker.computeCurrentVelocity(1000 /* units */); final float velocity = isLandscape ? mVelocityTracker.getXVelocity() diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/DividerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/DividerView.java index 60f7ee2941e25..abeb58c851bfd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/DividerView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/DividerView.java @@ -521,12 +521,14 @@ public class DividerView extends FrameLayout implements OnTouchListener, break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: - mVelocityTracker.addMovement(event); - - if (!mMoving) break; + if (!mMoving) { + stopDragging(); + break; + } x = (int) event.getRawX(); y = (int) event.getRawY(); + mVelocityTracker.addMovement(event); mVelocityTracker.computeCurrentVelocity(1000); int position = calculatePosition(x, y); stopDragging(position, isHorizontalDivision() ? mVelocityTracker.getYVelocity()