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

Commit 67906f5a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix duplicate bubbles in the overflow" into sc-dev am: 4a44c4f4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14332917

Change-Id: I7bc2f4452221524cfc637ba43cf477655ebffbd1
parents 6bf4d08d 4a44c4f4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -575,6 +575,7 @@ public class BubbleData {
            Log.d(TAG, "Overflowing: " + bubble);
        }
        mLogger.logOverflowAdd(bubble, reason);
        mOverflowBubbles.remove(bubble);
        mOverflowBubbles.add(0, bubble);
        mStateChange.addedOverflowBubble = bubble;
        bubble.stopInflation();
+12 −5
Original line number Diff line number Diff line
@@ -220,19 +220,26 @@ public class BubbleOverflowContainerView extends LinearLayout {
                    Log.d(TAG, "remove: " + toRemove);
                }
                toRemove.cleanupViews();
                final int i = mOverflowBubbles.indexOf(toRemove);
                final int indexToRemove = mOverflowBubbles.indexOf(toRemove);
                mOverflowBubbles.remove(toRemove);
                mAdapter.notifyItemRemoved(i);
                mAdapter.notifyItemRemoved(indexToRemove);
            }

            Bubble toAdd = update.addedOverflowBubble;
            if (toAdd != null) {
                final int indexToAdd = mOverflowBubbles.indexOf(toAdd);
                if (DEBUG_OVERFLOW) {
                    Log.d(TAG, "add: " + toAdd);
                    Log.d(TAG, "add: " + toAdd + " prevIndex: " + indexToAdd);
                }
                if (indexToAdd > 0) {
                    mOverflowBubbles.remove(toAdd);
                    mOverflowBubbles.add(0, toAdd);
                    mAdapter.notifyItemMoved(indexToAdd, 0);
                } else {
                    mOverflowBubbles.add(0, toAdd);
                    mAdapter.notifyItemInserted(0);
                }
            }

            updateEmptyStateVisibility();

+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.wm.shell.bubbles;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

import static junit.framework.TestCase.assertEquals;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -799,6 +801,15 @@ public class BubbleDataTest extends ShellTestCase {
        assertExpandedChangedTo(false);
    }

    @Test
    public void test_addToOverflow_doesntAllowDupes() {
        assertEquals(0, mBubbleData.getOverflowBubbles().size());
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        assertEquals(1, mBubbleData.getOverflowBubbles().size());
    }

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