summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lyn Han <lynhan@google.com> 2020-11-10 20:02:40 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-11-10 20:02:40 +0000
commitbea090f330de8181bb5206e6469ceea66fe9ef56 (patch)
tree2621c495cb3d78cc7bdd650f320f19210f8fe6cd
parentfd64aa2c1c6dbf7380f081acc74a3ebad0c3cccf (diff)
parentec72394775a911e7fda8a1e4580ada32c83789e1 (diff)
Merge "Remove padding customization from stack scroller algorithm"
-rw-r--r--packages/SystemUI/res/values/dimens.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java90
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java85
6 files changed, 10 insertions, 206 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 10d7c430a5a9..b90749a12167 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -635,9 +635,6 @@
<!-- The height of a notification header -->
<dimen name="notification_header_height">53dp</dimen>
- <!-- The height of the divider between the individual notifications when the notification wants it to be increased. This is currently the case for notification groups -->
- <dimen name="notification_divider_height_increased">6dp</dimen>
-
<!-- The height of the gap between adjacent notification sections. -->
<dimen name="notification_section_divider_height">@dimen/notification_side_paddings</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index a011d36af11d..2253b2ba26f2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -331,7 +331,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
private OnUserInteractionCallback mOnUserInteractionCallback;
private NotificationGutsManager mNotificationGutsManager;
private boolean mIsLowPriority;
- private boolean mIsColorized;
private boolean mUseIncreasedCollapsedHeight;
private boolean mUseIncreasedHeadsUpHeight;
private float mTranslationWhenRemoved;
@@ -541,7 +540,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
for (NotificationContentView l : mLayouts) {
l.onNotificationUpdated(mEntry);
}
- mIsColorized = mEntry.getSbn().getNotification().isColorized();
mShowingPublicInitialized = false;
updateNotificationColor();
if (mMenuRow != null) {
@@ -1624,8 +1622,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
R.dimen.notification_max_heads_up_height_increased);
Resources res = getResources();
- mIncreasedPaddingBetweenElements = res.getDimensionPixelSize(
- R.dimen.notification_divider_height_increased);
mEnableNonGroupedNotificationExpand =
res.getBoolean(R.bool.config_enableNonGroupedNotificationExpand);
mShowGroupBackgroundWhenExpanded =
@@ -2844,24 +2840,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
@Override
- public float getIncreasedPaddingAmount() {
- if (mIsSummaryWithChildren) {
- if (isGroupExpanded()) {
- return 1.0f;
- } else if (isUserLocked()) {
- return mChildrenContainer.getIncreasedPaddingAmount();
- }
- } else if (isColorized() && (!mIsLowPriority || isExpanded())) {
- return -1.0f;
- }
- return 0.0f;
- }
-
- private boolean isColorized() {
- return mIsColorized && mBgTint != NO_COLOR;
- }
-
- @Override
protected boolean disallowSingleClick(MotionEvent event) {
if (areGutsExposed()) {
return false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
index ccfd8a329ffd..73e080423d40 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
@@ -499,15 +499,6 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
return super.hasOverlappingRendering() && getActualHeight() <= getHeight();
}
- /**
- * @return an amount between -1 and 1 of increased padding that this child needs. 1 means it
- * needs a full increased padding while -1 means it needs no padding at all. For 0.0f the normal
- * padding is applied.
- */
- public float getIncreasedPaddingAmount() {
- return 0.0f;
- }
-
public boolean mustStayOnScreen() {
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
index 00bccfc1a323..b04f94ce9c1d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
@@ -1271,13 +1271,6 @@ public class NotificationChildrenContainer extends ViewGroup {
}
}
- public float getIncreasedPaddingAmount() {
- if (showingAsLowPriority()) {
- return 0.0f;
- }
- return getGroupExpandFraction();
- }
-
@VisibleForTesting
public boolean isUserLocked() {
return mUserLocked;
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 89a7857bf6ce..fbcfef3964af 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
@@ -198,7 +198,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private int mIntrinsicContentHeight;
private int mCollapsedSize;
private int mPaddingBetweenElements;
- private int mIncreasedPaddingBetweenElements;
private int mMaxTopPadding;
private int mTopPadding;
private int mBottomMargin;
@@ -883,8 +882,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
mAmbientState.reload(context);
mPaddingBetweenElements = Math.max(1,
res.getDimensionPixelSize(R.dimen.notification_divider_height));
- mIncreasedPaddingBetweenElements =
- res.getDimensionPixelSize(R.dimen.notification_divider_height_increased);
mMinTopOverScrollToEscape = res.getDimensionPixelSize(
R.dimen.min_top_overscroll_to_qs);
mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
@@ -1099,11 +1096,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
for (int i = 0; i < getChildCount(); i++) {
ExpandableView child = (ExpandableView) getChildAt(i);
if (mChildrenToAddAnimated.contains(child)) {
- int startingPosition = getPositionInLinearLayout(child);
- float increasedPaddingAmount = child.getIncreasedPaddingAmount();
- int padding = increasedPaddingAmount == 1.0f ? mIncreasedPaddingBetweenElements
- : increasedPaddingAmount == -1.0f ? 0 : mPaddingBetweenElements;
- int childHeight = getIntrinsicHeight(child) + padding;
+ final int startingPosition = getPositionInLinearLayout(child);
+ final int childHeight = getIntrinsicHeight(child) + mPaddingBetweenElements;
if (startingPosition < mOwnScrollY) {
// This child starts off screen, so let's keep it offscreen to keep the
// others visible
@@ -2297,7 +2291,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private void updateContentHeight() {
int height = 0;
float previousPaddingRequest = mPaddingBetweenElements;
- float previousPaddingAmount = 0.0f;
int numShownItems = 0;
boolean finish = false;
int maxDisplayedNotifications = mMaxDisplayedNotifications;
@@ -2316,37 +2309,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
} else {
viewHeight = expandableView.getIntrinsicHeight();
}
- float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount();
- float padding;
- if (increasedPaddingAmount >= 0.0f) {
- padding = (int) NotificationUtils.interpolate(
- previousPaddingRequest,
- mIncreasedPaddingBetweenElements,
- increasedPaddingAmount);
- previousPaddingRequest = (int) NotificationUtils.interpolate(
- mPaddingBetweenElements,
- mIncreasedPaddingBetweenElements,
- increasedPaddingAmount);
- } else {
- int ownPadding = (int) NotificationUtils.interpolate(
- 0,
- mPaddingBetweenElements,
- 1.0f + increasedPaddingAmount);
- if (previousPaddingAmount > 0.0f) {
- padding = (int) NotificationUtils.interpolate(
- ownPadding,
- mIncreasedPaddingBetweenElements,
- previousPaddingAmount);
- } else {
- padding = ownPadding;
- }
- previousPaddingRequest = ownPadding;
- }
if (height != 0) {
- height += padding;
+ height += mPaddingBetweenElements;
}
height += calculateGapHeight(previousView, expandableView, numShownItems);
- previousPaddingAmount = increasedPaddingAmount;
height += viewHeight;
numShownItems++;
previousView = expandableView;
@@ -3054,22 +3020,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
}
updateOnScrollChange();
} else {
- int startingPosition = getPositionInLinearLayout(removedChild);
- float increasedPaddingAmount = removedChild.getIncreasedPaddingAmount();
- int padding;
- if (increasedPaddingAmount >= 0) {
- padding = (int) NotificationUtils.interpolate(
- mPaddingBetweenElements,
- mIncreasedPaddingBetweenElements,
- increasedPaddingAmount);
- } else {
- padding = (int) NotificationUtils.interpolate(
- 0,
- mPaddingBetweenElements,
- 1.0f + increasedPaddingAmount);
- }
- int childHeight = getIntrinsicHeight(removedChild) + padding;
- int endPosition = startingPosition + childHeight;
+ final int startingPosition = getPositionInLinearLayout(removedChild);
+ final int childHeight = getIntrinsicHeight(removedChild) + mPaddingBetweenElements;
+ final int endPosition = startingPosition + childHeight;
if (endPosition <= mOwnScrollY) {
// This child is fully scrolled of the top, so we have to deduct its height from the
// scrollPosition
@@ -3102,42 +3055,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
requestedView = requestedRow = childInGroup.getNotificationParent();
}
int position = 0;
- float previousPaddingRequest = mPaddingBetweenElements;
- float previousPaddingAmount = 0.0f;
for (int i = 0; i < getChildCount(); i++) {
ExpandableView child = (ExpandableView) getChildAt(i);
boolean notGone = child.getVisibility() != View.GONE;
if (notGone && !child.hasNoContentHeight()) {
- float increasedPaddingAmount = child.getIncreasedPaddingAmount();
- float padding;
- if (increasedPaddingAmount >= 0.0f) {
- padding = (int) NotificationUtils.interpolate(
- previousPaddingRequest,
- mIncreasedPaddingBetweenElements,
- increasedPaddingAmount);
- previousPaddingRequest = (int) NotificationUtils.interpolate(
- mPaddingBetweenElements,
- mIncreasedPaddingBetweenElements,
- increasedPaddingAmount);
- } else {
- int ownPadding = (int) NotificationUtils.interpolate(
- 0,
- mPaddingBetweenElements,
- 1.0f + increasedPaddingAmount);
- if (previousPaddingAmount > 0.0f) {
- padding = (int) NotificationUtils.interpolate(
- ownPadding,
- mIncreasedPaddingBetweenElements,
- previousPaddingAmount);
- } else {
- padding = ownPadding;
- }
- previousPaddingRequest = ownPadding;
- }
if (position != 0) {
- position += padding;
+ position += mPaddingBetweenElements;
}
- previousPaddingAmount = increasedPaddingAmount;
}
if (child == requestedView) {
if (requestedRow != null) {
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 d7a8202d7a4c..d85baa9f1b93 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
@@ -51,7 +51,6 @@ public class StackScrollAlgorithm {
private final ViewGroup mHostView;
private int mPaddingBetweenElements;
- private int mIncreasedPaddingBetweenElements;
private int mGapHeight;
private int mCollapsedSize;
@@ -77,8 +76,6 @@ public class StackScrollAlgorithm {
Resources res = context.getResources();
mPaddingBetweenElements = res.getDimensionPixelSize(
R.dimen.notification_divider_height);
- mIncreasedPaddingBetweenElements =
- res.getDimensionPixelSize(R.dimen.notification_divider_height_increased);
mCollapsedSize = res.getDimensionPixelSize(R.dimen.notification_min_height);
mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
mClipNotificationScrollToTop = res.getBoolean(R.bool.config_clipNotificationScrollToTop);
@@ -240,17 +237,8 @@ public class StackScrollAlgorithm {
int childCount = hostView.getChildCount();
state.visibleChildren.clear();
state.visibleChildren.ensureCapacity(childCount);
- state.paddingMap.clear();
int notGoneIndex = 0;
ExpandableView lastView = null;
- int firstHiddenIndex = ambientState.isDozing()
- ? (ambientState.hasPulsingNotifications() ? 1 : 0)
- : childCount;
-
- // The goal here is to fill the padding map, by iterating over how much padding each child
- // needs. The map is thereby reused, by first filling it with the padding amount and when
- // iterating over it again, it's filled with the actual resolved value.
-
for (int i = 0; i < childCount; i++) {
if (ANCHOR_SCROLLING) {
if (i == ambientState.getAnchorViewIndex()) {
@@ -262,39 +250,7 @@ public class StackScrollAlgorithm {
if (v == ambientState.getShelf()) {
continue;
}
- if (i >= firstHiddenIndex) {
- // we need normal padding now, to be in sync with what the stack calculates
- lastView = null;
- }
notGoneIndex = updateNotGoneIndex(state, notGoneIndex, v);
- float increasedPadding = v.getIncreasedPaddingAmount();
- if (increasedPadding != 0.0f) {
- state.paddingMap.put(v, increasedPadding);
- if (lastView != null) {
- Float prevValue = state.paddingMap.get(lastView);
- float newValue = getPaddingForValue(increasedPadding);
- if (prevValue != null) {
- float prevPadding = getPaddingForValue(prevValue);
- if (increasedPadding > 0) {
- newValue = NotificationUtils.interpolate(
- prevPadding,
- newValue,
- increasedPadding);
- } else if (prevValue > 0) {
- newValue = NotificationUtils.interpolate(
- newValue,
- prevPadding,
- prevValue);
- }
- }
- state.paddingMap.put(lastView, newValue);
- }
- } else if (lastView != null) {
-
- // Let's now resolve the value to an actual padding
- float newValue = getPaddingForValue(state.paddingMap.get(lastView));
- state.paddingMap.put(lastView, newValue);
- }
if (v instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) v;
@@ -310,7 +266,6 @@ public class StackScrollAlgorithm {
}
}
}
- lastView = v;
}
}
ExpandableNotificationRow expandingNotification = ambientState.getExpandingNotification();
@@ -321,22 +276,6 @@ public class StackScrollAlgorithm {
: -1;
}
- private float getPaddingForValue(Float increasedPadding) {
- if (increasedPadding == null) {
- return mPaddingBetweenElements;
- } else if (increasedPadding >= 0.0f) {
- return NotificationUtils.interpolate(
- mPaddingBetweenElements,
- mIncreasedPaddingBetweenElements,
- increasedPadding);
- } else {
- return NotificationUtils.interpolate(
- 0,
- mPaddingBetweenElements,
- 1.0f + increasedPadding);
- }
- }
-
private int updateNotGoneIndex(StackScrollAlgorithmState state, int notGoneIndex,
ExpandableView v) {
ExpandableViewState viewState = v.getViewState();
@@ -413,10 +352,10 @@ public class StackScrollAlgorithm {
currentYPosition += mGapHeight;
}
- int paddingAfterChild = getPaddingAfterChild(algorithmState, child);
int childHeight = getMaxAllowedChildHeight(child);
if (reverse) {
- childViewState.yTranslation = currentYPosition - (childHeight + paddingAfterChild);
+ childViewState.yTranslation = currentYPosition
+ - (childHeight + mPaddingBetweenElements);
if (currentYPosition <= 0) {
childViewState.location = ExpandableViewState.LOCATION_HIDDEN_TOP;
}
@@ -453,7 +392,7 @@ public class StackScrollAlgorithm {
currentYPosition -= mGapHeight;
}
} else {
- currentYPosition = childViewState.yTranslation + childHeight + paddingAfterChild;
+ currentYPosition = childViewState.yTranslation + childHeight + mPaddingBetweenElements;
if (currentYPosition <= 0) {
childViewState.location = ExpandableViewState.LOCATION_HIDDEN_TOP;
}
@@ -516,11 +455,6 @@ public class StackScrollAlgorithm {
return needsGapHeight;
}
- protected int getPaddingAfterChild(StackScrollAlgorithmState algorithmState,
- ExpandableView child) {
- return algorithmState.getPaddingAfterChild(child);
- }
-
private void updatePulsingStates(StackScrollAlgorithmState algorithmState,
AmbientState ambientState) {
int childCount = algorithmState.visibleChildren.size();
@@ -780,21 +714,8 @@ public class StackScrollAlgorithm {
*/
public final ArrayList<ExpandableView> visibleChildren = new ArrayList<ExpandableView>();
- /**
- * The padding after each child measured in pixels.
- */
- public final HashMap<ExpandableView, Float> paddingMap = new HashMap<>();
private int indexOfExpandingNotification;
- public int getPaddingAfterChild(ExpandableView child) {
- Float padding = paddingMap.get(child);
- if (padding == null) {
- // Should only happen for the last view
- return mPaddingBetweenElements;
- }
- return (int) padding.floatValue();
- }
-
public int getIndexOfExpandingNotification() {
return indexOfExpandingNotification;
}