diff options
| author | 2023-04-14 20:00:19 +0000 | |
|---|---|---|
| committer | 2023-04-17 22:14:33 +0000 | |
| commit | 1f774adcf4e68ee0038c75e6995618ae77c78875 (patch) | |
| tree | c1afe6a18fa8920450da626f6bd912b42c740611 | |
| parent | 53c8ac6f3fcdc6e6420aa05c2c5b2d6a2a08f437 (diff) | |
[Central Surfaces] Make NotificationShadeWindowView a singleton.
Bug: 277762009
Test: compiles; notification shade still works
Change-Id: I58546516fe6daa3efb9ab0879fd962caf08d8b00
4 files changed, 48 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 044dd6a47241..6dc19078c2c7 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -71,6 +71,7 @@ import com.android.systemui.screenshot.dagger.ScreenshotModule; import com.android.systemui.security.data.repository.SecurityRepositoryModule; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.shade.ShadeController; +import com.android.systemui.shade.ShadeModule; import com.android.systemui.shade.transition.LargeScreenShadeInterpolator; import com.android.systemui.shade.transition.LargeScreenShadeInterpolatorImpl; import com.android.systemui.smartspace.dagger.SmartspaceModule; @@ -174,6 +175,7 @@ import javax.inject.Named; SecurityRepositoryModule.class, ScreenRecordModule.class, SettingsUtilModule.class, + ShadeModule.class, SmartRepliesInflationModule.class, SmartspaceModule.class, StatusBarPipelineModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt new file mode 100644 index 000000000000..8adb21d3b44b --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 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.shade + +import android.view.LayoutInflater +import com.android.systemui.R +import com.android.systemui.dagger.SysUISingleton +import dagger.Module +import dagger.Provides + +/** Module for classes related to the notification shade. */ +@Module +abstract class ShadeModule { + companion object { + @Provides + @SysUISingleton + // TODO(b/277762009): Do something similar to + // {@link StatusBarWindowModule.InternalWindowView} so that only + // {@link NotificationShadeWindowViewController} can inject this view. + fun providesNotificationShadeWindowView( + layoutInflater: LayoutInflater, + ): NotificationShadeWindowView { + return layoutInflater.inflate(R.layout.super_notification_shade, /* root= */ null) + as NotificationShadeWindowView? + ?: throw IllegalStateException( + "R.layout.super_notification_shade could not be properly inflated" + ) + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index fab334c5ebc4..85142ca92f32 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1637,6 +1637,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNotificationShadeWindowView = mCentralSurfacesComponent.getNotificationShadeWindowView(); mNotificationShadeWindowViewController = mCentralSurfacesComponent .getNotificationShadeWindowViewController(); + // TODO(b/277762009): Inject [NotificationShadeWindowView] directly into the controller. + // (Right now, there's a circular dependency.) mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); mNotificationShadeWindowViewController.setupExpandedStatusBar(); NotificationPanelViewController npvc = 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 015ee7b5682a..7e226ad66b5e 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 @@ -98,21 +98,6 @@ public abstract class StatusBarViewModule { /** */ @Provides @CentralSurfacesComponent.CentralSurfacesScope - public static NotificationShadeWindowView providesNotificationShadeWindowView( - LayoutInflater layoutInflater) { - NotificationShadeWindowView notificationShadeWindowView = (NotificationShadeWindowView) - layoutInflater.inflate(R.layout.super_notification_shade, /* root= */ null); - if (notificationShadeWindowView == null) { - throw new IllegalStateException( - "R.layout.super_notification_shade could not be properly inflated"); - } - - return notificationShadeWindowView; - } - - /** */ - @Provides - @CentralSurfacesComponent.CentralSurfacesScope public static NotificationStackScrollLayout providesNotificationStackScrollLayout( NotificationShadeWindowView notificationShadeWindowView) { return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller); |