diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java index 78ebe9bcbb9e5..b8ff298b532c0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java @@ -18,11 +18,9 @@ package com.android.systemui.statusbar; import android.content.Context; import android.view.LayoutInflater; -import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; -import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.phone.StatusBarWindowView; import com.android.systemui.util.InjectionInflationController; @@ -37,18 +35,14 @@ public class SuperStatusBarViewFactory { private final Context mContext; private final InjectionInflationController mInjectionInflationController; - private final NotificationShelfComponent.Builder mNotificationShelfComponentBuilder; private StatusBarWindowView mStatusBarWindowView; - private NotificationShelfController mNotificationShelfController; @Inject public SuperStatusBarViewFactory(Context context, - InjectionInflationController injectionInflationController, - NotificationShelfComponent.Builder notificationShelfComponentBuilder) { + InjectionInflationController injectionInflationController) { mContext = context; mInjectionInflationController = injectionInflationController; - mNotificationShelfComponentBuilder = notificationShelfComponentBuilder; } /** @@ -70,36 +64,4 @@ public class SuperStatusBarViewFactory { } return mStatusBarWindowView; } - - /** - * Gets the inflated {@link NotificationShelf} from - * {@link R.layout#status_bar_notification_shelf}. - * Returns a cached instance, if it has already been inflated. - * - * @param container the expected container to hold the {@link NotificationShelf}. The view - * isn't immediately attached, but the layout params of this view is used - * during inflation. - */ - public NotificationShelfController getNotificationShelfController(ViewGroup container) { - if (mNotificationShelfController != null) { - return mNotificationShelfController; - } - - NotificationShelf view = (NotificationShelf) LayoutInflater.from(mContext) - .inflate(R.layout.status_bar_notification_shelf, container, /* attachToRoot= */ - false); - - if (view == null) { - throw new IllegalStateException( - "R.layout.status_bar_notification_shelf could not be properly inflated"); - } - - NotificationShelfComponent component = mNotificationShelfComponentBuilder - .notificationShelf(view) - .build(); - mNotificationShelfController = component.getNotificationShelfController(); - mNotificationShelfController.init(); - - return mNotificationShelfController; - } } 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 dda67e7923b94..154b04782a66a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1107,14 +1107,10 @@ public class StatusBar extends SystemUI implements // TODO: Deal with the ugliness that comes from having some of the statusbar broken out // into fragments, but the rest here, it leaves some awkward lifecycle and whatnot. - mStackScrollerController = - mNotificationPanelViewController.getNotificationStackScrollLayoutController(); - mStackScroller = mStackScrollerController.getView(); NotificationListContainer notifListContainer = mStackScrollerController.getNotificationListContainer(); mNotificationLogger.setUpWithContainer(notifListContainer); - inflateShelf(); mNotificationIconAreaController.setupShelf(mNotificationShelfController); mNotificationPanelViewController.addExpansionListener(mWakeUpCoordinator); mNotificationPanelViewController.addExpansionListener( @@ -1526,11 +1522,6 @@ public class StatusBar extends SystemUI implements }; } - private void inflateShelf() { - mNotificationShelfController = mSuperStatusBarViewFactory - .getNotificationShelfController(mStackScroller); - } - private void inflateStatusBarWindow() { StatusBarComponent statusBarComponent = mStatusBarComponentFactory.create(); mNotificationShadeWindowView = statusBarComponent.getNotificationShadeWindowView(); @@ -1542,7 +1533,10 @@ public class StatusBar extends SystemUI implements mPhoneStatusBarWindow = mSuperStatusBarViewFactory.getStatusBarWindowView(); mNotificationPanelViewController = statusBarComponent.getNotificationPanelViewController(); statusBarComponent.getLockIconViewController().init(); + mStackScrollerController = statusBarComponent.getNotificationStackScrollLayoutController(); + mStackScroller = mStackScrollerController.getView(); + mNotificationShelfController = statusBarComponent.getNotificationShelfController(); mAuthRippleController = statusBarComponent.getAuthRippleController(); mAuthRippleController.init(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java index a5ff9e2fdf96f..418f5884ef62e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java @@ -20,6 +20,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.keyguard.LockIconViewController; import com.android.systemui.biometrics.AuthRippleController; +import com.android.systemui.statusbar.NotificationShelfController; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; @@ -65,6 +67,14 @@ public interface StatusBarComponent { @StatusBarScope NotificationShadeWindowView getNotificationShadeWindowView(); + /** */ + @StatusBarScope + NotificationShelfController getNotificationShelfController(); + + /** */ + @StatusBarScope + NotificationStackScrollLayoutController getNotificationStackScrollLayoutController(); + /** * Creates a NotificationShadeWindowViewController. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index c5fba13dde3cb..ecf3b86561b90 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -25,6 +25,11 @@ import com.android.keyguard.LockIconView; import com.android.systemui.R; import com.android.systemui.battery.BatteryMeterView; import com.android.systemui.biometrics.AuthRippleView; +import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.NotificationShelfController; +import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.TapAgainView; @@ -58,6 +63,45 @@ public abstract class StatusBarViewModule { return notificationShadeWindowView; } + /** */ + @Provides + @StatusBarComponent.StatusBarScope + public static NotificationStackScrollLayout providesNotificationStackScrollLayout( + NotificationStackScrollLayoutController notificationStackScrollLayoutController) { + return notificationStackScrollLayoutController.getView(); + } + + /** */ + @Provides + @StatusBarComponent.StatusBarScope + public static NotificationShelf providesNotificationShelf(LayoutInflater layoutInflater, + NotificationStackScrollLayout notificationStackScrollLayout) { + NotificationShelf view = (NotificationShelf) layoutInflater.inflate( + R.layout.status_bar_notification_shelf, notificationStackScrollLayout, false); + + if (view == null) { + throw new IllegalStateException( + "R.layout.status_bar_notification_shelf could not be properly inflated"); + } + return view; + } + + /** */ + @Provides + @StatusBarComponent.StatusBarScope + public static NotificationShelfController providesStatusBarWindowView( + NotificationShelfComponent.Builder notificationShelfComponentBuilder, + NotificationShelf notificationShelf) { + NotificationShelfComponent component = notificationShelfComponentBuilder + .notificationShelf(notificationShelf) + .build(); + NotificationShelfController notificationShelfController = + component.getNotificationShelfController(); + notificationShelfController.init(); + + return notificationShelfController; + } + /** */ @Provides @StatusBarComponent.StatusBarScope