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

Commit 89fb39dc authored by Lyn Han's avatar Lyn Han
Browse files

Show last selected bubble when stack expands

Fixes: 152888262

Test: manual
        1. Have 5 bubbles, select -middle- bubble, select overflow
        2. Collapse stack, reopen stack
        -> See that middle bubble is now first in stack and selected

Test: manual
        1. Have 5 bubbles, select -first- bubble, select overflow
        2. Collapse stack, reopen stack
        -> See that first bubble is selected again

Test: manual (overflow disabled)
        -> Previously selected bubble shows first in stack on expand

Change-Id: I8749306be247be3136d2b8a36852e796a5195ef7
parent 6f6216d3
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public class BubbleData {
    /** Bubbles that are being loaded but haven't been added to the stack just yet. */
    private final List<Bubble> mPendingBubbles;
    private Bubble mSelectedBubble;
    private boolean mShowingOverflow;
    private boolean mExpanded;
    private final int mMaxBubbles;
    private final int mMaxOverflowBubbles;
@@ -215,6 +216,10 @@ public class BubbleData {
        dispatchPendingChanges();
    }

    void setShowingOverflow(boolean showingOverflow) {
        mShowingOverflow = showingOverflow;
    }

    private void moveOverflowBubbleToPending(Bubble b) {
        // Preserve new order for next repack, which sorts by last updated time.
        b.markUpdatedAt(mTimeSource.currentTimeMillis());
@@ -513,9 +518,11 @@ public class BubbleData {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "setSelectedBubbleInternal: " + bubble);
        }
        if (Objects.equals(bubble, mSelectedBubble)) {
        if (!mShowingOverflow && Objects.equals(bubble, mSelectedBubble)) {
            return;
        }
        // Otherwise, if we are showing the overflow menu, return to the previously selected bubble.

        if (bubble != null && !mBubbles.contains(bubble) && !mOverflowBubbles.contains(bubble)) {
            Log.e(TAG, "Cannot select bubble which doesn't exist!"
                    + " (" + bubble + ") bubbles=" + mBubbles);
@@ -559,6 +566,10 @@ public class BubbleData {
            mStateChange.orderChanged |= repackAll();
            // Save the state which should be returned to when expanded (with no other changes)

            if (mShowingOverflow) {
                // Show previously selected bubble instead of overflow menu on next expansion.
                setSelectedBubbleInternal(mSelectedBubble);
            }
            if (mBubbles.indexOf(mSelectedBubble) > 0) {
                // Move the selected bubble to the top while collapsed.
                if (!mSelectedBubble.isOngoing() && mBubbles.get(0).isOngoing()) {
+5 −2
Original line number Diff line number Diff line
@@ -439,8 +439,8 @@ public class BubbleStackView extends FrameLayout {
                    // that means overflow was previously expanded. Set the selected bubble
                    // internally without going through BubbleData (which would ignore it since it's
                    // already selected).
                    mBubbleData.setShowingOverflow(true);
                    setSelectedBubble(clickedBubble);

                }
            } else {
                // Otherwise, we either tapped the stack (which means we're collapsed
@@ -1227,8 +1227,12 @@ public class BubbleStackView extends FrameLayout {
        if (mExpandedBubble != null && mExpandedBubble.equals(bubbleToSelect)) {
            return;
        }
        if (bubbleToSelect == null || bubbleToSelect.getKey() != BubbleOverflow.KEY) {
            mBubbleData.setShowingOverflow(false);
        }
        final BubbleViewProvider previouslySelected = mExpandedBubble;
        mExpandedBubble = bubbleToSelect;
        updatePointerPosition();

        if (mIsExpanded) {
            // Make the container of the expanded view transparent before removing the expanded view
@@ -1238,7 +1242,6 @@ public class BubbleStackView extends FrameLayout {
            mSurfaceSynchronizer.syncSurfaceAndRun(() -> {
                previouslySelected.setContentVisibility(false);
                updateExpandedBubble();
                updatePointerPosition();
                requestUpdate();

                logBubbleEvent(previouslySelected,