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

Commit cd9b1308 authored by Mady Mellor's avatar Mady Mellor
Browse files

Update scrim controller to bubble state when bubbles are expanded

There's one issue with this where if you expand status bar
on top of the expanded bubble there is no scrim in between.

Test: manual / existing tests pass (atest SystemUITests)
Bug: 111236845
Change-Id: I2510758366999131ac7ffbb7505026727f4e40e1
parent 0c333774
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -60,6 +60,7 @@ public class BubbleController {
    private Context mContext;
    private Context mContext;
    private BubbleDismissListener mDismissListener;
    private BubbleDismissListener mDismissListener;
    private BubbleStateChangeListener mStateChangeListener;
    private BubbleStateChangeListener mStateChangeListener;
    private BubbleExpandListener mExpandListener;


    private Map<String, BubbleView> mBubbles = new HashMap<>();
    private Map<String, BubbleView> mBubbles = new HashMap<>();
    private BubbleStackView mStackView;
    private BubbleStackView mStackView;
@@ -96,6 +97,19 @@ public class BubbleController {
        void onHasBubblesChanged(boolean hasBubbles);
        void onHasBubblesChanged(boolean hasBubbles);
    }
    }


    /**
     * Listener to find out about stack expansion / collapse events.
     */
    public interface BubbleExpandListener {
        /**
         * Called when the expansion state of the bubble stack changes.
         *
         * @param isExpanding whether it's expanding or collapsing
         * @param amount fraction of how expanded or collapsed it is, 1 being fully, 0 at the start
         */
        void onBubbleExpandChanged(boolean isExpanding, float amount);
    }

    public BubbleController(Context context) {
    public BubbleController(Context context) {
        mContext = context;
        mContext = context;
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
@@ -118,6 +132,16 @@ public class BubbleController {
        mStateChangeListener = listener;
        mStateChangeListener = listener;
    }
    }


    /**
     * Set a listener to be notified of bubble expand events.
     */
    public void setExpandListener(BubbleExpandListener listener) {
        mExpandListener = listener;
        if (mStackView != null) {
            mStackView.setExpandListener(mExpandListener);
        }
    }

    /**
    /**
     * Whether or not there are bubbles present, regardless of them being visible on the
     * Whether or not there are bubbles present, regardless of them being visible on the
     * screen (e.g. if on AOD).
     * screen (e.g. if on AOD).
@@ -185,6 +209,9 @@ public class BubbleController {
                int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
                int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
                sbv.addView(mStackView, bubblePosition,
                sbv.addView(mStackView, bubblePosition,
                        new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
                        new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
                if (mExpandListener != null) {
                    mStackView.setExpandListener(mExpandListener);
                }
            }
            }
            mStackView.addBubble(bubble);
            mStackView.addBubble(bubble);
            if (setPosition) {
            if (setPosition) {
+14 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
    private BubbleView mExpandedBubble;
    private BubbleView mExpandedBubble;
    private Point mCollapsedPosition;
    private Point mCollapsedPosition;
    private BubbleTouchHandler mTouchHandler;
    private BubbleTouchHandler mTouchHandler;
    private BubbleController.BubbleExpandListener mExpandListener;


    private boolean mViewUpdatedRequested = false;
    private boolean mViewUpdatedRequested = false;
    private boolean mIsAnimating = false;
    private boolean mIsAnimating = false;
@@ -175,6 +176,13 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
        }
        }
    }
    }


    /**
     * Sets the listener to notify when the bubble stack is expanded.
     */
    public void setExpandListener(BubbleController.BubbleExpandListener listener) {
        mExpandListener = listener;
    }

    /**
    /**
     * Whether the stack of bubbles is expanded or not.
     * Whether the stack of bubbles is expanded or not.
     */
     */
@@ -225,6 +233,9 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
        }
        }
        mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0;
        mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0;
        requestUpdate();
        requestUpdate();
        if (wasExpanded && !mIsExpanded && mExpandListener != null) {
            mExpandListener.onBubbleExpandChanged(mIsExpanded, 1 /* amount */);
        }
    }
    }


    /**
    /**
@@ -275,6 +286,9 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
            mExpandedBubble = shouldExpand ? getTopBubble() : null;
            mExpandedBubble = shouldExpand ? getTopBubble() : null;
            updateExpandedBubble();
            updateExpandedBubble();


            if (mExpandListener != null) {
                mExpandListener.onBubbleExpandChanged(mIsExpanded, 1 /* amount */);
            }
            if (shouldExpand) {
            if (shouldExpand) {
                // Save current position so that we might return there
                // Save current position so that we might return there
                savePosition();
                savePosition();
+12 −0
Original line number Original line Diff line number Diff line
@@ -141,6 +141,7 @@ import com.android.systemui.SystemUIFactory;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.appops.AppOpsController;
import com.android.systemui.appops.AppOpsController;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.charging.WirelessChargingAnimation;
import com.android.systemui.charging.WirelessChargingAnimation;
import com.android.systemui.classifier.FalsingLog;
import com.android.systemui.classifier.FalsingLog;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.classifier.FalsingManager;
@@ -456,6 +457,13 @@ public class StatusBar extends SystemUI implements DemoMode,
    private NotificationMediaManager mMediaManager;
    private NotificationMediaManager mMediaManager;
    protected NotificationLockscreenUserManager mLockscreenUserManager;
    protected NotificationLockscreenUserManager mLockscreenUserManager;
    protected NotificationRemoteInputManager mRemoteInputManager;
    protected NotificationRemoteInputManager mRemoteInputManager;
    protected BubbleController mBubbleController;
    private final BubbleController.BubbleExpandListener mBubbleExpandListener =
            (isExpanding, amount) -> {
                if (amount == 1) {
                    updateScrimController();
                }
            };


    private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
    private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
        @Override
        @Override
@@ -613,6 +621,8 @@ public class StatusBar extends SystemUI implements DemoMode,
        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
        mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
        mNavigationBarController = Dependency.get(DisplayNavigationBarController.class);
        mNavigationBarController = Dependency.get(DisplayNavigationBarController.class);
        mBubbleController = Dependency.get(BubbleController.class);
        mBubbleController.setExpandListener(mBubbleExpandListener);


        mColorExtractor.addOnColorsChangedListener(this);
        mColorExtractor.addOnColorsChangedListener(this);
        mStatusBarStateController.addListener(this, StatusBarStateController.RANK_STATUS_BAR);
        mStatusBarStateController.addListener(this, StatusBarStateController.RANK_STATUS_BAR);
@@ -3845,6 +3855,8 @@ public class StatusBar extends SystemUI implements DemoMode,
        } else if (mIsKeyguard && !wakeAndUnlocking) {
        } else if (mIsKeyguard && !wakeAndUnlocking) {
            mScrimController.transitionTo(mNotificationPanel.isSemiAwake()
            mScrimController.transitionTo(mNotificationPanel.isSemiAwake()
                    ? ScrimState.DARK_KEYGUARD : ScrimState.KEYGUARD);
                    ? ScrimState.DARK_KEYGUARD : ScrimState.KEYGUARD);
        } else if (mBubbleController.isStackExpanded()) {
            mScrimController.transitionTo(ScrimState.BUBBLE_EXPANDED);
        } else {
        } else {
            mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
            mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
        }
        }
