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

Commit 8b6a3c6c authored by Mark Renouf's avatar Mark Renouf
Browse files

BubbleData [4/n]: Cleanup StackView initializiation

Make lazy-init of BubbleStackView more explicit.

Bug: 123542488
Test: atest BubbleControllerTest
Change-Id: Ibd51517b606e65124d16d6823b1e8c2a9f5da51c
parent 85e0a90d
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -220,6 +220,26 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
        mSurfaceSynchronizer = synchronizer;
    }

    /**
     * BubbleStackView is lazily created by this method the first time a Bubble is added. This
     * method initializes the stack view and adds it to the StatusBar just above the scrim.
     */
    private void ensureStackViewCreated() {
        if (mStackView == null) {
            mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer);
            ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
            // TODO(b/130237686): When you expand the shade on top of expanded bubble, there is no
            //  scrim between bubble and the shade
            int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
            sbv.addView(mStackView, bubblePosition,
                    new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
            if (mExpandListener != null) {
                mStackView.setExpandListener(mExpandListener);
            }
            mStackView.setOnBlockedListener(this);
        }
    }

    @Override
    public void onUiModeChanged() {
        if (mStackView != null) {
@@ -332,20 +352,8 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
            // It's an update
            mStackView.updateBubble(notif);
        } else {
            if (mStackView == null) {
                mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer);
                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
                int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
                sbv.addView(mStackView, bubblePosition,
                        new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
                if (mExpandListener != null) {
                    mStackView.setExpandListener(mExpandListener);
                }
                mStackView.setOnBlockedListener(this);
            }
            // It's new
            ensureStackViewCreated();
            mStackView.addBubble(notif);
        }
        if (shouldAutoExpand(notif)) {