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
This commit is contained in:
@@ -60,6 +60,7 @@ public class BubbleController {
|
||||
private Context mContext;
|
||||
private BubbleDismissListener mDismissListener;
|
||||
private BubbleStateChangeListener mStateChangeListener;
|
||||
private BubbleExpandListener mExpandListener;
|
||||
|
||||
private Map<String, BubbleView> mBubbles = new HashMap<>();
|
||||
private BubbleStackView mStackView;
|
||||
@@ -96,6 +97,19 @@ public class BubbleController {
|
||||
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) {
|
||||
mContext = context;
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
@@ -118,6 +132,16 @@ public class BubbleController {
|
||||
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
|
||||
* screen (e.g. if on AOD).
|
||||
@@ -185,6 +209,9 @@ public class BubbleController {
|
||||
int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
|
||||
sbv.addView(mStackView, bubblePosition,
|
||||
new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
|
||||
if (mExpandListener != null) {
|
||||
mStackView.setExpandListener(mExpandListener);
|
||||
}
|
||||
}
|
||||
mStackView.addBubble(bubble);
|
||||
if (setPosition) {
|
||||
|
||||
@@ -61,6 +61,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
|
||||
private BubbleView mExpandedBubble;
|
||||
private Point mCollapsedPosition;
|
||||
private BubbleTouchHandler mTouchHandler;
|
||||
private BubbleController.BubbleExpandListener mExpandListener;
|
||||
|
||||
private boolean mViewUpdatedRequested = 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.
|
||||
*/
|
||||
@@ -225,6 +233,9 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
|
||||
}
|
||||
mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0;
|
||||
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;
|
||||
updateExpandedBubble();
|
||||
|
||||
if (mExpandListener != null) {
|
||||
mExpandListener.onBubbleExpandChanged(mIsExpanded, 1 /* amount */);
|
||||
}
|
||||
if (shouldExpand) {
|
||||
// Save current position so that we might return there
|
||||
savePosition();
|
||||
|
||||
@@ -141,6 +141,7 @@ import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.UiOffloadThread;
|
||||
import com.android.systemui.appops.AppOpsController;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.bubbles.BubbleController;
|
||||
import com.android.systemui.charging.WirelessChargingAnimation;
|
||||
import com.android.systemui.classifier.FalsingLog;
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
@@ -456,6 +457,13 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
private NotificationMediaManager mMediaManager;
|
||||
protected NotificationLockscreenUserManager mLockscreenUserManager;
|
||||
protected NotificationRemoteInputManager mRemoteInputManager;
|
||||
protected BubbleController mBubbleController;
|
||||
private final BubbleController.BubbleExpandListener mBubbleExpandListener =
|
||||
(isExpanding, amount) -> {
|
||||
if (amount == 1) {
|
||||
updateScrimController();
|
||||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -613,6 +621,8 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mColorExtractor = Dependency.get(SysuiColorExtractor.class);
|
||||
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
|
||||
mNavigationBarController = Dependency.get(DisplayNavigationBarController.class);
|
||||
mBubbleController = Dependency.get(BubbleController.class);
|
||||
mBubbleController.setExpandListener(mBubbleExpandListener);
|
||||
|
||||
mColorExtractor.addOnColorsChangedListener(this);
|
||||
mStatusBarStateController.addListener(this, StatusBarStateController.RANK_STATUS_BAR);
|
||||
@@ -3845,6 +3855,8 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
} else if (mIsKeyguard && !wakeAndUnlocking) {
|
||||
mScrimController.transitionTo(mNotificationPanel.isSemiAwake()
|
||||
? ScrimState.DARK_KEYGUARD : ScrimState.KEYGUARD);
|
||||
} else if (mBubbleController.isStackExpanded()) {
|
||||
mScrimController.transitionTo(ScrimState.BUBBLE_EXPANDED);
|
||||
} else {
|
||||
mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.appops.AppOpsController;
|
||||
import com.android.systemui.appops.AppOpsControllerImpl;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.bubbles.BubbleController;
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
@@ -138,6 +139,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
@Mock private DeviceProvisionedController mDeviceProvisionedController;
|
||||
@Mock private NotificationPresenter mNotificationPresenter;
|
||||
@Mock private NotificationEntryManager.Callback mCallback;
|
||||
@Mock private BubbleController mBubbleController;
|
||||
|
||||
private TestableStatusBar mStatusBar;
|
||||
private FakeMetricsLogger mMetricsLogger;
|
||||
@@ -162,6 +164,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mDependency.injectTestDependency(StatusBarStateController.class, mStatusBarStateController);
|
||||
mDependency.injectTestDependency(DeviceProvisionedController.class,
|
||||
mDeviceProvisionedController);
|
||||
mDependency.injectMockDependency(BubbleController.class);
|
||||
|
||||
mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class));
|
||||
mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class));
|
||||
@@ -210,7 +213,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mock(NotificationIconAreaController.class), mock(DozeScrimController.class),
|
||||
mock(NotificationShelf.class), mLockscreenUserManager,
|
||||
mCommandQueue,
|
||||
mNotificationPresenter);
|
||||
mNotificationPresenter, mock(BubbleController.class));
|
||||
mStatusBar.mContext = mContext;
|
||||
mStatusBar.mComponents = mContext.getComponents();
|
||||
mStatusBar.putComponent(StatusBar.class, mStatusBar);
|
||||
@@ -638,7 +641,8 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
NotificationShelf notificationShelf,
|
||||
NotificationLockscreenUserManager notificationLockscreenUserManager,
|
||||
CommandQueue commandQueue,
|
||||
NotificationPresenter notificationPresenter) {
|
||||
NotificationPresenter notificationPresenter,
|
||||
BubbleController bubbleController) {
|
||||
mStatusBarKeyguardViewManager = man;
|
||||
mUnlockMethodCache = unlock;
|
||||
mKeyguardIndicationController = key;
|
||||
@@ -667,6 +671,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mCommandQueue = commandQueue;
|
||||
mPresenter = notificationPresenter;
|
||||
mGestureWakeLock = mock(PowerManager.WakeLock.class);
|
||||
mBubbleController = bubbleController;
|
||||
}
|
||||
|
||||
private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {
|
||||
|
||||
Reference in New Issue
Block a user