summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lyn Han <lynhan@google.com> 2022-05-24 19:40:41 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-05-24 19:40:41 +0000
commit849235c84c1a321dcbf682a7e8c4cb5057de9b69 (patch)
tree8bfec7799725f6d297e512bea7d9c1b7fa749fb3
parent60cf6be172c9737779ca106a5d545f79864e3024 (diff)
parented0976bfa6fde3bc0e48428ccd0e16de52a8409b (diff)
Merge "Fix white line before shelf on lockscreen" into tm-dev am: 565c12dd94 am: ed0976bfa6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18132915 Change-Id: Iaa549961520a906a53c6dd799a7715166cd70867 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java49
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt51
3 files changed, 83 insertions, 27 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 491c1e186be3..398ab0a9f32b 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
@@ -191,7 +191,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private final boolean mDebugRemoveAnimation;
private int mContentHeight;
- private int mIntrinsicContentHeight;
+ private float mIntrinsicContentHeight;
private int mCollapsedSize;
private int mPaddingBetweenElements;
private int mMaxTopPadding;
@@ -802,7 +802,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
drawDebugInfo(canvas, y, Color.MAGENTA,
/* label= */ "mAmbientState.getStackY() + mContentHeight = " + y);
- y = (int) mAmbientState.getStackY() + mIntrinsicContentHeight;
+ y = (int) (mAmbientState.getStackY() + mIntrinsicContentHeight);
drawDebugInfo(canvas, y, Color.YELLOW,
/* label= */ "mAmbientState.getStackY() + mIntrinsicContentHeight = " + y);
@@ -1473,7 +1473,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
*/
@ShadeViewRefactor(RefactorComponent.COORDINATOR)
public int getIntrinsicContentHeight() {
- return mIntrinsicContentHeight;
+ return (int) mIntrinsicContentHeight;
}
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
@@ -2287,7 +2287,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private void updateContentHeight() {
final float scrimTopPadding = mAmbientState.isOnKeyguard() ? 0 : mMinimumPaddings;
final int shelfIntrinsicHeight = mShelf != null ? mShelf.getIntrinsicHeight() : 0;
- final int height =
+ final float height =
(int) scrimTopPadding + (int) mNotificationStackSizeCalculator.computeHeight(
/* notificationStackScrollLayout= */ this, mMaxDisplayedNotifications,
shelfIntrinsicHeight);
@@ -2295,7 +2295,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
// The topPadding can be bigger than the regular padding when qs is expanded, in that
// state the maxPanelHeight and the contentHeight should be bigger
- mContentHeight = height + Math.max(mIntrinsicPadding, mTopPadding) + mBottomPadding;
+ mContentHeight = (int) (height + Math.max(mIntrinsicPadding, mTopPadding) + mBottomPadding);
updateScrollability();
clampScrollPosition();
updateStackPosition();
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 799fee5e865d..4013254c6592 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
@@ -53,9 +53,9 @@ public class StackScrollAlgorithm {
private static final Boolean DEBUG = false;
private final ViewGroup mHostView;
- private int mPaddingBetweenElements;
- private int mGapHeight;
- private int mGapHeightOnLockscreen;
+ private float mPaddingBetweenElements;
+ private float mGapHeight;
+ private float mGapHeightOnLockscreen;
private int mCollapsedSize;
private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState();
@@ -127,13 +127,13 @@ public class StackScrollAlgorithm {
return getExpansionFractionWithoutShelf(mTempAlgorithmState, ambientState);
}
- private void log(String s) {
+ public static void log(String s) {
if (DEBUG) {
android.util.Log.i(TAG, s);
}
}
- public void logView(View view, String s) {
+ public static void logView(View view, String s) {
String viewString = "";
if (view instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = ((ExpandableNotificationRow) view);
@@ -535,30 +535,23 @@ public class StackScrollAlgorithm {
// more notifications than we should during this special transitional states.
boolean bypassPulseNotExpanding = ambientState.isBypassEnabled()
&& ambientState.isOnKeyguard() && !ambientState.isPulseExpanding();
- final int stackBottom =
- !ambientState.isShadeExpanded() || ambientState.isDozing()
- || bypassPulseNotExpanding
+ final float stackBottom = !ambientState.isShadeExpanded()
+ || ambientState.getDozeAmount() == 1f
+ || bypassPulseNotExpanding
? ambientState.getInnerHeight()
- : (int) ambientState.getStackHeight();
- final int shelfStart = stackBottom
+ : ambientState.getStackHeight();
+ final float shelfStart = stackBottom
- ambientState.getShelf().getIntrinsicHeight()
- mPaddingBetweenElements;
- viewState.yTranslation = Math.min(viewState.yTranslation, shelfStart);
- if (viewState.yTranslation >= shelfStart) {
- viewState.hidden = !view.isExpandAnimationRunning()
- && !view.hasExpandingChild();
- viewState.inShelf = true;
- // Notifications in the shelf cannot be visible HUNs.
- viewState.headsUpIsVisible = false;
- }
+ updateViewWithShelf(view, viewState, shelfStart);
}
}
// Clip height of view right before shelf.
viewState.height = (int) (getMaxAllowedChildHeight(view) * expansionFraction);
}
- algorithmState.mCurrentYPosition += viewState.height
- + expansionFraction * mPaddingBetweenElements;
+ algorithmState.mCurrentYPosition +=
+ expansionFraction * (getMaxAllowedChildHeight(view) + mPaddingBetweenElements);
algorithmState.mCurrentExpandedYPosition += view.getIntrinsicHeight()
+ mPaddingBetweenElements;
@@ -566,6 +559,18 @@ public class StackScrollAlgorithm {
viewState.yTranslation += ambientState.getStackY();
}
+ @VisibleForTesting
+ void updateViewWithShelf(ExpandableView view, ExpandableViewState viewState, float shelfStart) {
+ viewState.yTranslation = Math.min(viewState.yTranslation, shelfStart);
+ if (viewState.yTranslation >= shelfStart) {
+ viewState.hidden = !view.isExpandAnimationRunning()
+ && !view.hasExpandingChild();
+ viewState.inShelf = true;
+ // Notifications in the shelf cannot be visible HUNs.
+ viewState.headsUpIsVisible = false;
+ }
+ }
+
/**
* Get the gap height needed for before a view
*
@@ -849,13 +854,13 @@ public class StackScrollAlgorithm {
* Y position of the current view during updating children
* with expansion factor applied.
*/
- private int mCurrentYPosition;
+ private float mCurrentYPosition;
/**
* Y position of the current view during updating children
* without applying the expansion factor.
*/
- private int mCurrentExpandedYPosition;
+ private float mCurrentExpandedYPosition;
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
index 87ca1aa5eeb7..668f7526891a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
@@ -7,10 +7,13 @@ import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.EmptyShadeView
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
+import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.BypassController
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.google.common.truth.Truth.assertThat
+import junit.framework.Assert.assertFalse
+import junit.framework.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito.mock
@@ -110,4 +113,52 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
/* fractionToShade= */ 0f, /* onKeyguard= */ false)
assertThat(gap).isEqualTo(bigGap)
}
+
+ @Test
+ fun updateViewWithShelf_viewAboveShelf_viewShown() {
+ val viewStart = 0f
+ val shelfStart = 1f
+
+ val expandableView = mock(ExpandableView::class.java)
+ whenever(expandableView.isExpandAnimationRunning).thenReturn(false)
+ whenever(expandableView.hasExpandingChild()).thenReturn(false)
+
+ val expandableViewState = ExpandableViewState()
+ expandableViewState.yTranslation = viewStart
+
+ stackScrollAlgorithm.updateViewWithShelf(expandableView, expandableViewState, shelfStart);
+ assertFalse(expandableViewState.hidden)
+ }
+
+ @Test
+ fun updateViewWithShelf_viewBelowShelf_viewHidden() {
+ val shelfStart = 0f
+ val viewStart = 1f
+
+ val expandableView = mock(ExpandableView::class.java)
+ whenever(expandableView.isExpandAnimationRunning).thenReturn(false)
+ whenever(expandableView.hasExpandingChild()).thenReturn(false)
+
+ val expandableViewState = ExpandableViewState()
+ expandableViewState.yTranslation = viewStart
+
+ stackScrollAlgorithm.updateViewWithShelf(expandableView, expandableViewState, shelfStart);
+ assertTrue(expandableViewState.hidden)
+ }
+
+ @Test
+ fun updateViewWithShelf_viewBelowShelfButIsExpanding_viewShown() {
+ val shelfStart = 0f
+ val viewStart = 1f
+
+ val expandableView = mock(ExpandableView::class.java)
+ whenever(expandableView.isExpandAnimationRunning).thenReturn(true)
+ whenever(expandableView.hasExpandingChild()).thenReturn(true)
+
+ val expandableViewState = ExpandableViewState()
+ expandableViewState.yTranslation = viewStart
+
+ stackScrollAlgorithm.updateViewWithShelf(expandableView, expandableViewState, shelfStart);
+ assertFalse(expandableViewState.hidden)
+ }
}