From 37632bb6e489f3a96d3643b8a9ba598a6c8c5f14 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Fri, 4 Jun 2021 10:44:36 -0700 Subject: [PATCH] Collapse the stack on clicks rather than on down Fixes an issue where you'd collapse the bubble accidentally when performing back gesture in the padding around the expanded view. This means things will hide 'on up' rather than 'on down' but I think that's fine / more expected behavior. Removed some old code. Test: manual - expand the bubble stack, open a 2nd activity in the bubble, perform gesture back => 2nd activity goes away & the bubble doesn't collapse Bug: 190102948 Change-Id: I016bd9b3091938974f3330f4d005d4ef6bcccfee --- .../wm/shell/bubbles/BubbleExpandedView.java | 21 ------------------ .../wm/shell/bubbles/BubbleStackView.java | 22 ++++++++----------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index b674c68b2490c..f81f086e598f5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -290,27 +290,6 @@ public class BubbleExpandedView extends LinearLayout { applyThemeAttrs(); setClipToPadding(false); - setOnTouchListener((view, motionEvent) -> { - if (mTaskView == null) { - return false; - } - - final Rect avBounds = new Rect(); - mTaskView.getBoundsOnScreen(avBounds); - - // Consume and ignore events on the expanded view padding that are within the - // ActivityView's vertical bounds. These events are part of a back gesture, and so they - // should not collapse the stack (which all other touches on areas around the AV would - // do). - if (motionEvent.getRawY() >= avBounds.top - && motionEvent.getRawY() <= avBounds.bottom - && (motionEvent.getRawX() < avBounds.left - || motionEvent.getRawX() > avBounds.right)) { - return true; - } - - return false; - }); // BubbleStackView is forced LTR, but we want to respect the locale for expanded view layout // so the Manage button appears on the right. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 7e48a7e139200..f6be4ecdcfcaf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -932,20 +932,16 @@ public class BubbleStackView extends FrameLayout } }); - // If the stack itself is touched, it means none of its touchable views (bubbles, flyouts, - // ActivityViews, etc.) were touched. Collapse the stack if it's expanded. - setOnTouchListener((view, ev) -> { - if (ev.getAction() == MotionEvent.ACTION_DOWN) { - if (mShowingManage) { - showManageMenu(false /* show */); - } else if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { - mStackEduView.hide(false); - } else if (mBubbleData.isExpanded()) { - mBubbleData.setExpanded(false); - } + // If the stack itself is clicked, it means none of its touchable views (bubbles, flyouts, + // TaskView, etc.) were touched. Collapse the stack if it's expanded. + setOnClickListener(view -> { + if (mShowingManage) { + showManageMenu(false /* show */); + } else if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { + mStackEduView.hide(false); + } else if (mBubbleData.isExpanded()) { + mBubbleData.setExpanded(false); } - - return true; }); animate()