From 7c60dad05705dfb4c85b60b71c549c3a29269c2e Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Fri, 2 Sep 2022 12:49:14 -0700 Subject: [PATCH] Refactor around NSSL to open up some more APIs for subcomponents. Bug: 251207888 Test: make GoldfishPcSystemUI Change-Id: Ie84504e7c4d4f2c48a431ee70f2ad6e5082ba955 --- .../com/android/systemui/dagger/SysUIComponent.java | 2 ++ .../com/android/systemui/dagger/SystemUIModule.java | 2 -- .../shade/NotificationPanelViewController.java | 5 +++-- .../statusbar/QsFrameTranslateController.java | 3 +-- .../systemui/statusbar/QsFrameTranslateImpl.java | 6 ++++-- .../stack/NotificationStackScrollLayout.java | 4 ++++ .../notification/stack/StackScrollAlgorithm.java | 11 +++++++++-- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java index 0d06c513d248b..f889e8e33cb75 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java @@ -31,6 +31,7 @@ import com.android.systemui.media.taptotransfer.MediaTttCommandLineHelper; import com.android.systemui.media.taptotransfer.receiver.MediaTttChipControllerReceiver; import com.android.systemui.media.taptotransfer.sender.MediaTttChipControllerSender; import com.android.systemui.people.PeopleProvider; +import com.android.systemui.statusbar.QsFrameTranslateModule; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.unfold.FoldStateLogger; import com.android.systemui.unfold.FoldStateLoggingProvider; @@ -66,6 +67,7 @@ import dagger.Subcomponent; @Subcomponent(modules = { DefaultComponentBinder.class, DependencyProvider.class, + QsFrameTranslateModule.class, SystemUIBinder.class, SystemUIModule.class, SystemUICoreStartableModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index d70b971dba141..dc3dadb326698 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -61,7 +61,6 @@ import com.android.systemui.smartspace.dagger.SmartspaceModule; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationShadeWindowController; -import com.android.systemui.statusbar.QsFrameTranslateModule; import com.android.systemui.statusbar.notification.collection.NotifPipeline; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; @@ -133,7 +132,6 @@ import dagger.Provides; PeopleModule.class, PluginModule.class, PrivacyModule.class, - QsFrameTranslateModule.class, ScreenshotModule.class, SensorModule.class, MultiUserUtilsModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 11103861f70b4..33508729f42c9 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -3385,8 +3385,9 @@ public final class NotificationPanelViewController extends PanelViewController { } private void updateQsFrameTranslation() { - mQsFrameTranslateController.translateQsFrame(mQsFrame, mQs, mOverExpansion, - mQsTranslationForFullShadeTransition); + mQsFrameTranslateController.translateQsFrame(mQsFrame, mQs, + mNavigationBarBottomHeight + mAmbientState.getStackTopMargin()); + } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java index 78077386179aa..59afb18195dd6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java @@ -36,8 +36,7 @@ public abstract class QsFrameTranslateController { /** * Calculate and translate the QS Frame on the Y-axis. */ - public abstract void translateQsFrame(View qsFrame, QS qs, float overExpansion, - float qsTranslationForFullShadeTransition); + public abstract void translateQsFrame(View qsFrame, QS qs, int bottomInset); /** * Calculate the top padding for notifications panel. This could be the supplied diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java index 33e224579bef3..85b522cbd9d54 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java @@ -27,6 +27,8 @@ import javax.inject.Inject; /** * Default implementation of QS Translation. This by default does not do much. + * This class can be subclassed to allow System UI variants the flexibility to change position of + * the Quick Settings frame. */ @SysUISingleton public class QsFrameTranslateImpl extends QsFrameTranslateController { @@ -37,8 +39,8 @@ public class QsFrameTranslateImpl extends QsFrameTranslateController { } @Override - public void translateQsFrame(View qsFrame, QS qs, float overExpansion, - float qsTranslationForFullShadeTransition) { + public void translateQsFrame(View qsFrame, QS qs, int bottomInset) { + // Empty implementation by default, meant to be overridden by subclasses. } @Override 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 836cacc185c62..55c577f1ea39e 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 @@ -1115,6 +1115,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable updateAlgorithmLayoutMinHeight(); updateOwnTranslationZ(); + // Give The Algorithm information regarding the QS height so it can layout notifications + // properly. Needed for some devices that grows notifications down-to-top + mStackScrollAlgorithm.updateQSFrameTop(mQsHeader == null ? 0 : mQsHeader.getHeight()); + // Once the layout has finished, we don't need to animate any scrolling clampings anymore. mAnimateStackYForContentHeightChange = false; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index 8d28f7524f9a7..0502159f46cd7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -416,13 +416,20 @@ public class StackScrollAlgorithm { return i > 0 ? algorithmState.visibleChildren.get(i - 1) : null; } + /** + * Update the position of QS Frame. + */ + public void updateQSFrameTop(int qsHeight) { + // Intentionally empty for sub-classes in other device form factors to override + } + /** * Determine the positions for the views. This is the main part of the algorithm. * * @param algorithmState The state in which the current pass of the algorithm is currently in * @param ambientState The current ambient state */ - private void updatePositionsForState(StackScrollAlgorithmState algorithmState, + protected void updatePositionsForState(StackScrollAlgorithmState algorithmState, AmbientState ambientState) { if (!ambientState.isOnKeyguard() || (ambientState.isBypassEnabled() && ambientState.isPulseExpanding())) { @@ -448,7 +455,7 @@ public class StackScrollAlgorithm { * @return Fraction to apply to view height and gap between views. * Does not include shelf height even if shelf is showing. */ - private float getExpansionFractionWithoutShelf( + protected float getExpansionFractionWithoutShelf( StackScrollAlgorithmState algorithmState, AmbientState ambientState) {