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

Commit fad849bc authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Dispatch one message for selected bubble and expanded" into main

parents 1eddd1ca beeee072
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -455,8 +455,7 @@ public class BubbleController implements ConfigurationChangeListener,
                        ProtoLog.d(WM_SHELL_BUBBLES,
                                "onActivityRestartAttempt - taskId=%d selecting matching bubble=%s",
                                task.taskId, b.getKey());
                        mBubbleData.setSelectedBubble(b);
                        mBubbleData.setExpanded(true);
                        mBubbleData.setSelectedBubbleAndExpandStack(b);
                        return;
                    }
                }
@@ -593,13 +592,6 @@ public class BubbleController implements ConfigurationChangeListener,
        }
    }

    private void openBubbleOverflow() {
        ensureBubbleViewsAndWindowCreated();
        mBubbleData.setShowingOverflow(true);
        mBubbleData.setSelectedBubble(mBubbleData.getOverflow());
        mBubbleData.setExpanded(true);
    }

    /**
     * Called when the status bar has become visible or invisible (either permanently or
     * temporarily).
@@ -1247,8 +1239,7 @@ public class BubbleController implements ConfigurationChangeListener,
        }
        if (mBubbleData.hasBubbleInStackWithKey(b.getKey())) {
            // already in the stack
            mBubbleData.setSelectedBubble(b);
            mBubbleData.setExpanded(true);
            mBubbleData.setSelectedBubbleAndExpandStack(b);
        } else if (mBubbleData.hasOverflowBubbleWithKey(b.getKey())) {
            // promote it out of the overflow
            promoteBubbleFromOverflow(b);
@@ -1273,8 +1264,7 @@ public class BubbleController implements ConfigurationChangeListener,
            String key = entry.getKey();
            Bubble bubble = mBubbleData.getBubbleInStackWithKey(key);
            if (bubble != null) {
                mBubbleData.setSelectedBubble(bubble);
                mBubbleData.setExpanded(true);
                mBubbleData.setSelectedBubbleAndExpandStack(bubble);
            } else {
                bubble = mBubbleData.getOverflowBubbleWithKey(key);
                if (bubble != null) {
@@ -1367,8 +1357,7 @@ public class BubbleController implements ConfigurationChangeListener,
            } else {
                // App bubble is not selected, select it & expand
                Log.i(TAG, "  showOrHideAppBubble, expand and select existing app bubble");
                mBubbleData.setSelectedBubble(existingAppBubble);
                mBubbleData.setExpanded(true);
                mBubbleData.setSelectedBubbleAndExpandStack(existingAppBubble);
            }
        } else {
            // Check if it exists in the overflow
+13 −0
Original line number Diff line number Diff line
@@ -365,6 +365,19 @@ public class BubbleData {
        mSelectedBubble = bubble;
    }

    /**
     * Sets the selected bubble and expands it.
     *
     * <p>This dispatches a single state update for both changes and should be used instead of
     * calling {@link #setSelectedBubble(BubbleViewProvider)} followed by
     * {@link #setExpanded(boolean)} immediately after, which will generate 2 separate updates.
     */
    public void setSelectedBubbleAndExpandStack(BubbleViewProvider bubble) {
        setSelectedBubbleInternal(bubble);
        setExpandedInternal(true);
        dispatchPendingChanges();
    }

    public void setSelectedBubble(BubbleViewProvider bubble) {
        setSelectedBubbleInternal(bubble);
        dispatchPendingChanges();
+13 −0
Original line number Diff line number Diff line
@@ -1222,6 +1222,19 @@ public class BubbleDataTest extends ShellTestCase {
        assertThat(update.bubbleBarLocation).isEqualTo(BubbleBarLocation.LEFT);
    }

    @Test
    public void setSelectedBubbleAndExpandStack() {
        sendUpdatedEntryAtTime(mEntryA1, 1000);
        sendUpdatedEntryAtTime(mEntryA2, 2000);
        mBubbleData.setListener(mListener);

        mBubbleData.setSelectedBubbleAndExpandStack(mBubbleA1);

        verifyUpdateReceived();
        assertSelectionChangedTo(mBubbleA1);
        assertExpandedChangedTo(true);
    }

    private void verifyUpdateReceived() {
        verify(mListener).applyUpdate(mUpdateCaptor.capture());
        reset(mListener);