Merge "Fix white line before shelf on lockscreen" into tm-dev

This commit is contained in:
Lyn Han
2022-05-24 19:34:01 +00:00
committed by Android (Google) Code Review
3 changed files with 83 additions and 27 deletions

View File

@@ -191,7 +191,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private final boolean mDebugRemoveAnimation; private final boolean mDebugRemoveAnimation;
private int mContentHeight; private int mContentHeight;
private int mIntrinsicContentHeight; private float mIntrinsicContentHeight;
private int mCollapsedSize; private int mCollapsedSize;
private int mPaddingBetweenElements; private int mPaddingBetweenElements;
private int mMaxTopPadding; private int mMaxTopPadding;
@@ -802,7 +802,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
drawDebugInfo(canvas, y, Color.MAGENTA, drawDebugInfo(canvas, y, Color.MAGENTA,
/* label= */ "mAmbientState.getStackY() + mContentHeight = " + y); /* label= */ "mAmbientState.getStackY() + mContentHeight = " + y);
y = (int) mAmbientState.getStackY() + mIntrinsicContentHeight; y = (int) (mAmbientState.getStackY() + mIntrinsicContentHeight);
drawDebugInfo(canvas, y, Color.YELLOW, drawDebugInfo(canvas, y, Color.YELLOW,
/* label= */ "mAmbientState.getStackY() + mIntrinsicContentHeight = " + y); /* label= */ "mAmbientState.getStackY() + mIntrinsicContentHeight = " + y);
@@ -1473,7 +1473,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
*/ */
@ShadeViewRefactor(RefactorComponent.COORDINATOR) @ShadeViewRefactor(RefactorComponent.COORDINATOR)
public int getIntrinsicContentHeight() { public int getIntrinsicContentHeight() {
return mIntrinsicContentHeight; return (int) mIntrinsicContentHeight;
} }
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
@@ -2287,7 +2287,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private void updateContentHeight() { private void updateContentHeight() {
final float scrimTopPadding = mAmbientState.isOnKeyguard() ? 0 : mMinimumPaddings; final float scrimTopPadding = mAmbientState.isOnKeyguard() ? 0 : mMinimumPaddings;
final int shelfIntrinsicHeight = mShelf != null ? mShelf.getIntrinsicHeight() : 0; final int shelfIntrinsicHeight = mShelf != null ? mShelf.getIntrinsicHeight() : 0;
final int height = final float height =
(int) scrimTopPadding + (int) mNotificationStackSizeCalculator.computeHeight( (int) scrimTopPadding + (int) mNotificationStackSizeCalculator.computeHeight(
/* notificationStackScrollLayout= */ this, mMaxDisplayedNotifications, /* notificationStackScrollLayout= */ this, mMaxDisplayedNotifications,
shelfIntrinsicHeight); 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 // The topPadding can be bigger than the regular padding when qs is expanded, in that
// state the maxPanelHeight and the contentHeight should be bigger // 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(); updateScrollability();
clampScrollPosition(); clampScrollPosition();
updateStackPosition(); updateStackPosition();

View File

@@ -53,9 +53,9 @@ public class StackScrollAlgorithm {
private static final Boolean DEBUG = false; private static final Boolean DEBUG = false;
private final ViewGroup mHostView; private final ViewGroup mHostView;
private int mPaddingBetweenElements; private float mPaddingBetweenElements;
private int mGapHeight; private float mGapHeight;
private int mGapHeightOnLockscreen; private float mGapHeightOnLockscreen;
private int mCollapsedSize; private int mCollapsedSize;
private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState(); private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState();
@@ -127,13 +127,13 @@ public class StackScrollAlgorithm {
return getExpansionFractionWithoutShelf(mTempAlgorithmState, ambientState); return getExpansionFractionWithoutShelf(mTempAlgorithmState, ambientState);
} }
private void log(String s) { public static void log(String s) {
if (DEBUG) { if (DEBUG) {
android.util.Log.i(TAG, s); android.util.Log.i(TAG, s);
} }
} }
public void logView(View view, String s) { public static void logView(View view, String s) {
String viewString = ""; String viewString = "";
if (view instanceof ExpandableNotificationRow) { if (view instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = ((ExpandableNotificationRow) view); ExpandableNotificationRow row = ((ExpandableNotificationRow) view);
@@ -535,14 +535,32 @@ public class StackScrollAlgorithm {
// more notifications than we should during this special transitional states. // more notifications than we should during this special transitional states.
boolean bypassPulseNotExpanding = ambientState.isBypassEnabled() boolean bypassPulseNotExpanding = ambientState.isBypassEnabled()
&& ambientState.isOnKeyguard() && !ambientState.isPulseExpanding(); && ambientState.isOnKeyguard() && !ambientState.isPulseExpanding();
final int stackBottom = final float stackBottom = !ambientState.isShadeExpanded()
!ambientState.isShadeExpanded() || ambientState.isDozing() || ambientState.getDozeAmount() == 1f
|| bypassPulseNotExpanding || bypassPulseNotExpanding
? ambientState.getInnerHeight() ? ambientState.getInnerHeight()
: (int) ambientState.getStackHeight(); : ambientState.getStackHeight();
final int shelfStart = stackBottom final float shelfStart = stackBottom
- ambientState.getShelf().getIntrinsicHeight() - ambientState.getShelf().getIntrinsicHeight()
- mPaddingBetweenElements; - mPaddingBetweenElements;
updateViewWithShelf(view, viewState, shelfStart);
}
}
// Clip height of view right before shelf.
viewState.height = (int) (getMaxAllowedChildHeight(view) * expansionFraction);
}
algorithmState.mCurrentYPosition +=
expansionFraction * (getMaxAllowedChildHeight(view) + mPaddingBetweenElements);
algorithmState.mCurrentExpandedYPosition += view.getIntrinsicHeight()
+ mPaddingBetweenElements;
setLocation(view.getViewState(), algorithmState.mCurrentYPosition, i);
viewState.yTranslation += ambientState.getStackY();
}
@VisibleForTesting
void updateViewWithShelf(ExpandableView view, ExpandableViewState viewState, float shelfStart) {
viewState.yTranslation = Math.min(viewState.yTranslation, shelfStart); viewState.yTranslation = Math.min(viewState.yTranslation, shelfStart);
if (viewState.yTranslation >= shelfStart) { if (viewState.yTranslation >= shelfStart) {
viewState.hidden = !view.isExpandAnimationRunning() viewState.hidden = !view.isExpandAnimationRunning()
@@ -552,19 +570,6 @@ public class StackScrollAlgorithm {
viewState.headsUpIsVisible = false; viewState.headsUpIsVisible = false;
} }
} }
}
// Clip height of view right before shelf.
viewState.height = (int) (getMaxAllowedChildHeight(view) * expansionFraction);
}
algorithmState.mCurrentYPosition += viewState.height
+ expansionFraction * mPaddingBetweenElements;
algorithmState.mCurrentExpandedYPosition += view.getIntrinsicHeight()
+ mPaddingBetweenElements;
setLocation(view.getViewState(), algorithmState.mCurrentYPosition, i);
viewState.yTranslation += ambientState.getStackY();
}
/** /**
* Get the gap height needed for before a view * 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 * Y position of the current view during updating children
* with expansion factor applied. * with expansion factor applied.
*/ */
private int mCurrentYPosition; private float mCurrentYPosition;
/** /**
* Y position of the current view during updating children * Y position of the current view during updating children
* without applying the expansion factor. * without applying the expansion factor.
*/ */
private int mCurrentExpandedYPosition; private float mCurrentExpandedYPosition;
} }
/** /**

View File

@@ -7,10 +7,13 @@ import com.android.systemui.R
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.EmptyShadeView import com.android.systemui.statusbar.EmptyShadeView
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow 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.BypassController
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.mockito.Mockito.mock import org.mockito.Mockito.mock
@@ -110,4 +113,52 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
/* fractionToShade= */ 0f, /* onKeyguard= */ false) /* fractionToShade= */ 0f, /* onKeyguard= */ false)
assertThat(gap).isEqualTo(bigGap) 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)
}
} }