summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michał Brzeziński <brzezinski@google.com> 2021-12-17 00:37:58 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-12-17 00:37:58 +0000
commitcdb9fa739f6f03b6ba46b1aa2a3d241b591e6380 (patch)
tree91d501ae84c3193e7225e254755cefece733c7ef
parent27b46824cb637c4ed80fad7fffb546a5ab8abb0b (diff)
parenta3b5e2295b663389dcf97696da279532367d4ce0 (diff)
Merge "Fixing split shade going full black when changing density" into sc-v2-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java52
2 files changed, 44 insertions, 16 deletions
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 79231796577b..73a48c3b5cb0 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
@@ -411,7 +411,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private NotificationShelf mShelf;
private int mMaxDisplayedNotifications = -1;
private float mKeyguardBottomPadding = -1;
- private int mStatusBarHeight;
+ @VisibleForTesting int mStatusBarHeight;
private int mMinInteractionHeight;
private final Rect mClipRect = new Rect();
private boolean mIsClipped;
@@ -4851,8 +4851,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
public int getMinExpansionHeight() {
+ // shelf height is defined in dp but status bar height can be defined in px, that makes
+ // relation between them variable - sometimes one might be bigger than the other when
+ // changing density. That’s why we need to ensure we’re not subtracting negative value below
return mShelf.getIntrinsicHeight()
- - (mShelf.getIntrinsicHeight() - mStatusBarHeight + mWaterfallTopInset) / 2
+ - Math.max(0,
+ (mShelf.getIntrinsicHeight() - mStatusBarHeight + mWaterfallTopInset) / 2)
+ mWaterfallTopInset;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index 185d9cd8733e..326369b8e815 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -22,6 +22,7 @@ import static android.view.View.GONE;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE;
+import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static junit.framework.Assert.assertEquals;
@@ -103,6 +104,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
@Mock private NotificationSwipeHelper mNotificationSwipeHelper;
@Mock private NotificationStackScrollLayoutController mStackScrollLayoutController;
@Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
+ @Mock private NotificationShelf mNotificationShelf;
@Before
@UiThreadTest
@@ -124,13 +126,13 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mDependency.injectTestDependency(GroupMembershipManager.class, mGroupMembershipManger);
mDependency.injectTestDependency(GroupExpansionManager.class, mGroupExpansionManager);
mDependency.injectTestDependency(AmbientState.class, mAmbientState);
+ mDependency.injectTestDependency(NotificationShelf.class, mNotificationShelf);
mDependency.injectTestDependency(
UnlockedScreenOffAnimationController.class, mUnlockedScreenOffAnimationController);
NotificationShelfController notificationShelfController =
mock(NotificationShelfController.class);
- NotificationShelf notificationShelf = mock(NotificationShelf.class);
- when(notificationShelfController.getView()).thenReturn(notificationShelf);
+ when(notificationShelfController.getView()).thenReturn(mNotificationShelf);
when(mNotificationSectionsManager.createSectionsForBuckets()).thenReturn(
new NotificationSection[]{
mNotificationSection
@@ -160,7 +162,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
anyBoolean());
doNothing().when(mGroupExpansionManager).collapseGroups();
doNothing().when(mExpandHelper).cancelImmediately();
- doNothing().when(notificationShelf).setAnimationsEnabled(anyBoolean());
+ doNothing().when(mNotificationShelf).setAnimationsEnabled(anyBoolean());
}
@Test
@@ -203,21 +205,43 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
@Test
@UiThreadTest
- public void testSetExpandedHeight_blockingHelperManagerReceivedCallbacks() {
- final float[] expectedHeight = {0f};
- final float[] expectedAppear = {0f};
+ public void testSetExpandedHeight_listenerReceivedCallbacks() {
+ final float expectedHeight = 0f;
mStackScroller.addOnExpandedHeightChangedListener((height, appear) -> {
- Assert.assertEquals(expectedHeight[0], height, 0);
- Assert.assertEquals(expectedAppear[0], appear, .1);
+ Assert.assertEquals(expectedHeight, height, 0);
});
- expectedHeight[0] = 1f;
- expectedAppear[0] = 1f;
- mStackScroller.setExpandedHeight(expectedHeight[0]);
+ mStackScroller.setExpandedHeight(expectedHeight);
+ }
- expectedHeight[0] = 100f;
- expectedAppear[0] = 0f;
- mStackScroller.setExpandedHeight(expectedHeight[0]);
+ @Test
+ public void testAppearFractionCalculation() {
+ // appear start position
+ when(mNotificationShelf.getIntrinsicHeight()).thenReturn(100);
+ // because it's the same as shelf height, appear start position equals shelf height
+ mStackScroller.mStatusBarHeight = 100;
+ // appear end position
+ when(mEmptyShadeView.getHeight()).thenReturn(200);
+
+ assertEquals(0f, mStackScroller.calculateAppearFraction(100));
+ assertEquals(1f, mStackScroller.calculateAppearFraction(200));
+ assertEquals(0.5f, mStackScroller.calculateAppearFraction(150));
+ }
+
+ @Test
+ public void testAppearFractionCalculationIsNotNegativeWhenShelfBecomesSmaller() {
+ // this situation might occur if status bar height is defined in pixels while shelf height
+ // in dp and screen density changes - appear start position
+ // (calculated in NSSL#getMinExpansionHeight) that is adjusting for status bar might
+ // increase and become bigger that end position, which should be prevented
+
+ // appear start position
+ when(mNotificationShelf.getIntrinsicHeight()).thenReturn(80);
+ mStackScroller.mStatusBarHeight = 100;
+ // appear end position
+ when(mEmptyShadeView.getHeight()).thenReturn(90);
+
+ assertThat(mStackScroller.calculateAppearFraction(100)).isAtLeast(0);
}
@Test