diff options
10 files changed, 167 insertions, 20 deletions
diff --git a/packages/SystemUI/res/layout/super_notification_shade.xml b/packages/SystemUI/res/layout/super_notification_shade.xml index 8388b67c1fa1..bafdb11ab211 100644 --- a/packages/SystemUI/res/layout/super_notification_shade.xml +++ b/packages/SystemUI/res/layout/super_notification_shade.xml @@ -26,12 +26,12 @@ android:fitsSystemWindows="true"> <com.android.systemui.statusbar.BackDropView - android:id="@+id/backdrop" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone" - sysui:ignoreRightInset="true" - > + android:id="@+id/backdrop" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + sysui:ignoreRightInset="true" + > <ImageView android:id="@+id/backdrop_back" android:layout_width="match_parent" android:scaleType="centerCrop" @@ -49,7 +49,7 @@ android:layout_height="match_parent" android:importantForAccessibility="no" sysui:ignoreRightInset="true" - /> + /> <com.android.systemui.scrim.ScrimView android:id="@+id/scrim_notifications" @@ -57,17 +57,17 @@ android:layout_height="match_parent" android:importantForAccessibility="no" sysui:ignoreRightInset="true" - /> + /> <com.android.systemui.statusbar.LightRevealScrim - android:id="@+id/light_reveal_scrim" - android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:id="@+id/light_reveal_scrim" + android:layout_width="match_parent" + android:layout_height="match_parent" /> <include layout="@layout/status_bar_expanded" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="invisible" /> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="invisible" /> <include layout="@layout/brightness_mirror_container" /> diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java index d3555eec0243..b30e0c22e566 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java @@ -17,6 +17,7 @@ package com.android.systemui.dagger; import com.android.systemui.keyguard.KeyguardQuickAffordanceProvider; +import com.android.systemui.statusbar.NotificationInsetsModule; import com.android.systemui.statusbar.QsFrameTranslateModule; import dagger.Subcomponent; @@ -28,6 +29,7 @@ import dagger.Subcomponent; @Subcomponent(modules = { DefaultComponentBinder.class, DependencyProvider.class, + NotificationInsetsModule.class, QsFrameTranslateModule.class, SystemUIBinder.class, SystemUIModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java index a14b0ee04d8a..6dc4f5c60108 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java @@ -28,6 +28,7 @@ import com.android.systemui.keyguard.KeyguardSliceProvider; import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionCli; import com.android.systemui.media.nearby.NearbyMediaDevicesManager; import com.android.systemui.people.PeopleProvider; +import com.android.systemui.statusbar.NotificationInsetsModule; import com.android.systemui.statusbar.QsFrameTranslateModule; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.unfold.FoldStateLogger; @@ -65,6 +66,7 @@ import dagger.Subcomponent; @Subcomponent(modules = { DefaultComponentBinder.class, DependencyProvider.class, + NotificationInsetsModule.class, QsFrameTranslateModule.class, SystemUIBinder.class, SystemUIModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java index 400b0baea01b..6acf417f0ea6 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java @@ -24,6 +24,7 @@ import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG; import android.annotation.ColorInt; import android.annotation.DrawableRes; import android.annotation.LayoutRes; +import android.annotation.Nullable; import android.content.Context; import android.content.res.Configuration; import android.content.res.TypedArray; @@ -36,6 +37,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Trace; import android.util.AttributeSet; +import android.util.Pair; import android.view.ActionMode; import android.view.DisplayCutout; import android.view.InputQueue; @@ -74,6 +76,7 @@ public class NotificationShadeWindowView extends FrameLayout { private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener; private InteractionEventHandler mInteractionEventHandler; + private LayoutInsetsController mLayoutInsetProvider; public NotificationShadeWindowView(Context context, AttributeSet attrs) { super(context, attrs); @@ -108,12 +111,10 @@ public class NotificationShadeWindowView extends FrameLayout { mLeftInset = 0; mRightInset = 0; DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout(); - if (displayCutout != null) { - mLeftInset = displayCutout.getSafeInsetLeft(); - mRightInset = displayCutout.getSafeInsetRight(); - } - mLeftInset = Math.max(insets.left, mLeftInset); - mRightInset = Math.max(insets.right, mRightInset); + Pair<Integer, Integer> pairInsets = mLayoutInsetProvider + .getinsets(windowInsets, displayCutout); + mLeftInset = pairInsets.first; + mRightInset = pairInsets.second; applyMargins(); return windowInsets; } @@ -172,6 +173,10 @@ public class NotificationShadeWindowView extends FrameLayout { mInteractionEventHandler = listener; } + protected void setLayoutInsetsController(LayoutInsetsController provider) { + mLayoutInsetProvider = provider; + } + @Override public boolean dispatchTouchEvent(MotionEvent ev) { Boolean result = mInteractionEventHandler.handleDispatchTouchEvent(ev); @@ -353,6 +358,18 @@ public class NotificationShadeWindowView extends FrameLayout { } } + /** + * Controller responsible for calculating insets for the shade window. + */ + public interface LayoutInsetsController { + + /** + * Update the insets and calculate them accordingly. + */ + Pair<Integer, Integer> getinsets(@Nullable WindowInsets windowInsets, + @Nullable DisplayCutout displayCutout); + } + interface InteractionEventHandler { /** * Returns a result for {@link ViewGroup#dispatchTouchEvent(MotionEvent)} or null to defer diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java index bb67280c07b8..8379e51f7449 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java @@ -42,6 +42,7 @@ import com.android.systemui.keyguard.ui.binder.KeyguardBouncerViewBinder; import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel; import com.android.systemui.statusbar.DragDownHelper; import com.android.systemui.statusbar.LockscreenShadeTransitionController; +import com.android.systemui.statusbar.NotificationInsetsController; import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -76,6 +77,7 @@ public class NotificationShadeWindowViewController { private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; private final AmbientState mAmbientState; private final PulsingGestureListener mPulsingGestureListener; + private final NotificationInsetsController mNotificationInsetsController; private GestureDetector mPulsingWakeupGestureHandler; private View mBrightnessMirror; @@ -111,6 +113,7 @@ public class NotificationShadeWindowViewController { CentralSurfaces centralSurfaces, NotificationShadeWindowController controller, KeyguardUnlockAnimationController keyguardUnlockAnimationController, + NotificationInsetsController notificationInsetsController, AmbientState ambientState, PulsingGestureListener pulsingGestureListener, FeatureFlags featureFlags, @@ -134,6 +137,7 @@ public class NotificationShadeWindowViewController { mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; mAmbientState = ambientState; mPulsingGestureListener = pulsingGestureListener; + mNotificationInsetsController = notificationInsetsController; // This view is not part of the newly inflated expanded status bar. mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container); @@ -165,6 +169,7 @@ public class NotificationShadeWindowViewController { mPulsingWakeupGestureHandler = new GestureDetector(mView.getContext(), mPulsingGestureListener); + mView.setLayoutInsetsController(mNotificationInsetsController); mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() { @Override public Boolean handleDispatchTouchEvent(MotionEvent ev) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsController.java new file mode 100644 index 000000000000..39d7d6675ed4 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsController.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 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.shade.NotificationShadeWindowView; + +/** + * Calculates insets for the notification shade window view. + */ +public abstract class NotificationInsetsController + implements NotificationShadeWindowView.LayoutInsetsController { +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsImpl.java new file mode 100644 index 000000000000..1ed704e66c76 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsImpl.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2022 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 static android.view.WindowInsets.Type.systemBars; + +import android.annotation.Nullable; +import android.graphics.Insets; +import android.util.Pair; +import android.view.DisplayCutout; +import android.view.WindowInsets; + +import com.android.systemui.dagger.SysUISingleton; + +import javax.inject.Inject; + +/** + * Default implementation of NotificationsInsetsController. + */ +@SysUISingleton +public class NotificationInsetsImpl extends NotificationInsetsController { + + @Inject + public NotificationInsetsImpl() { + + } + + @Override + public Pair<Integer, Integer> getinsets(@Nullable WindowInsets windowInsets, + @Nullable DisplayCutout displayCutout) { + final Insets insets = windowInsets.getInsetsIgnoringVisibility(systemBars()); + int leftInset = 0; + int rightInset = 0; + + if (displayCutout != null) { + leftInset = displayCutout.getSafeInsetLeft(); + rightInset = displayCutout.getSafeInsetRight(); + } + leftInset = Math.max(insets.left, leftInset); + rightInset = Math.max(insets.right, rightInset); + + return new Pair(leftInset, rightInset); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsModule.java new file mode 100644 index 000000000000..614bc0f1a6f4 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInsetsModule.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 NotificationInsetsModule { + + @Binds + @SysUISingleton + NotificationInsetsController bindNotificationInsetsController(NotificationInsetsImpl impl); +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt index db7e017e379e..c3207c2f58a5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt @@ -33,6 +33,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler import com.android.systemui.statusbar.LockscreenShadeTransitionController +import com.android.systemui.statusbar.NotificationInsetsController import com.android.systemui.statusbar.NotificationShadeDepthController import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.SysuiStatusBarStateController @@ -94,6 +95,8 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController @Mock private lateinit var pulsingGestureListener: PulsingGestureListener + @Mock + private lateinit var notificationInsetsController: NotificationInsetsController @Mock lateinit var keyguardBouncerComponentFactory: KeyguardBouncerComponent.Factory @Mock lateinit var keyguardBouncerContainer: ViewGroup @Mock lateinit var keyguardBouncerComponent: KeyguardBouncerComponent @@ -124,6 +127,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { centralSurfaces, notificationShadeWindowController, keyguardUnlockAnimationController, + notificationInsetsController, ambientState, pulsingGestureListener, featureFlags, diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.java index a6c80ab649e5..4bf00c4ccb51 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.java @@ -43,6 +43,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel; import com.android.systemui.statusbar.DragDownHelper; import com.android.systemui.statusbar.LockscreenShadeTransitionController; +import com.android.systemui.statusbar.NotificationInsetsController; import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -91,6 +92,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase { @Mock private FeatureFlags mFeatureFlags; @Mock private KeyguardBouncerViewModel mKeyguardBouncerViewModel; @Mock private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory; + @Mock private NotificationInsetsController mNotificationInsetsController; @Captor private ArgumentCaptor<NotificationShadeWindowView.InteractionEventHandler> mInteractionEventHandlerCaptor; @@ -125,6 +127,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase { mCentralSurfaces, mNotificationShadeWindowController, mKeyguardUnlockAnimationController, + mNotificationInsetsController, mAmbientState, mPulsingGestureListener, mFeatureFlags, |