+7 −2
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.appops.AppOpsController;
import com.android.systemui.appops.AppOpsController;
import com.android.systemui.appops.AppOpsControllerImpl;
import com.android.systemui.appops.AppOpsControllerImpl;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -138,6 +139,7 @@ public class StatusBarTest extends SysuiTestCase {
    @Mock private DeviceProvisionedController mDeviceProvisionedController;
    @Mock private DeviceProvisionedController mDeviceProvisionedController;
    @Mock private NotificationPresenter mNotificationPresenter;
    @Mock private NotificationPresenter mNotificationPresenter;
    @Mock private NotificationEntryManager.Callback mCallback;
    @Mock private NotificationEntryManager.Callback mCallback;
    @Mock private BubbleController mBubbleController;


    private TestableStatusBar mStatusBar;
    private TestableStatusBar mStatusBar;
    private FakeMetricsLogger mMetricsLogger;
    private FakeMetricsLogger mMetricsLogger;
@@ -162,6 +164,7 @@ public class StatusBarTest extends SysuiTestCase {
        mDependency.injectTestDependency(StatusBarStateController.class, mStatusBarStateController);
        mDependency.injectTestDependency(StatusBarStateController.class, mStatusBarStateController);
        mDependency.injectTestDependency(DeviceProvisionedController.class,
        mDependency.injectTestDependency(DeviceProvisionedController.class,
                mDeviceProvisionedController);
                mDeviceProvisionedController);
        mDependency.injectMockDependency(BubbleController.class);


        mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class));
        mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class));
        mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class));
        mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class));
@@ -210,7 +213,7 @@ public class StatusBarTest extends SysuiTestCase {
                mock(NotificationIconAreaController.class), mock(DozeScrimController.class),
                mock(NotificationIconAreaController.class), mock(DozeScrimController.class),
                mock(NotificationShelf.class), mLockscreenUserManager,
                mock(NotificationShelf.class), mLockscreenUserManager,
                mCommandQueue,
                mCommandQueue,
                mNotificationPresenter);
                mNotificationPresenter, mock(BubbleController.class));
        mStatusBar.mContext = mContext;
        mStatusBar.mContext = mContext;
        mStatusBar.mComponents = mContext.getComponents();
        mStatusBar.mComponents = mContext.getComponents();
        mStatusBar.putComponent(StatusBar.class, mStatusBar);
        mStatusBar.putComponent(StatusBar.class, mStatusBar);
@@ -638,7 +641,8 @@ public class StatusBarTest extends SysuiTestCase {
                NotificationShelf notificationShelf,
                NotificationShelf notificationShelf,
                NotificationLockscreenUserManager notificationLockscreenUserManager,
                NotificationLockscreenUserManager notificationLockscreenUserManager,
                CommandQueue commandQueue,
                CommandQueue commandQueue,
                NotificationPresenter notificationPresenter) {
                NotificationPresenter notificationPresenter,
                BubbleController bubbleController) {
            mStatusBarKeyguardViewManager = man;
            mStatusBarKeyguardViewManager = man;
            mUnlockMethodCache = unlock;
            mUnlockMethodCache = unlock;
            mKeyguardIndicationController = key;
            mKeyguardIndicationController = key;
@@ -667,6 +671,7 @@ public class StatusBarTest extends SysuiTestCase {
            mCommandQueue = commandQueue;
            mCommandQueue = commandQueue;
            mPresenter = notificationPresenter;
            mPresenter = notificationPresenter;
            mGestureWakeLock = mock(PowerManager.WakeLock.class);
            mGestureWakeLock = mock(PowerManager.WakeLock.class);
            mBubbleController = bubbleController;
        }
        }


        private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {
        private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {