diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 1d17fd89bb45a..c4a58db4f41a5 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -52,6 +52,7 @@ import com.android.systemui.shared.system.smartspace.SmartspaceTransitionControl 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.NotifPipelineFlags; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotifPipeline; @@ -112,6 +113,7 @@ import dagger.Provides; LogModule.class, PeopleHubModule.class, PluginModule.class, + QsFrameTranslateModule.class, ScreenshotModule.class, SensorModule.class, SettingsModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java new file mode 100644 index 0000000000000..2e1762a26b7e5 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateController.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 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.plugins.qs.QS; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.phone.StatusBar; + +/** + * Calculates and moves the QS frame vertically. + */ +public abstract class QsFrameTranslateController { + + protected StatusBar mStatusBar; + + public QsFrameTranslateController(StatusBar statusBar) { + mStatusBar = statusBar; + } + + /** + * Calculate and translate the QS Frame on the Y-axis. + */ + public abstract void translateQsFrame(View qsFrame, QS qs, float overExpansion, + float qsTranslationForFullShadeTransition); + + /** + * Calculate the top padding for notifications panel. This could be the supplied + * @param expansionHeight or recalculate it for a different value. + */ + public abstract float getNotificationsTopPadding(float expansionHeight, + NotificationStackScrollLayoutController controller); +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java new file mode 100644 index 0000000000000..c15679709c3da --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2021 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.dagger.SysUISingleton; +import com.android.systemui.plugins.qs.QS; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; +import com.android.systemui.statusbar.phone.StatusBar; + +import javax.inject.Inject; + +/** + * Default implementation of QS Translation. This by default does not do much. + */ +@SysUISingleton +public class QsFrameTranslateImpl extends QsFrameTranslateController { + + @Inject + public QsFrameTranslateImpl(StatusBar statusBar) { + super(statusBar); + } + + @Override + public void translateQsFrame(View qsFrame, QS qs, float overExpansion, + float qsTranslationForFullShadeTransition) { + } + + @Override + public float getNotificationsTopPadding(float expansionHeight, + NotificationStackScrollLayoutController controller) { + + return expansionHeight; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateModule.java new file mode 100644 index 0000000000000..075adfcfc0e5e --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/QsFrameTranslateModule.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2021 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 com.android.systemui.dagger.SysUISingleton; + +import dagger.Binds; +import dagger.Module; + +@Module +public interface QsFrameTranslateModule { + + @Binds + @SysUISingleton + QsFrameTranslateController bindQsFrameTranslateController(QsFrameTranslateImpl impl); +} 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 db68ecf1fd18e..275074d19c3c7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -157,6 +157,7 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.PulseExpansionHandler; +import com.android.systemui.statusbar.QsFrameTranslateController; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -339,6 +340,7 @@ public class NotificationPanelViewController extends PanelViewController { private KeyguardStatusBarViewController mKeyguardStatusBarViewController; @VisibleForTesting QS mQs; private FrameLayout mQsFrame; + private QsFrameTranslateController mQsFrameTranslateController; @Nullable private CommunalHostViewController mCommunalViewController; private KeyguardStatusViewController mKeyguardStatusViewController; @@ -775,7 +777,8 @@ public class NotificationPanelViewController extends PanelViewController { NotificationRemoteInputManager remoteInputManager, Optional unfoldComponent, ControlsComponent controlsComponent, - InteractionJankMonitor interactionJankMonitor) { + InteractionJankMonitor interactionJankMonitor, + QsFrameTranslateController qsFrameTranslateController) { super(view, falsingManager, dozeLog, @@ -900,7 +903,6 @@ public class NotificationPanelViewController extends PanelViewController { mMaxKeyguardNotifications = resources.getInteger(R.integer.keyguard_max_notification_count); mKeyguardUnfoldTransition = unfoldComponent.map(c -> c.getKeyguardUnfoldTransition()); - mCommunalSourceCallback = () -> { mUiExecutor.execute(() -> setCommunalSource(null /*source*/)); }; @@ -908,7 +910,7 @@ public class NotificationPanelViewController extends PanelViewController { mCommunalSourceMonitorCallback = (source) -> { mUiExecutor.execute(() -> setCommunalSource(source)); }; - + mQsFrameTranslateController = qsFrameTranslateController; updateUserSwitcherFlags(); onFinishInflate(); } @@ -2667,7 +2669,8 @@ public class NotificationPanelViewController extends PanelViewController { (float) (mQsMaxExpansionHeight), computeQsExpansionFraction()); } else { - return mQsExpansionHeight; + return mQsFrameTranslateController.getNotificationsTopPadding(mQsExpansionHeight, + mNotificationStackScrollLayoutController); } } @@ -3251,8 +3254,8 @@ public class NotificationPanelViewController extends PanelViewController { } private void updateQsFrameTranslation() { - float translation = mOverExpansion / 2.0f + mQsTranslationForFullShadeTransition; - mQsFrame.setTranslationY(translation); + mQsFrameTranslateController.translateQsFrame(mQsFrame, mQs, mOverExpansion, + mQsTranslationForFullShadeTransition); } @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index 3ec9629e187a0..99800e4a628fb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -120,6 +120,7 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.NotificationShelfController; import com.android.systemui.statusbar.PulseExpansionHandler; +import com.android.systemui.statusbar.QsFrameTranslateController; import com.android.systemui.statusbar.StatusBarStateControllerImpl; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.VibratorHelper; @@ -354,6 +355,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { private InteractionJankMonitor mInteractionJankMonitor; @Mock private NotificationsQSContainerController mNotificationsQSContainerController; + @Mock + private QsFrameTranslateController mQsFrameTranslateController; private Optional mSysUIUnfoldComponent = Optional.empty(); private SysuiStatusBarStateController mStatusBarStateController; private NotificationPanelViewController mNotificationPanelViewController; @@ -530,7 +533,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mNotificationRemoteInputManager, mSysUIUnfoldComponent, mControlsComponent, - mInteractionJankMonitor); + mInteractionJankMonitor, + mQsFrameTranslateController); mNotificationPanelViewController.initDependencies( mStatusBar, () -> {},