From d7cd8499e99a8c33e1140c3393001703ce008d69 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 24 Mar 2022 22:36:26 +0000 Subject: [PATCH] Make sure to update the manage button click listener after rotation The view gets recreated so the listener needs to be reapplied. Test: manual - expand bubble stack - rotate device - make sure manage button works - repeat but rather than rotate, fold / unfold Bug: 206086337 Change-Id: Iedcf39613a9696f41a4f9f11f760e4b55beb61aa --- .../android/wm/shell/bubbles/BubbleStackView.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 677c1c7d7759a..558288a7d9688 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 @@ -1139,6 +1139,7 @@ public class BubbleStackView extends FrameLayout // The menu itself should respect locale direction so the icons are on the correct side. mManageMenu.setLayoutDirection(LAYOUT_DIRECTION_LOCALE); addView(mManageMenu); + updateManageButtonListener(); } /** @@ -1311,7 +1312,6 @@ public class BubbleStackView extends FrameLayout /** Respond to the display size change by recalculating view size and location. */ public void onDisplaySizeChanged() { updateOverflow(); - setUpManageMenu(); setUpFlyout(); setUpDismissView(); updateUserEdu(); @@ -1338,6 +1338,7 @@ public class BubbleStackView extends FrameLayout if (mIsExpanded) { updateExpandedView(); } + setUpManageMenu(); } @Override @@ -2808,7 +2809,7 @@ public class BubbleStackView extends FrameLayout // a race condition with adding the BubbleExpandedView view to the expanded view // container. Due to the race condition the click handler sometimes is not set up // correctly and is never called. - bev.setManageClickListener((view) -> showManageMenu(true /* show */)); + updateManageButtonListener(); }, 0); if (!mIsExpansionAnimating) { @@ -2819,6 +2820,16 @@ public class BubbleStackView extends FrameLayout } } + private void updateManageButtonListener() { + if (mIsExpanded && mExpandedBubble != null + && mExpandedBubble.getExpandedView() != null) { + BubbleExpandedView bev = mExpandedBubble.getExpandedView(); + bev.setManageClickListener((view) -> { + showManageMenu(true /* show */); + }); + } + } + /** * Requests a snapshot from the currently expanded bubble's TaskView and displays it in a * SurfaceView. This allows us to load a newly expanded bubble's Activity into the TaskView,