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

Commit 269374bb authored by Mady Mellor's avatar Mady Mellor
Browse files

Add visibility changes to the bubble view callback

- this way we're not constantly checking both views when
  updating visibility

Flag: EXEMPT trivial refactor
Test: atest BubbleControllerTest
Bug: 420487074
Change-Id: I4b14087636794d723dcf61934eb16c08e92713ee
parent b760d7c4
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -204,6 +204,8 @@ public class BubbleController implements ConfigurationChangeListener,
        void bubbleOrderChanged(List<Bubble> bubbleOrder, boolean updatePointer);
        /** Called when the bubble overflow empty state changes, used to show/hide the overflow. */
        void bubbleOverflowChanged(boolean hasBubbles);
        /** Called when the visibility of bubble views should be updated. */
        void updateVisibility(boolean visible);
    }

    private final Context mContext;
@@ -1298,14 +1300,9 @@ public class BubbleController implements ConfigurationChangeListener,
     * added in the meantime.
     */
    public void onAllBubblesAnimatedOut() {
        if (mStackView != null) {
            mStackView.setVisibility(INVISIBLE);
            removeFromWindowManagerMaybe();
        } else if (mLayerView != null) {
            mLayerView.setVisibility(INVISIBLE);
        mBubbleViewCallback.updateVisibility(false /* visible */);
        removeFromWindowManagerMaybe();
    }
    }

    /**
     * Records the notification key for any active bubbles. These are used to restore active
@@ -2493,6 +2490,13 @@ public class BubbleController implements ConfigurationChangeListener,
                }
            }
        }

        @Override
        public void updateVisibility(boolean visible) {
            if (mStackView != null) {
                mStackView.setVisibility(visible ? VISIBLE : INVISIBLE);
            }
        }
    };

    /** When bubbles are in the bubble bar, this will be used to notify bubble bar views. */
@@ -2572,6 +2576,13 @@ public class BubbleController implements ConfigurationChangeListener,
                }
            }
        }

        @Override
        public void updateVisibility(boolean visible) {
            if (mLayerView != null) {
                mLayerView.setVisibility(visible ? VISIBLE : INVISIBLE);
            }
        }
    };

    @SuppressWarnings("FieldCanBeLocal")
@@ -2833,22 +2844,12 @@ public class BubbleController implements ConfigurationChangeListener,
                mIsStatusBarShade, hasBubbles());
        if (!mIsStatusBarShade) {
            // Bubbles don't appear when the device is locked.
            if (mStackView != null) {
                mStackView.setVisibility(INVISIBLE);
            }
            if (mLayerView != null) {
                mLayerView.setVisibility(INVISIBLE);
            }
            mBubbleViewCallback.updateVisibility(false /* visible */);
        } else if (hasBubbles()) {
            // If we're unlocked, show the stack if we have bubbles. If we don't have bubbles, the
            // stack will be set to INVISIBLE in onAllBubblesAnimatedOut after the bubbles animate
            // out.
            if (mStackView != null) {
                mStackView.setVisibility(VISIBLE);
            }
            if (mLayerView != null) {
                mLayerView.setVisibility(VISIBLE);
            }
            mBubbleViewCallback.updateVisibility(true /* visible */);
        }

        if (mStackView != null) {