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

Commit b9be52dc authored by Lyn Han's avatar Lyn Han
Browse files

Show selected bubble first, after stack expands

When the stack collapses, BubbleData moves the selected bubble
to first in stack, but marks accessed time instead of updated time.

Sorting uses updated time (in repackAll) and moves the selected bubble
back to where it was, when the stack expands later.

Fixed by marking updated time in addition to accessed time.

Fixes: 152883409
Test: manual: select bubble in middle of stack, collapse stack, expand
        stack -> see that bubble first in stack
Test: manual: select bubble in middle of stack, collapse stack, add new
        bubble, expand stack -> see that new bubble is first in stack
        and previously selected bubble is repacked

Change-Id: I8042549708ba3ace13d94e9cd3397af229af2dc9
parent 0bf55d7d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -549,6 +549,7 @@ public class BubbleData {
                Log.e(TAG, "Attempt to expand stack without selected bubble!");
                return;
            }
            mSelectedBubble.markUpdatedAt(mTimeSource.currentTimeMillis());
            mSelectedBubble.markAsAccessedAt(mTimeSource.currentTimeMillis());
            mStateChange.orderChanged |= repackAll();
        } else if (!mBubbles.isEmpty()) {
@@ -662,7 +663,7 @@ public class BubbleData {

    /**
     * This applies a full sort and group pass to all existing bubbles. The bubbles are grouped
     * by groupId. Each group is then sorted by the max(lastUpdated) time of it's bubbles. Bubbles
     * by groupId. Each group is then sorted by the max(lastUpdated) time of its bubbles. Bubbles
     * within each group are then sorted by lastUpdated descending.
     *
     * @return true if the position of any bubbles changed as a result
+4 −13
Original line number Diff line number Diff line
@@ -599,13 +599,13 @@ public class BubbleDataTest extends SysuiTestCase {
        sendUpdatedEntryAtTime(mEntryA1, 1000);
        sendUpdatedEntryAtTime(mEntryA2, 2000);
        sendUpdatedEntryAtTime(mEntryB1, 3000); // [B1, A2, A1]
        changeExpandedStateAtTime(true, 4000L);
        changeExpandedStateAtTime(true, 4000L); // B1 marked updated at 4000L
        mBubbleData.setListener(mListener);

        // Test
        sendUpdatedEntryAtTime(mEntryC1, 4000);
        verifyUpdateReceived();
        assertOrderChangedTo(mBubbleC1, mBubbleB1, mBubbleA2, mBubbleA1);
        assertOrderChangedTo(mBubbleB1, mBubbleC1, mBubbleA2, mBubbleA1);
    }

    /**
@@ -789,8 +789,7 @@ public class BubbleDataTest extends SysuiTestCase {
     * When the stack transitions to the collapsed state, the selected bubble is brought to the top.
     * Bubbles within the same group should move up with it.
     * <p>
     * When the stack transitions back to the expanded state, the previous ordering is restored, as
     * long as no changes have been made (adds, removes or updates) while in the collapsed state.
     * When the stack transitions back to the expanded state, this new order is kept as is.
     */
    @Test
    public void test_expansionChanges() {
@@ -813,20 +812,12 @@ public class BubbleDataTest extends SysuiTestCase {
        // stack is expanded. When next collapsed, sorting will be applied and saved, just prior
        // to moving the selected bubble to the top (first).
        //
        // In this case, the expected re-expand state will be: [B1, B2, A2*, A1]
        //
        // That state is restored as long as no changes occur (add/remove/update) while in
        // the collapsed state.
        // In this case, the expected re-expand state will be: [A2, A1, B1, B2]
        //
        // collapse -> selected bubble (A2) moves first.
        changeExpandedStateAtTime(false, 8000L);
        verifyUpdateReceived();
        assertOrderChangedTo(mBubbleA2, mBubbleA1, mBubbleB1, mBubbleB2);

        // expand -> "original" order/grouping restored
        changeExpandedStateAtTime(true, 10000L);
        verifyUpdateReceived();
        assertOrderChangedTo(mBubbleB1, mBubbleB2, mBubbleA2, mBubbleA1);
    }

    /**