summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ats Jenk <atsjenk@google.com> 2024-05-09 23:38:07 +0000
committer Ats Jenk <atsjenk@google.com> 2024-05-15 09:58:40 -0700
commit8621f65826bf5ef9fd72ea670dc8af9611dfbc4a (patch)
tree720bf1077bbb92421823c679fd00e5eaebc7ca51
parentf16e8ea2862decfaae13aaf51b9537f23844e847 (diff)
Always collapse expanded view when dragging a bubble from bubble bar
Previously we only collapsed the expanded view when the expanded bubble was being dragged. This caused issues with the bubble bar reposition logic. The expanded view got detached from the the bubble bar when the bar moved to the other side. Update the drag logic to always collapse the expanded view when any bubble is dragged. When drag stops, expand the previously expanded bubble again. Bug: 330585402 Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT Test: atest BubblesTest Test: check that expanded bubble collapses during drag - have 2 bubbles in the bubble bar (A, B) - select and expand bubble A - start dragging bubble B - bubble A should collapse - release bubble B - bubble A should expand again Test: check that selected bubble expands after a bubble is dismissed - have 2 bubbles in the bubble bar (A, B) - select and expand bubble A - dismiss bubble B by dragging it to dismiss target - bubble A should expand Change-Id: I5fc47461c1e857073c260c146f924fb444b39e45
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java45
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java12
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java108
4 files changed, 144 insertions, 25 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index 9e6c5fbf9f5e..40658709cdf9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -1170,7 +1170,9 @@ public class BubbleController implements ConfigurationChangeListener,
* @param bubbleKey key of the bubble being dragged
*/
public void startBubbleDrag(String bubbleKey) {
- onBubbleDrag(bubbleKey, true /* isBeingDragged */);
+ if (mBubbleData.getSelectedBubble() != null) {
+ mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ false);
+ }
if (mBubbleStateListener != null) {
boolean overflow = BubbleOverflow.KEY.equals(bubbleKey);
Rect rect = new Rect();
@@ -1183,23 +1185,29 @@ public class BubbleController implements ConfigurationChangeListener,
}
/**
- * A bubble is no longer being dragged in Launcher. As was released in given location.
+ * A bubble is no longer being dragged in Launcher. And was released in given location.
* Will be called only when bubble bar is expanded.
*
- * @param bubbleKey key of the bubble being dragged
* @param location location where bubble was released
*/
- public void stopBubbleDrag(String bubbleKey, BubbleBarLocation location) {
+ public void stopBubbleDrag(BubbleBarLocation location) {
mBubblePositioner.setBubbleBarLocation(location);
- onBubbleDrag(bubbleKey, false /* isBeingDragged */);
+ if (mBubbleData.getSelectedBubble() != null) {
+ mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ true);
+ }
}
- private void onBubbleDrag(String bubbleKey, boolean isBeingDragged) {
- // TODO(b/330585402): collapse stack if any bubble is dragged
- if (mBubbleData.getSelectedBubble() != null
- && mBubbleData.getSelectedBubble().getKey().equals(bubbleKey)) {
- // Should collapse/expand only if equals to selected bubble.
- mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ !isBeingDragged);
+ /**
+ * A bubble was dragged and is released in dismiss target in Launcher.
+ *
+ * @param bubbleKey key of the bubble being dragged to dismiss target
+ */
+ public void dragBubbleToDismiss(String bubbleKey) {
+ String selectedBubbleKey = mBubbleData.getSelectedBubbleKey();
+ removeBubble(bubbleKey, Bubbles.DISMISS_USER_GESTURE);
+ if (selectedBubbleKey != null && !selectedBubbleKey.equals(bubbleKey)) {
+ // We did not remove the selected bubble. Expand it again
+ mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ true);
}
}
@@ -2358,12 +2366,6 @@ public class BubbleController implements ConfigurationChangeListener,
}
@Override
- public void removeBubble(String key) {
- mMainExecutor.execute(
- () -> mController.removeBubble(key, Bubbles.DISMISS_USER_GESTURE));
- }
-
- @Override
public void removeAllBubbles() {
mMainExecutor.execute(() -> mController.removeAllBubbles(Bubbles.DISMISS_USER_GESTURE));
}
@@ -2379,8 +2381,13 @@ public class BubbleController implements ConfigurationChangeListener,
}
@Override
- public void stopBubbleDrag(String bubbleKey, BubbleBarLocation location) {
- mMainExecutor.execute(() -> mController.stopBubbleDrag(bubbleKey, location));
+ public void stopBubbleDrag(BubbleBarLocation location) {
+ mMainExecutor.execute(() -> mController.stopBubbleDrag(location));
+ }
+
+ @Override
+ public void dragBubbleToDismiss(String key) {
+ mMainExecutor.execute(() -> mController.dragBubbleToDismiss(key));
}
@Override
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
index ea30af5c3d5a..26483c8428c6 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
@@ -327,6 +327,14 @@ public class BubbleData {
return mSelectedBubble;
}
+ /**
+ * Returns the key of the selected bubble, or null if no bubble is selected.
+ */
+ @Nullable
+ public String getSelectedBubbleKey() {
+ return mSelectedBubble != null ? mSelectedBubble.getKey() : null;
+ }
+
public BubbleOverflow getOverflow() {
return mOverflow;
}
@@ -1228,9 +1236,7 @@ public class BubbleData {
public void dump(PrintWriter pw) {
pw.println("BubbleData state:");
pw.print(" selected: ");
- pw.println(mSelectedBubble != null
- ? mSelectedBubble.getKey()
- : "null");
+ pw.println(getSelectedBubbleKey());
pw.print(" expanded: ");
pw.println(mExpanded);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl
index 66f77fa6f76d..1eff149f2e91 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl
@@ -33,7 +33,7 @@ interface IBubbles {
oneway void showBubble(in String key, in Rect bubbleBarBounds) = 3;
- oneway void removeBubble(in String key) = 4;
+ oneway void dragBubbleToDismiss(in String key) = 4;
oneway void removeAllBubbles() = 5;
@@ -47,5 +47,5 @@ interface IBubbles {
oneway void setBubbleBarBounds(in Rect bubbleBarBounds) = 10;
- oneway void stopBubbleDrag(in String key, in BubbleBarLocation location) = 11;
+ oneway void stopBubbleDrag(in BubbleBarLocation location) = 11;
} \ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index 56e5e293c799..df781108cf79 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -27,6 +27,7 @@ import static android.service.notification.NotificationListenerService.REASON_GR
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.server.notification.Flags.FLAG_SCREENSHARE_NOTIFICATION_HIDING;
+import static com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR;
import static com.google.common.truth.Truth.assertThat;
@@ -138,7 +139,6 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
-import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -2142,6 +2142,112 @@ public class BubblesTest extends SysuiTestCase {
assertThat(mBubbleController.getLayerView().isExpanded()).isFalse();
}
+ @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
+ @Test
+ public void dragBubbleBarBubble_selectedBubble_expandedViewCollapsesDuringDrag() {
+ mBubbleProperties.mIsBubbleBarEnabled = true;
+ mPositioner.setIsLargeScreen(true);
+ FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
+ mBubbleController.registerBubbleStateListener(bubbleStateListener);
+
+ // Add 2 bubbles
+ mEntryListener.onEntryAdded(mRow);
+ mEntryListener.onEntryAdded(mRow2);
+ mBubbleController.updateBubble(mBubbleEntry);
+ mBubbleController.updateBubble(mBubbleEntry2);
+
+ // Select first bubble
+ mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect());
+ assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
+
+ // Drag first bubble, bubble should collapse
+ mBubbleController.startBubbleDrag(mBubbleEntry.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isFalse();
+
+ // Stop dragging, first bubble should be expanded
+ mBubbleController.stopBubbleDrag(BubbleBarLocation.LEFT);
+ assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
+ }
+
+ @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
+ @Test
+ public void dragBubbleBarBubble_unselectedBubble_expandedViewCollapsesDuringDrag() {
+ mBubbleProperties.mIsBubbleBarEnabled = true;
+ mPositioner.setIsLargeScreen(true);
+ FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
+ mBubbleController.registerBubbleStateListener(bubbleStateListener);
+
+ // Add 2 bubbles
+ mEntryListener.onEntryAdded(mRow);
+ mEntryListener.onEntryAdded(mRow2);
+ mBubbleController.updateBubble(mBubbleEntry);
+ mBubbleController.updateBubble(mBubbleEntry2);
+
+ // Select first bubble
+ mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect());
+ assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
+
+ // Drag second bubble, bubble should collapse
+ mBubbleController.startBubbleDrag(mBubbleEntry2.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isFalse();
+
+ // Stop dragging, first bubble should be expanded
+ mBubbleController.stopBubbleDrag(BubbleBarLocation.LEFT);
+ assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
+ }
+
+ @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
+ @Test
+ public void dismissBubbleBarBubble_selected_selectsAndExpandsNext() {
+ mBubbleProperties.mIsBubbleBarEnabled = true;
+ mPositioner.setIsLargeScreen(true);
+ FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
+ mBubbleController.registerBubbleStateListener(bubbleStateListener);
+
+ // Add 2 bubbles
+ mEntryListener.onEntryAdded(mRow);
+ mEntryListener.onEntryAdded(mRow2);
+ mBubbleController.updateBubble(mBubbleEntry);
+ mBubbleController.updateBubble(mBubbleEntry2);
+
+ // Select first bubble
+ mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect());
+ // Drag first bubble to dismiss
+ mBubbleController.startBubbleDrag(mBubbleEntry.getKey());
+ mBubbleController.dragBubbleToDismiss(mBubbleEntry.getKey());
+ // Second bubble is selected and expanded
+ assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry2.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
+ }
+
+ @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
+ @Test
+ public void dismissBubbleBarBubble_unselected_selectionDoesNotChange() {
+ mBubbleProperties.mIsBubbleBarEnabled = true;
+ mPositioner.setIsLargeScreen(true);
+ FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
+ mBubbleController.registerBubbleStateListener(bubbleStateListener);
+
+ // Add 2 bubbles
+ mEntryListener.onEntryAdded(mRow);
+ mEntryListener.onEntryAdded(mRow2);
+ mBubbleController.updateBubble(mBubbleEntry);
+ mBubbleController.updateBubble(mBubbleEntry2);
+
+ // Select first bubble
+ mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect());
+ // Drag second bubble to dismiss
+ mBubbleController.startBubbleDrag(mBubbleEntry2.getKey());
+ mBubbleController.dragBubbleToDismiss(mBubbleEntry2.getKey());
+ // First bubble remains selected and expanded
+ assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey());
+ assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
+ }
+
@DisableFlags(FLAG_SCREENSHARE_NOTIFICATION_HIDING)
@Test
public void doesNotRegisterSensitiveStateListener() {