Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afb53107 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Only collapse if the removed bubble matches the expanded bubble" into main

parents c8656c6e 8c8ef107
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -294,6 +294,25 @@ class BubbleBarLayerViewTest {
        assertThat(bubbleBarLayerView.children.last()).isEqualTo(secondBubble.bubbleBarExpandedView)
    }

    @Test
    fun twoBubbles_removeBubbleInTransition_skipCollapse() {
        val firstBubble = createBubble("first")
        val secondBubble = createBubble("second")


        getInstrumentation().runOnMainSync { bubbleBarLayerView.showExpandedView(firstBubble) }
        waitForExpandedViewAnimation()

        getInstrumentation().runOnMainSync { bubbleBarLayerView.showExpandedView(secondBubble) }
        waitForExpandedViewAnimation()

        firstBubble.preparingTransition = object : BubbleTransitions.BubbleTransition {}

        getInstrumentation().runOnMainSync { bubbleBarLayerView.removeBubble(firstBubble) {} }

        assertThat(bubbleBarLayerView.isExpanded).isTrue()
    }

    @Test
    fun testEventLogging_dismissExpandedViewViaDrag() {
        val bubble = createBubble("first")
+2 −1
Original line number Diff line number Diff line
@@ -712,7 +712,8 @@ public class Bubble implements BubbleViewProvider {
    /**
     * Sets the current bubble-transition that is coordinating a change in this bubble.
     */
    void setPreparingTransition(BubbleTransitions.BubbleTransition transit) {
    @VisibleForTesting
    public void setPreparingTransition(BubbleTransitions.BubbleTransition transit) {
        ProtoLog.d(WM_SHELL_BUBBLES_NOISY, "setPreparingTransition: transit=%s", transit);
        mPreparingTransition = transit;
    }
+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ public class BubbleTransitions {
     * in order to coordinate with the bubble view logic. These steps are communicated on this
     * interface.
     */
    interface BubbleTransition {
    public interface BubbleTransition {
        default void surfaceCreated() {}
        default void continueExpand() {}
        default void skip() {}
+14 −5
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.bubbles.bar;

import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES_NOISY;
import static com.android.wm.shell.shared.animation.Interpolators.ALPHA_IN;
import static com.android.wm.shell.shared.animation.Interpolators.ALPHA_OUT;
import static com.android.wm.shell.bubbles.Bubbles.DISMISS_USER_GESTURE;
@@ -40,6 +41,7 @@ import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;

import com.android.internal.protolog.ProtoLog;
import com.android.wm.shell.R;
import com.android.wm.shell.bubbles.Bubble;
import com.android.wm.shell.bubbles.BubbleController;
@@ -493,18 +495,25 @@ public class BubbleBarLayerView extends FrameLayout
        mAnimationHelper.getExpandedViewRestBounds(out);
    }

    /** Removes the given {@code bubble}. */
    public void removeBubble(Bubble bubble, Runnable endAction) {
    public void removeBubble(@NonNull Bubble bubble, @NonNull Runnable endAction) {
        final boolean inTransition = bubble.getPreparingTransition() != null;
        ProtoLog.d(WM_SHELL_BUBBLES_NOISY,
                "BBLayerView.removeBubble(): bubble=%s hasBubbles=%b inTransition=%b",
                bubble, !mBubbleData.getBubbles().isEmpty(), inTransition);
        Runnable cleanUp = () -> {
            // The transition is already managing the task/wm state.
            bubble.cleanupViews(!inTransition);
            endAction.run();
        };
        if (mBubbleData.getBubbles().isEmpty() || inTransition) {
            if (mExpandedBubble != null && mExpandedBubble.getKey().equals(bubble.getKey())) {
                // If we are removing the last bubble or removing the current bubble via transition,
                // collapse the expanded view and clean up bubbles at the end.
                collapse(cleanUp);
            } else {
                ProtoLog.d(WM_SHELL_BUBBLES_NOISY, "  Skipping, does not match expanded view");
                cleanUp.run();
            }
        } else {
            cleanUp.run();
        }