From ed6a57d4571adda3949977fde970474346d081db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Go=CC=88llner?= Date: Tue, 17 Jan 2023 16:32:58 +0100 Subject: [PATCH] Split-shade: fix notification scrim position when there is a horizontal display cutout. Notification scrim coordinates were being set without taking into account horizontal insets coming from display cutouts such as notches or cameras. Test: manually on-device. Setting a handheld device to have smallest width of 600dp and rotating it horizontally in both directions. Fixes: 231769989 Change-Id: Ie19195ea5c76729a6795c6ebac263ec591b7d2e2 --- .../NotificationPanelViewController.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index ecaabce70f8af..2ea49bb31cab2 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -447,6 +447,7 @@ public final class NotificationPanelViewController implements Dumpable { private float mDownY; private int mDisplayTopInset = 0; // in pixels private int mDisplayRightInset = 0; // in pixels + private int mDisplayLeftInset = 0; // in pixels private int mLargeScreenShadeHeaderHeight; private int mSplitShadeNotificationsScrimMarginBottom; @@ -2983,7 +2984,7 @@ public final class NotificationPanelViewController implements Dumpable { // left bounds can ignore insets, it should always reach the edge of the screen return 0; } else { - return mNotificationStackScrollLayoutController.getLeft(); + return mNotificationStackScrollLayoutController.getLeft() + mDisplayLeftInset; } } @@ -2991,7 +2992,7 @@ public final class NotificationPanelViewController implements Dumpable { if (mIsFullWidth) { return mView.getRight() + mDisplayRightInset; } else { - return mNotificationStackScrollLayoutController.getRight(); + return mNotificationStackScrollLayoutController.getRight() + mDisplayLeftInset; } } @@ -3115,8 +3116,8 @@ public final class NotificationPanelViewController implements Dumpable { // Convert global clipping coordinates to local ones, // relative to NotificationStackScrollLayout - int nsslLeft = left - mNotificationStackScrollLayoutController.getLeft(); - int nsslRight = right - mNotificationStackScrollLayoutController.getLeft(); + int nsslLeft = calculateNsslLeft(left); + int nsslRight = calculateNsslRight(right); int nsslTop = getNotificationsClippingTopBounds(top); int nsslBottom = bottom - mNotificationStackScrollLayoutController.getTop(); int bottomRadius = mSplitShadeEnabled ? radius : 0; @@ -3125,6 +3126,22 @@ public final class NotificationPanelViewController implements Dumpable { nsslLeft, nsslTop, nsslRight, nsslBottom, topRadius, bottomRadius); } + private int calculateNsslLeft(int nsslLeftAbsolute) { + int left = nsslLeftAbsolute - mNotificationStackScrollLayoutController.getLeft(); + if (mIsFullWidth) { + return left; + } + return left - mDisplayLeftInset; + } + + private int calculateNsslRight(int nsslRightAbsolute) { + int right = nsslRightAbsolute - mNotificationStackScrollLayoutController.getLeft(); + if (mIsFullWidth) { + return right; + } + return right - mDisplayLeftInset; + } + private int getNotificationsClippingTopBounds(int qsTop) { if (mSplitShadeEnabled && mExpandingFromHeadsUp) { // in split shade nssl has extra top margin so clipping at top 0 is not enough, we need @@ -4522,6 +4539,7 @@ public final class NotificationPanelViewController implements Dumpable { ipw.print("mDownY="); ipw.println(mDownY); ipw.print("mDisplayTopInset="); ipw.println(mDisplayTopInset); ipw.print("mDisplayRightInset="); ipw.println(mDisplayRightInset); + ipw.print("mDisplayLeftInset="); ipw.println(mDisplayLeftInset); ipw.print("mLargeScreenShadeHeaderHeight="); ipw.println(mLargeScreenShadeHeaderHeight); ipw.print("mSplitShadeNotificationsScrimMarginBottom="); ipw.println(mSplitShadeNotificationsScrimMarginBottom); @@ -5898,6 +5916,7 @@ public final class NotificationPanelViewController implements Dumpable { Insets combinedInsets = insets.getInsetsIgnoringVisibility(insetTypes); mDisplayTopInset = combinedInsets.top; mDisplayRightInset = combinedInsets.right; + mDisplayLeftInset = combinedInsets.left; mNavigationBarBottomHeight = insets.getStableInsetBottom(); updateMaxHeadsUpTranslation();