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

Commit f38871c7 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Fix bubble bar state after rotation on foldable" into main

parents fa68dfd9 d116bb49
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1551,6 +1551,12 @@ public class BubbleController implements ConfigurationChangeListener,
                    Log.w(TAG, "Tried to add a bubble to the stack but the stack is null");
                }
            };
        } else if (mBubbleData.isExpanded() && mBubbleData.getSelectedBubble() != null) {
            callback = b -> {
                if (b.getKey().equals(mBubbleData.getSelectedBubbleKey())) {
                    mLayerView.showExpandedView(b);
                }
            };
        }
        for (int i = mBubbleData.getBubbles().size() - 1; i >= 0; i--) {
            Bubble bubble = mBubbleData.getBubbles().get(i);
+5 −1
Original line number Diff line number Diff line
@@ -256,11 +256,15 @@ public class BubbleData {
    }

    /**
     * Returns a bubble bar update populated with the current list of active bubbles.
     * Returns a bubble bar update populated with the current list of active bubbles, expanded,
     * and selected state.
     */
    public BubbleBarUpdate getInitialStateForBubbleBar() {
        BubbleBarUpdate initialState = mStateChange.getInitialState();
        initialState.bubbleBarLocation = mPositioner.getBubbleBarLocation();
        initialState.expanded = mExpanded;
        initialState.expandedChanged = mExpanded; // only matters if we're expanded
        initialState.selectedBubbleKey = getSelectedBubbleKey();
        return initialState;
    }

+19 −0
Original line number Diff line number Diff line
@@ -1203,6 +1203,25 @@ public class BubbleDataTest extends ShellTestCase {
        assertThat(update.currentBubbleList.get(0).getKey()).isEqualTo(mEntryA2.getKey());
        assertThat(update.currentBubbleList.get(1).getKey()).isEqualTo(mEntryA1.getKey());
        assertThat(update.bubbleBarLocation).isEqualTo(BubbleBarLocation.LEFT);
        assertThat(update.expandedChanged).isFalse();
        assertThat(update.selectedBubbleKey).isEqualTo(mEntryA2.getKey());
    }

    @Test
    public void test_getInitialStateForBubbleBar_includesExpandedState() {
        sendUpdatedEntryAtTime(mEntryA1, 1000);
        sendUpdatedEntryAtTime(mEntryA2, 2000);
        mPositioner.setBubbleBarLocation(BubbleBarLocation.LEFT);
        mBubbleData.setExpanded(true);

        BubbleBarUpdate update = mBubbleData.getInitialStateForBubbleBar();
        assertThat(update.currentBubbleList).hasSize(2);
        assertThat(update.currentBubbleList.get(0).getKey()).isEqualTo(mEntryA2.getKey());
        assertThat(update.currentBubbleList.get(1).getKey()).isEqualTo(mEntryA1.getKey());
        assertThat(update.bubbleBarLocation).isEqualTo(BubbleBarLocation.LEFT);
        assertThat(update.expandedChanged).isTrue();
        assertThat(update.expanded).isTrue();
        assertThat(update.selectedBubbleKey).isEqualTo(mEntryA2.getKey());
    }

    @Test
+28 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ import com.android.wm.shell.bubbles.BubbleViewInfoTask;
import com.android.wm.shell.bubbles.BubbleViewProvider;
import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.bubbles.StackEducationView;
import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.bubbles.properties.BubbleProperties;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.FloatingContentCoordinator;
@@ -2108,6 +2109,33 @@ public class BubblesTest extends SysuiTestCase {
        assertBubbleIsInflatedForStack(mBubbleData.getOverflow());
    }

    @Test
    public void registerBubbleBarListener_switchToBarWhileExpanded() {
        mBubbleProperties.mIsBubbleBarEnabled = true;
        mPositioner.setIsLargeScreen(true);

        mEntryListener.onEntryAdded(mRow);
        mBubbleController.updateBubble(mBubbleEntry);
        BubbleStackView stackView = mBubbleController.getStackView();
        spyOn(stackView);

        mBubbleData.setExpanded(true);

        assertStackMode();
        assertThat(mBubbleData.isExpanded()).isTrue();
        assertThat(stackView.isExpanded()).isTrue();

        FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
        mBubbleController.registerBubbleStateListener(bubbleStateListener);

        BubbleBarLayerView layerView = mBubbleController.getLayerView();
        spyOn(layerView);

        assertBarMode();
        assertThat(mBubbleData.isExpanded()).isTrue();
        assertThat(layerView.isExpanded()).isTrue();
    }

    @Test
    public void switchBetweenBarAndStack_noBubbles_shouldBeIgnored() {
        mBubbleProperties.mIsBubbleBarEnabled = false;