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

Commit cfd06c1e authored by Mady Mellor's avatar Mady Mellor Committed by Mark Renouf
Browse files

Make BubbleData @Inject

Follow up comments from ag/6274141

Test: atest BubbleControllerTest
Bug: 123543995
Change-Id: Id9e74557e7b1a91f5fbf05bf9b94aeaf3e2d17be
parent 6d002031
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -150,7 +150,8 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
    }

    @Inject
    public BubbleController(Context context, StatusBarWindowController statusBarWindowController) {
    public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
            BubbleData data) {
        mContext = context;

        mNotificationEntryManager = Dependency.get(NotificationEntryManager.class);
@@ -171,7 +172,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
        mTaskStackListener = new BubbleTaskStackListener();
        ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);

        mBubbleData = BubbleData.getInstance();
        mBubbleData = data;
    }

    /**
@@ -253,7 +254,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
            mStackView.updateBubble(notif, updatePosition);
        } else {
            if (mStackView == null) {
                mStackView = new BubbleStackView(mContext);
                mStackView = new BubbleStackView(mContext, mBubbleData);
                ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
                // XXX: Bug when you expand the shade on top of expanded bubble, there is no scrim
                // between bubble and the shade
+6 −10
Original line number Diff line number Diff line
@@ -22,23 +22,19 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import java.util.Collection;
import java.util.HashMap;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * Keeps track of active bubbles.
 */
@Singleton
class BubbleData {

    private HashMap<String, Bubble> mBubbles = new HashMap<>();

    private static BubbleData sBubbleData = null;

    private BubbleData() {}

    public static BubbleData getInstance() {
        if (sBubbleData == null) {
            sBubbleData = new BubbleData();
        }
        return sBubbleData;
    }
    @Inject
    BubbleData() {}

    /**
     * The set of bubbles.
+3 −3
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F

    private final SpringAnimation mExpandedViewXAnim;
    private final SpringAnimation mExpandedViewYAnim;
    private final BubbleData mBubbleData;

    private PhysicsAnimationLayout mBubbleContainer;
    private StackAnimationController mStackAnimationController;
@@ -92,7 +93,6 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F

    private FrameLayout mExpandedViewContainer;

    private BubbleData mBubbleData;

    private int mBubbleSize;
    private int mBubblePadding;
@@ -140,10 +140,10 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
        }
    };

    public BubbleStackView(Context context) {
    public BubbleStackView(Context context, BubbleData data) {
        super(context);
        mBubbleData = BubbleData.getInstance();

        mBubbleData = data;
        mInflater = LayoutInflater.from(context);
        mTouchHandler = new BubbleTouchHandler(context);
        setOnTouchListener(mTouchHandler);
+7 −6
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ public class BubbleControllerTest extends SysuiTestCase {
    @Mock
    private BubbleController.BubbleExpandListener mBubbleExpandListener;

    private BubbleData mBubbleData;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
@@ -104,7 +106,9 @@ public class BubbleControllerTest extends SysuiTestCase {
        when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel);
        when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null);

        mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController);
        mBubbleData = new BubbleData();
        mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController,
                mBubbleData);
        mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener);
        mBubbleController.setExpandListener(mBubbleExpandListener);

@@ -112,9 +116,6 @@ public class BubbleControllerTest extends SysuiTestCase {
        verify(mNotificationEntryManager, atLeastOnce())
                .addNotificationEntryListener(mEntryListenerCaptor.capture());
        mEntryListener = mEntryListenerCaptor.getValue();

        // Reset the data
        BubbleData.getInstance().clear();
    }

    @Test
@@ -300,8 +301,8 @@ public class BubbleControllerTest extends SysuiTestCase {
    static class TestableBubbleController extends BubbleController {

        TestableBubbleController(Context context,
                StatusBarWindowController statusBarWindowController) {
            super(context, statusBarWindowController);
                StatusBarWindowController statusBarWindowController, BubbleData data) {
            super(context, statusBarWindowController, data);
        }

        @Override