Update bubble bar bounds in shell

Shell keeps track of bubble bar bounds for positioning and animating the
expanded view.
Bubble bar location can be changed when dragging the expanded view or
bubble bar itself.
Previously bounds were only reported when expanding a bubble. But after
adding drag support, bounds can change outside of expand action.
Implement a new bubbles API to report bubble bar bounds to shell
whenever they change in launcher.
Keep track of last reported bounds to ensure that we only send bounds
over when they change and when expand API has not already reported the
bounds.

Bug: 332423960
Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT
Test: drag expanded bubble from one side to the other, collapse it,
  observe that collapse animation collapses the view into the bar
Change-Id: If1bf31a04b8f134a1b055fddccd276e924ed98b6
This commit is contained in:
Ats Jenk
2024-04-02 16:23:45 -07:00
parent 96e4511d1a
commit f628796fc6
3 changed files with 72 additions and 13 deletions
@@ -27,6 +27,7 @@ import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
@@ -84,6 +85,11 @@ public class BubbleBarViewController {
private BubbleBarViewAnimator mBubbleBarViewAnimator;
@Nullable
private BubbleBarBoundsChangeListener mBoundsChangeListener;
private final Rect mPreviousBubbleBarBounds = new Rect();
public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) {
mActivity = activity;
mBarView = barView;
@@ -113,9 +119,17 @@ public class BubbleBarViewController {
mBubbleBarClickListener = v -> onBubbleBarClicked();
mBubbleDragController.setupBubbleBarView(mBarView);
mBarView.setOnClickListener(mBubbleBarClickListener);
mBarView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) ->
mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged()
);
mBarView.addOnLayoutChangeListener(
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
Rect bubbleBarBounds = mBarView.getBubbleBarBounds();
if (!bubbleBarBounds.equals(mPreviousBubbleBarBounds)) {
mPreviousBubbleBarBounds.set(bubbleBarBounds);
if (mBoundsChangeListener != null) {
mBoundsChangeListener.onBoundsChanged(bubbleBarBounds);
}
}
});
mBubbleBarViewAnimator = new BubbleBarViewAnimator(mBarView, mBubbleStashController);
}
@@ -426,4 +440,19 @@ public class BubbleBarViewController {
public void onDismissAllBubblesWhileDragging() {
mSystemUiProxy.removeAllBubbles();
}
/**
* Set listener to be notified when bubble bar bounds have changed
*/
public void setBoundsChangeListener(@Nullable BubbleBarBoundsChangeListener listener) {
mBoundsChangeListener = listener;
}
/**
* Listener to receive updates about bubble bar bounds changing
*/
public interface BubbleBarBoundsChangeListener {
/** Called when bounds have changed */
void onBoundsChanged(Rect newBounds);
}
}