diff options
| author | 2020-02-20 17:45:34 -0500 | |
|---|---|---|
| committer | 2020-08-10 17:19:09 -0400 | |
| commit | f152f9d2ab96b47593875e7d6a2e932587ddf904 (patch) | |
| tree | 3d32b4b6455b5ea059c242b50ec68ad35caa69d9 | |
| parent | 18c3a47853336edd00cf840f207f9f4b9a703608 (diff) | |
Add NotificationShelfController.
This moves injection from NotificationShelf into its controller,
creating a subcomponent for the view.
This is a relatively light-weight version of this change. Very little
logic is actually moved into the controller, with a handful of public
methods on the controller simply acting as proxies to the view for
now.
Bug: 147245740
Test: manual && atest SystemUITests
Change-Id: Ic74dc6a2ef83bcc2e1a86080d77b156b2b3e8c15
14 files changed, 297 insertions, 95 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index fce545b421d5..f774358b69fb 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -38,6 +38,7 @@ import com.android.systemui.statusbar.notification.collection.inflation.Notifica import com.android.systemui.statusbar.notification.people.PeopleHubModule; import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent; import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; +import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.phone.KeyguardLiftController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; @@ -72,7 +73,8 @@ import dagger.Provides; subcomponents = {StatusBarComponent.class, NotificationRowComponent.class, DozeComponent.class, - ExpandableNotificationRowComponent.class}) + ExpandableNotificationRowComponent.class, + NotificationShelfComponent.class}) public abstract class SystemUIModule { @Binds diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index d798692879f5..36f8bcdc9123 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -18,7 +18,6 @@ package com.android.systemui.statusbar; import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN_REVERSE; import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE; -import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; import android.content.Context; import android.content.res.Configuration; @@ -26,7 +25,6 @@ import android.content.res.Resources; import android.graphics.Rect; import android.os.SystemProperties; import android.util.AttributeSet; -import android.util.Log; import android.util.MathUtils; import android.view.DisplayCutout; import android.view.View; @@ -36,10 +34,8 @@ import android.view.WindowInsets; import android.view.accessibility.AccessibilityNodeInfo; import com.android.internal.annotations.VisibleForTesting; -import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.statusbar.notification.NotificationUtils; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; @@ -50,12 +46,8 @@ import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.notification.stack.ExpandableViewState; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.ViewState; -import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationIconContainer; -import javax.inject.Inject; -import javax.inject.Named; - /** * A notification shelf view that is placed inside the notification scroller. It manages the * overflow icons that don't fit into the regular list anymore. @@ -69,7 +61,6 @@ public class NotificationShelf extends ActivatableNotificationView implements = SystemProperties.getBoolean("debug.icon_scroll_animations", true); private static final int TAG_CONTINUOUS_CLIPPING = R.id.continuous_clipping_tag; private static final String TAG = "NotificationShelf"; - private final KeyguardBypassController mBypassController; private NotificationIconContainer mShelfIcons; private int[] mTmp = new int[2]; @@ -77,7 +68,6 @@ public class NotificationShelf extends ActivatableNotificationView implements private int mIconAppearTopPadding; private float mHiddenShelfIconSize; private int mStatusBarHeight; - private int mStatusBarPaddingStart; private AmbientState mAmbientState; private NotificationStackScrollLayout mHostLayout; private int mMaxLayoutHeight; @@ -88,7 +78,6 @@ public class NotificationShelf extends ActivatableNotificationView implements private int mScrollFastThreshold; private int mIconSize; private int mStatusBarState; - private float mMaxShelfEnd; private int mRelativeOffset; private boolean mInteractive; private float mOpenedAmount; @@ -99,13 +88,10 @@ public class NotificationShelf extends ActivatableNotificationView implements private Rect mClipRect = new Rect(); private int mCutoutHeight; private int mGapHeight; + private NotificationShelfController mController; - @Inject - public NotificationShelf(@Named(VIEW_CONTEXT) Context context, - AttributeSet attrs, - KeyguardBypassController keyguardBypassController) { + public NotificationShelf(Context context, AttributeSet attrs) { super(context, attrs); - mBypassController = keyguardBypassController; } @Override @@ -128,19 +114,6 @@ public class NotificationShelf extends ActivatableNotificationView implements initDimens(); } - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class)) - .addCallback(this, SysuiStatusBarStateController.RANK_SHELF); - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - Dependency.get(StatusBarStateController.class).removeCallback(this); - } - public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout) { mAmbientState = ambientState; mHostLayout = hostLayout; @@ -150,7 +123,6 @@ public class NotificationShelf extends ActivatableNotificationView implements Resources res = getResources(); mIconAppearTopPadding = res.getDimensionPixelSize(R.dimen.notification_icon_appear_padding); mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height); - mStatusBarPaddingStart = res.getDimensionPixelOffset(R.dimen.status_bar_padding_start); mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height); ViewGroup.LayoutParams layoutParams = getLayoutParams(); @@ -315,9 +287,7 @@ public class NotificationShelf extends ActivatableNotificationView implements transitionAmount = inShelfAmount; } // We don't want to modify the color if the notification is hun'd - boolean canModifyColor = mAmbientState.isShadeExpanded() - && !(mAmbientState.isOnKeyguard() && mBypassController.getBypassEnabled()); - if (isLastChild && canModifyColor) { + if (isLastChild && mController.canModifyColorOfNotifications()) { if (colorOfViewBeforeLast == NO_COLOR) { colorOfViewBeforeLast = ownColorUntinted; } @@ -999,10 +969,6 @@ public class NotificationShelf extends ActivatableNotificationView implements return mInteractive; } - public void setMaxShelfEnd(float maxShelfEnd) { - mMaxShelfEnd = maxShelfEnd; - } - public void setAnimationsEnabled(boolean enabled) { mAnimationsEnabled = enabled; if (!enabled) { @@ -1044,6 +1010,10 @@ public class NotificationShelf extends ActivatableNotificationView implements updateBackgroundColors(); } + public void setController(NotificationShelfController notificationShelfController) { + mController = notificationShelfController; + } + private class ShelfState extends ExpandableViewState { private float openedAmount; private boolean hasItemsInStableShelf; @@ -1056,7 +1026,6 @@ public class NotificationShelf extends ActivatableNotificationView implements } super.applyToView(view); - setMaxShelfEnd(maxShelfEnd); setOpenedAmount(openedAmount); updateAppearance(); setHasItemsInStableShelf(hasItemsInStableShelf); @@ -1070,7 +1039,6 @@ public class NotificationShelf extends ActivatableNotificationView implements } super.animateTo(child, properties); - setMaxShelfEnd(maxShelfEnd); setOpenedAmount(openedAmount); updateAppearance(); setHasItemsInStableShelf(hasItemsInStableShelf); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelfController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelfController.java new file mode 100644 index 000000000000..9f8f8447d72c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelfController.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar; + +import android.view.View; + +import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowScope; +import com.android.systemui.statusbar.notification.stack.AmbientState; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.statusbar.phone.KeyguardBypassController; +import com.android.systemui.statusbar.phone.NotificationIconContainer; +import com.android.systemui.statusbar.phone.StatusBarNotificationPresenter; + +import javax.inject.Inject; + +/** + * Controller class for {@link NotificationShelf}. + */ +@NotificationRowScope +public class NotificationShelfController { + private final NotificationShelf mView; + private final ActivatableNotificationViewController mActivatableNotificationViewController; + private final KeyguardBypassController mKeyguardBypassController; + private final SysuiStatusBarStateController mStatusBarStateController; + private final View.OnAttachStateChangeListener mOnAttachStateChangeListener; + private AmbientState mAmbientState; + + @Inject + public NotificationShelfController(NotificationShelf notificationShelf, + ActivatableNotificationViewController activatableNotificationViewController, + KeyguardBypassController keyguardBypassController, + SysuiStatusBarStateController statusBarStateController) { + mView = notificationShelf; + mActivatableNotificationViewController = activatableNotificationViewController; + mKeyguardBypassController = keyguardBypassController; + mStatusBarStateController = statusBarStateController; + mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() { + @Override + public void onViewAttachedToWindow(View v) { + mStatusBarStateController.addCallback( + mView, SysuiStatusBarStateController.RANK_SHELF); + } + + @Override + public void onViewDetachedFromWindow(View v) { + mStatusBarStateController.removeCallback(mView); + } + }; + } + + public void init() { + mActivatableNotificationViewController.init(); + mView.setController(this); + mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); + if (mView.isAttachedToWindow()) { + mOnAttachStateChangeListener.onViewAttachedToWindow(mView); + } + } + + public NotificationShelf getView() { + return mView; + } + + public boolean canModifyColorOfNotifications() { + return mAmbientState.isShadeExpanded() + && !(mAmbientState.isOnKeyguard() && mKeyguardBypassController.getBypassEnabled()); + } + + public NotificationIconContainer getShelfIcons() { + return mView.getShelfIcons(); + } + + public void setCollapsedIcons(NotificationIconContainer notificationIcons) { + mView.setCollapsedIcons(notificationIcons); + } + + public void bind(AmbientState ambientState, + NotificationStackScrollLayout notificationStackScrollLayout) { + mView.bind(ambientState, notificationStackScrollLayout); + mAmbientState = ambientState; + } + + public int getHeight() { + return mView.getHeight(); + } + + public void updateState(AmbientState ambientState) { + mAmbientState = ambientState; + mView.updateState(ambientState); + } + + public int getIntrinsicHeight() { + return mView.getIntrinsicHeight(); + } + + public void setOnActivatedListener(StatusBarNotificationPresenter presenter) { + mView.setOnActivatedListener(presenter); + } + + public void setOnClickListener(View.OnClickListener onClickListener) { + mView.setOnClickListener(onClickListener); + } + + public int getNotGoneIndex() { + return mView.getNotGoneIndex(); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java index 7cda23544ca0..27e4adee68ba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java @@ -21,7 +21,7 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import com.android.systemui.R; -import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; +import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.phone.LockIcon; import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.NotificationPanelView; @@ -41,22 +41,22 @@ public class SuperStatusBarViewFactory { private final Context mContext; private final InjectionInflationController mInjectionInflationController; - private final NotificationRowComponent.Builder mNotificationRowComponentBuilder; private final LockscreenLockIconController mLockIconController; + private final NotificationShelfComponent.Builder mNotificationShelfComponentBuilder; private NotificationShadeWindowView mNotificationShadeWindowView; private StatusBarWindowView mStatusBarWindowView; - private NotificationShelf mNotificationShelf; + private NotificationShelfController mNotificationShelfController; @Inject public SuperStatusBarViewFactory(Context context, InjectionInflationController injectionInflationController, - NotificationRowComponent.Builder notificationRowComponentBuilder, + NotificationShelfComponent.Builder notificationShelfComponentBuilder, LockscreenLockIconController lockIconController) { mContext = context; mInjectionInflationController = injectionInflationController; - mNotificationRowComponentBuilder = notificationRowComponentBuilder; mLockIconController = lockIconController; + mNotificationShelfComponentBuilder = notificationShelfComponentBuilder; } /** @@ -114,25 +114,27 @@ public class SuperStatusBarViewFactory { * isn't immediately attached, but the layout params of this view is used * during inflation. */ - public NotificationShelf getNotificationShelf(ViewGroup container) { - if (mNotificationShelf != null) { - return mNotificationShelf; + public NotificationShelfController getNotificationShelfController(ViewGroup container) { + if (mNotificationShelfController != null) { + return mNotificationShelfController; } - mNotificationShelf = (NotificationShelf) mInjectionInflationController.injectable( - LayoutInflater.from(mContext)).inflate(R.layout.status_bar_notification_shelf, - container, /* attachToRoot= */ false); + NotificationShelf view = (NotificationShelf) LayoutInflater.from(mContext) + .inflate(R.layout.status_bar_notification_shelf, container, /* attachToRoot= */ + false); - NotificationRowComponent component = mNotificationRowComponentBuilder - .activatableNotificationView(mNotificationShelf) - .build(); - component.getActivatableNotificationViewController().init(); - - if (mNotificationShelf == null) { + if (view == null) { throw new IllegalStateException( "R.layout.status_bar_notification_shelf could not be properly inflated"); } - return mNotificationShelf; + + NotificationShelfComponent component = mNotificationShelfComponentBuilder + .notificationShelf(view) + .build(); + mNotificationShelfController = component.getNotificationShelfController(); + mNotificationShelfController.init(); + + return mNotificationShelfController; } public NotificationPanelView getNotificationPanelView() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationShelfComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationShelfComponent.java new file mode 100644 index 000000000000..af8d6ec727d1 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationShelfComponent.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.notification.row.dagger; + +import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; +import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; + +import dagger.Binds; +import dagger.BindsInstance; +import dagger.Module; +import dagger.Subcomponent; + +/** + * Dagger subcomponent for NotificationShelf. + */ +@Subcomponent(modules = {ActivatableNotificationViewModule.class, + NotificationShelfComponent.NotificationShelfModule.class}) +@NotificationRowScope +public interface NotificationShelfComponent { + /** + * Builder for {@link NotificationShelfComponent}. + */ + @Subcomponent.Builder + interface Builder { + @BindsInstance + Builder notificationShelf(NotificationShelf view); + NotificationShelfComponent build(); + } + + /** + * Creates a NotificationShelfController. + */ + @NotificationRowScope + NotificationShelfController getNotificationShelfController(); + /** + * Dagger Module that extracts interesting properties from a NotificationShelf. + */ + @Module + abstract class NotificationShelfModule { + + /** NotificationShelf is provided as an instance of ActivatableNotificationView. */ + @Binds + abstract ActivatableNotificationView bindNotificationShelf(NotificationShelf view); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 66a541a923a4..57c1a16a259d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -113,6 +113,7 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -5419,28 +5420,23 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) - public void setShelf(NotificationShelf shelf) { + public void setShelfController(NotificationShelfController notificationShelfController) { int index = -1; if (mShelf != null) { index = indexOfChild(mShelf); removeView(mShelf); } - mShelf = shelf; + mShelf = notificationShelfController.getView(); addView(mShelf, index); - mAmbientState.setShelf(shelf); - mStateAnimator.setShelf(shelf); - shelf.bind(mAmbientState, this); + mAmbientState.setShelf(mShelf); + mStateAnimator.setShelf(mShelf); + notificationShelfController.bind(mAmbientState, this); if (ANCHOR_SCROLLING) { mScrollAnchorView = mShelf; } } @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) - public NotificationShelf getNotificationShelf() { - return mShelf; - } - - @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) public void setMaxDisplayedNotifications(int maxDisplayedNotifications) { if (mMaxDisplayedNotifications != maxDisplayedNotifications) { mMaxDisplayedNotifications = maxDisplayedNotifications; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 9d3e915cad69..7bbe1c986249 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -26,7 +26,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationMediaManager; -import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.StatusBarIconView; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.NotificationUtils; @@ -160,9 +160,9 @@ public class NotificationIconAreaController implements DarkReceiver, } } - public void setupShelf(NotificationShelf shelf) { - mShelfIcons = shelf.getShelfIcons(); - shelf.setCollapsedIcons(mNotificationIcons); + public void setupShelf(NotificationShelfController notificationShelfController) { + mShelfIcons = notificationShelfController.getShelfIcons(); + notificationShelfController.setCollapsedIcons(mNotificationIcons); } public void onDensityOrFontScaleChanged(Context context) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index a87311a69ab5..6946346eee2f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -86,6 +86,7 @@ import com.android.systemui.statusbar.KeyguardAffordanceView; import com.android.systemui.statusbar.KeyguardIndicationController; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.StatusBarState; @@ -454,6 +455,7 @@ public class NotificationPanelViewController extends PanelViewController { private boolean mAnimatingQS; private int mOldLayoutDirection; + private NotificationShelfController mNotificationShelfController; private View.AccessibilityDelegate mAccessibilityDelegate = new View.AccessibilityDelegate() { @Override @@ -858,7 +860,7 @@ public class NotificationPanelViewController extends PanelViewController { float minPadding = mClockPositionAlgorithm.getMinStackScrollerPadding(); int notificationPadding = Math.max( 1, mResources.getDimensionPixelSize(R.dimen.notification_divider_height)); - NotificationShelf shelf = mNotificationStackScroller.getNotificationShelf(); + NotificationShelf shelf = mNotificationShelfController.getView(); float shelfSize = shelf.getVisibility() == View.GONE ? 0 @@ -3053,7 +3055,7 @@ public class NotificationPanelViewController extends PanelViewController { } public void initDependencies(StatusBar statusBar, NotificationGroupManager groupManager, - NotificationShelf notificationShelf, + NotificationShelfController notificationShelfController, NotificationIconAreaController notificationIconAreaController, ScrimController scrimController) { setStatusBar(statusBar); @@ -3062,9 +3064,10 @@ public class NotificationPanelViewController extends PanelViewController { mNotificationStackScroller.setIconAreaController(notificationIconAreaController); mNotificationStackScroller.setStatusBar(statusBar); mNotificationStackScroller.setGroupManager(groupManager); - mNotificationStackScroller.setShelf(notificationShelf); + mNotificationStackScroller.setShelfController(notificationShelfController); mNotificationStackScroller.setScrimController(scrimController); updateShowEmptyShadeView(); + mNotificationShelfController = notificationShelfController; } public void showTransientIndication(int id) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index eb626280b494..c8fb4e3372c8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -179,7 +179,6 @@ import com.android.systemui.statusbar.AutoHideUiElement; import com.android.systemui.statusbar.BackDropView; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CrossFadeHelper; -import com.android.systemui.statusbar.EmptyShadeView; import com.android.systemui.statusbar.GestureRecorder; import com.android.systemui.statusbar.KeyboardShortcuts; import com.android.systemui.statusbar.KeyguardIndicationController; @@ -189,7 +188,7 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationShadeDepthController; -import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.NotificationViewHierarchyManager; import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.ScrimView; @@ -1029,7 +1028,7 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarStateController); mWakeUpCoordinator.setIconAreaController(mNotificationIconAreaController); inflateShelf(); - mNotificationIconAreaController.setupShelf(mNotificationShelf); + mNotificationIconAreaController.setupShelf(mNotificationShelfController); mNotificationPanelViewController.setOnReinflationListener( mNotificationIconAreaController::initAodIcons); mNotificationPanelViewController.addExpansionListener(mWakeUpCoordinator); @@ -1147,7 +1146,8 @@ public class StatusBar extends SystemUI implements DemoMode, }); mScrimController.attachViews(scrimBehind, scrimInFront, scrimForBubble); - mNotificationPanelViewController.initDependencies(this, mGroupManager, mNotificationShelf, + mNotificationPanelViewController.initDependencies(this, mGroupManager, + mNotificationShelfController, mNotificationIconAreaController, mScrimController); BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); @@ -1310,7 +1310,7 @@ public class StatusBar extends SystemUI implements DemoMode, this /* statusBar */, mShadeController, mCommandQueue, mInitController, mNotificationInterruptStateProvider); - mNotificationShelf.setOnActivatedListener(mPresenter); + mNotificationShelfController.setOnActivatedListener(mPresenter); mRemoteInputManager.getController().addCallback(mNotificationShadeWindowController); mNotificationActivityStarter = @@ -1386,8 +1386,9 @@ public class StatusBar extends SystemUI implements DemoMode, } private void inflateShelf() { - mNotificationShelf = mSuperStatusBarViewFactory.getNotificationShelf(mStackScroller); - mNotificationShelf.setOnClickListener(mGoToLockedShadeListener); + mNotificationShelfController = mSuperStatusBarViewFactory + .getNotificationShelfController(mStackScroller); + mNotificationShelfController.setOnClickListener(mGoToLockedShadeListener); } @Override @@ -4085,8 +4086,7 @@ public class StatusBar extends SystemUI implements DemoMode, private final Optional<Recents> mRecentsOptional; - protected NotificationShelf mNotificationShelf; - protected EmptyShadeView mEmptyShadeView; + protected NotificationShelfController mNotificationShelfController; private final Lazy<AssistManager> mAssistManagerLazy; diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java index 551b7b41212a..d16bedcad960 100644 --- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java +++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java @@ -23,6 +23,7 @@ import android.view.InflateException; import android.view.LayoutInflater; import android.view.View; +import com.android.keyguard.KeyguardClockSwitch; import com.android.keyguard.KeyguardMessageArea; import com.android.keyguard.KeyguardSliceView; import com.android.systemui.dagger.SystemUIRootComponent; @@ -126,11 +127,6 @@ public class InjectionInflationController { NotificationStackScrollLayout createNotificationStackScrollLayout(); /** - * Creates the Shelf. - */ - NotificationShelf creatNotificationShelf(); - - /** * Creates the KeyguardSliceView. */ KeyguardSliceView createKeyguardSliceView(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java index b7589534a770..1538a32ecf8a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java @@ -60,6 +60,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.statusbar.IStatusBarService; +import com.android.systemui.SystemUIFactory; import com.android.systemui.SysuiTestCase; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dump.DumpManager; @@ -70,7 +71,9 @@ import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationRemoveInterceptor; +import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.RankingBuilder; +import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; @@ -79,8 +82,10 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.NotificationTestHelper; +import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; +import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; @@ -90,6 +95,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.util.FloatingContentCoordinator; +import com.android.systemui.util.InjectionInflationController; import com.google.common.collect.ImmutableList; @@ -174,6 +180,8 @@ public class BubbleControllerTest extends SysuiTestCase { @Mock private ShadeController mShadeController; @Mock + private NotificationShelfComponent mNotificationShelfComponent; + @Mock private NotifPipeline mNotifPipeline; @Mock private FeatureFlags mFeatureFlagsOldPipeline; @@ -185,11 +193,14 @@ public class BubbleControllerTest extends SysuiTestCase { private IStatusBarService mStatusBarService; @Mock private LauncherApps mLauncherApps; + @Mock private LockscreenLockIconController mLockIconController; private BubbleData mBubbleData; private TestableLooper mTestableLooper; + private SuperStatusBarViewFactory mSuperStatusBarViewFactory; + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); @@ -199,6 +210,23 @@ public class BubbleControllerTest extends SysuiTestCase { mContext.addMockSystemService(FaceManager.class, mFaceManager); when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); + mSuperStatusBarViewFactory = new SuperStatusBarViewFactory(mContext, + new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()), + new NotificationShelfComponent.Builder() { + @Override + public NotificationShelfComponent.Builder notificationShelf( + NotificationShelf view) { + return this; + } + + @Override + public NotificationShelfComponent build() { + return mNotificationShelfComponent; + } + }, + mLockIconController); + + // Bubbles get added to status bar window view mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java index 43bf19111049..0e7cb79ec266 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java @@ -58,6 +58,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.colorextraction.ColorExtractor; import com.android.internal.statusbar.IStatusBarService; +import com.android.systemui.SystemUIFactory; import com.android.systemui.SysuiTestCase; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dump.DumpManager; @@ -66,7 +67,9 @@ import com.android.systemui.model.SysUiState; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.NotificationLockscreenUserManager; +import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.RankingBuilder; +import com.android.systemui.statusbar.SuperStatusBarViewFactory; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationFilter; @@ -75,7 +78,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.NotificationTestHelper; -import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; +import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.LockscreenLockIconController; @@ -88,6 +91,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.util.FloatingContentCoordinator; +import com.android.systemui.util.InjectionInflationController; import org.junit.Before; import org.junit.Ignore; @@ -168,7 +172,7 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase { @Mock private ShadeController mShadeController; @Mock - private NotificationRowComponent mNotificationRowComponent; + private NotificationShelfComponent mNotificationShelfComponent; @Mock private NotifPipeline mNotifPipeline; @Mock @@ -185,6 +189,7 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase { private BubbleData mBubbleData; private TestableLooper mTestableLooper; + private SuperStatusBarViewFactory mSuperStatusBarViewFactory; @Before public void setUp() throws Exception { @@ -195,6 +200,22 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase { mContext.addMockSystemService(FaceManager.class, mFaceManager); when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); + mSuperStatusBarViewFactory = new SuperStatusBarViewFactory(mContext, + new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()), + new NotificationShelfComponent.Builder() { + @Override + public NotificationShelfComponent.Builder notificationShelf( + NotificationShelf view) { + return this; + } + + @Override + public NotificationShelfComponent build() { + return mNotificationShelfComponent; + } + }, + mLockIconController); + // Bubbles get added to status bar window view mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index ddac2ecbd6eb..85701c24f7d6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -64,6 +64,7 @@ import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -197,7 +198,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mEntryManager.setUpWithPresenter(mock(NotificationPresenter.class)); when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(false); + NotificationShelfController notificationShelfController = + mock(NotificationShelfController.class); NotificationShelf notificationShelf = mock(NotificationShelf.class); + when(notificationShelfController.getView()).thenReturn(notificationShelf); when(mNotificationSectionsManager.createSectionsForBuckets()).thenReturn( new NotificationSection[]{ mNotificationSection @@ -230,7 +234,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture()); mUserChangedListener = userChangedCaptor.getValue(); mStackScroller = spy(mStackScrollerInternal); - mStackScroller.setShelf(notificationShelf); + mStackScroller.setShelfController(notificationShelfController); mStackScroller.setStatusBar(mBar); mStackScroller.setScrimController(mock(ScrimController.class)); mStackScroller.setGroupManager(mGroupManager); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index c7434f6fd95f..bf4ccd22effd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -63,7 +63,7 @@ import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.FlingAnimationUtils; import com.android.systemui.statusbar.KeyguardAffordanceView; import com.android.systemui.statusbar.NotificationLockscreenUserManager; -import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.PulseExpansionHandler; import com.android.systemui.statusbar.StatusBarStateControllerImpl; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -115,7 +115,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { @Mock private HeadsUpManagerPhone mHeadsUpManager; @Mock - private NotificationShelf mNotificationShelf; + private NotificationShelfController mNotificationShelfController; @Mock private NotificationGroupManager mGroupManager; @Mock @@ -246,7 +246,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { mBiometricUnlockController, mStatusBarKeyguardViewManager, () -> mKeyguardClockSwitchController); mNotificationPanelViewController.initDependencies(mStatusBar, mGroupManager, - mNotificationShelf, mNotificationAreaController, mScrimController); + mNotificationShelfController, mNotificationAreaController, mScrimController); mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); mNotificationPanelViewController.setBar(mPanelBar); |