Bubble bar drag to dismiss

* Added dismiss view to the taskbar
* Bubble drag to dismiss of:
  * A single bubble when the bubble bar stack is expanded
  * All bubbles when the bubble bar stack is colapsed
* Added dismiss related calls to WMShell in SystemUI through SystemUIProxy

Bug: 271466616
Test: manual, TBD
Flag: WM_BUBBLE_BAR
Change-Id: Ibb62a0b1ab9fafa8a3acf07450ce2132ed605adc
This commit is contained in:
Ivan Tkachenko
2023-07-10 21:20:33 +01:00
parent 3e952e034c
commit eceb797d2f
11 changed files with 708 additions and 7 deletions
@@ -24,6 +24,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.taskbar.TaskbarActivityContext;
@@ -54,6 +56,7 @@ public class BubbleBarViewController {
// Initialized in init.
private BubbleStashController mBubbleStashController;
private BubbleBarController mBubbleBarController;
private BubbleDragController mBubbleDragController;
private TaskbarStashController mTaskbarStashController;
private TaskbarInsetsController mTaskbarInsetsController;
private View.OnClickListener mBubbleClickListener;
@@ -85,6 +88,7 @@ public class BubbleBarViewController {
public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers) {
mBubbleStashController = bubbleControllers.bubbleStashController;
mBubbleBarController = bubbleControllers.bubbleBarController;
mBubbleDragController = bubbleControllers.bubbleDragController;
mTaskbarStashController = controllers.taskbarStashController;
mTaskbarInsetsController = controllers.taskbarInsetsController;
@@ -95,6 +99,7 @@ public class BubbleBarViewController {
mBubbleBarScale.updateValue(1f);
mBubbleClickListener = v -> onBubbleClicked(v);
mBubbleBarClickListener = v -> setExpanded(true);
mBubbleDragController.setupBubbleBarView(mBarView);
mBarView.setOnClickListener(mBubbleBarClickListener);
mBarView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) ->
mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged()
@@ -256,6 +261,7 @@ public class BubbleBarViewController {
if (b != null) {
mBarView.addView(b.getView(), 0, new FrameLayout.LayoutParams(mIconSize, mIconSize));
b.getView().setOnClickListener(mBubbleClickListener);
mBubbleDragController.setupBubbleView(b.getView());
} else {
Log.w(TAG, "addBubble, bubble was null!");
}
@@ -307,4 +313,41 @@ public class BubbleBarViewController {
mBubbleStashController.showBubbleBar(true /* expand the bubbles */);
}
}
/**
* Updates the dragged bubble view in the bubble bar view, and notifies SystemUI
* to collapse the selected bubble while it's dragged.
* @param bubbleView dragged bubble view
*/
public void onDragStart(@NonNull BubbleView bubbleView) {
mBarView.setDraggedBubble(bubbleView);
if (bubbleView.getBubble() == null) return;
mSystemUiProxy.collapseWhileDragging(bubbleView.getBubble().getKey(), true /* collapse */);
}
/**
* Removes the dragged bubble view in the bubble bar view, and notifies SystemUI
* to expand the selected bubble when dragging finished.
* @param bubbleView dragged bubble view
*/
public void onDragEnd(@NonNull BubbleView bubbleView) {
mBarView.setDraggedBubble(null);
if (bubbleView.getBubble() == null) return;
mSystemUiProxy.collapseWhileDragging(bubbleView.getBubble().getKey(), false /* collapse */);
}
/**
* Called when bubble was dragged into the dismiss target. Notifies System
* @param bubble dismissed bubble item
*/
public void onDismissBubbleWhileDragging(@NonNull BubbleBarItem bubble) {
mSystemUiProxy.removeBubble(bubble.getKey());
}
/**
* Called when bubble stack was dragged into the dismiss target
*/
public void onDismissAllBubblesWhileDragging() {
mSystemUiProxy.removeAllBubbles();
}
}