summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-05-28 23:58:59 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-28 23:58:59 +0000
commit92f04af94436da53ef111dd16cb7da1a3f535de0 (patch)
tree72c797d57b8f4a743a29193aed7da7a708abcc99
parent8489779ad049c15f7338395e2e0058a97ce37746 (diff)
parented48c8aa12b2e9777bba41bd0113f956d3c4ae7c (diff)
Merge changes I92ef4715,Iebf64931 into rvc-dev
* changes: Fixed the calculation of how many views to show on the lockscreen Fixed an issue where the contentHeight was calculated wrongly
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java30
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java42
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java77
3 files changed, 124 insertions, 25 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 a877bc1c4205..fc203a0d857f 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
@@ -2452,7 +2452,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
int numShownItems = 0;
boolean finish = false;
int maxDisplayedNotifications = mMaxDisplayedNotifications;
-
+ ExpandableView previousView = null;
for (int i = 0; i < getChildCount(); i++) {
ExpandableView expandableView = (ExpandableView) getChildAt(i);
boolean footerViewOnLockScreen = expandableView == mFooterView && onKeyguard();
@@ -2460,9 +2460,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
&& !expandableView.hasNoContentHeight() && !footerViewOnLockScreen) {
boolean limitReached = maxDisplayedNotifications != -1
&& numShownItems >= maxDisplayedNotifications;
+ final float viewHeight;
if (limitReached) {
- expandableView = mShelf;
+ viewHeight = mShelf.getIntrinsicHeight();
finish = true;
+ } else {
+ viewHeight = expandableView.getIntrinsicHeight();
}
float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount();
float padding;
@@ -2493,9 +2496,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
if (height != 0) {
height += padding;
}
+ height += calculateGapHeight(previousView, expandableView, numShownItems);
previousPaddingAmount = increasedPaddingAmount;
- height += expandableView.getIntrinsicHeight();
+ height += viewHeight;
numShownItems++;
+ previousView = expandableView;
if (finish) {
break;
}
@@ -2511,6 +2516,25 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
mAmbientState.setLayoutMaxHeight(mContentHeight);
}
+ /**
+ * Calculate the gap height between two different views
+ *
+ * @param previous the previousView
+ * @param current the currentView
+ * @param visibleIndex the visible index in the list
+ *
+ * @return the gap height needed before the current view
+ */
+ public float calculateGapHeight(
+ ExpandableView previous,
+ ExpandableView current,
+ int visibleIndex
+ ) {
+ return mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager,
+ mAmbientState.getAnchorViewIndex(), visibleIndex, current,
+ previous);
+ }
+
@Override
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
public boolean hasPulsingNotifications() {
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 1a15377566e2..a4598e9cec9f 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
@@ -402,7 +402,8 @@ public class StackScrollAlgorithm {
ExpandableView previousChild = i > 0 ? algorithmState.visibleChildren.get(i - 1) : null;
final boolean applyGapHeight =
childNeedsGapHeight(
- ambientState.getSectionProvider(), algorithmState, i, child, previousChild);
+ ambientState.getSectionProvider(), algorithmState.anchorViewIndex, i,
+ child, previousChild);
ExpandableViewState childViewState = child.getViewState();
childViewState.location = ExpandableViewState.LOCATION_UNKNOWN;
@@ -463,9 +464,44 @@ public class StackScrollAlgorithm {
return currentYPosition;
}
+ /**
+ * Get the gap height needed for before a view
+ *
+ * @param sectionProvider the sectionProvider used to understand the sections
+ * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not
+ * @param visibleIndex the visible index of this view in the list
+ * @param child the child asked about
+ * @param previousChild the child right before it or null if none
+ * @return the size of the gap needed or 0 if none is needed
+ */
+ public float getGapHeightForChild(
+ SectionProvider sectionProvider,
+ int anchorViewIndex,
+ int visibleIndex,
+ View child,
+ View previousChild) {
+
+ if (childNeedsGapHeight(sectionProvider, anchorViewIndex, visibleIndex, child,
+ previousChild)) {
+ return mGapHeight;
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Does a given child need a gap, i.e spacing before a view?
+ *
+ * @param sectionProvider the sectionProvider used to understand the sections
+ * @param anchorViewIndex the anchorView index when anchor scrolling, can be 0 if not
+ * @param visibleIndex the visible index of this view in the list
+ * @param child the child asked about
+ * @param previousChild the child right before it or null if none
+ * @return if the child needs a gap height
+ */
private boolean childNeedsGapHeight(
SectionProvider sectionProvider,
- StackScrollAlgorithmState algorithmState,
+ int anchorViewIndex,
int visibleIndex,
View child,
View previousChild) {
@@ -473,7 +509,7 @@ public class StackScrollAlgorithm {
boolean needsGapHeight = sectionProvider.beginsSection(child, previousChild)
&& visibleIndex > 0;
if (ANCHOR_SCROLLING) {
- needsGapHeight &= visibleIndex != algorithmState.anchorViewIndex;
+ needsGapHeight &= visibleIndex != anchorViewIndex;
}
return needsGapHeight;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index a85000730106..8889510cde28 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.phone;
+import static android.view.View.GONE;
+
import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;
@@ -102,6 +104,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
+import com.android.systemui.statusbar.notification.stack.MediaHeaderView;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
@@ -848,34 +851,25 @@ public class NotificationPanelViewController extends PanelViewController {
mIndicationBottomPadding, mAmbientIndicationBottomPadding)
- mKeyguardStatusView.getLogoutButtonHeight();
int count = 0;
+ ExpandableView previousView = null;
for (int i = 0; i < mNotificationStackScroller.getChildCount(); i++) {
ExpandableView child = (ExpandableView) mNotificationStackScroller.getChildAt(i);
- if (!(child instanceof ExpandableNotificationRow)) {
- continue;
- }
- ExpandableNotificationRow row = (ExpandableNotificationRow) child;
- boolean
- suppressedSummary =
- mGroupManager != null && mGroupManager.isSummaryOfSuppressedGroup(
- row.getEntry().getSbn());
- if (suppressedSummary) {
- continue;
- }
- if (!mLockscreenUserManager.shouldShowOnKeyguard(row.getEntry())) {
- continue;
- }
- if (row.isRemoved()) {
+ if (!canShowViewOnLockscreen(child)) {
continue;
}
- availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */)
- + notificationPadding;
+ availableSpace -= child.getMinHeight(true /* ignoreTemporaryStates */);
+ availableSpace -= count == 0 ? 0 : notificationPadding;
+ availableSpace -= mNotificationStackScroller.calculateGapHeight(previousView, child,
+ count);
+ previousView = child;
if (availableSpace >= 0 && count < maximum) {
count++;
} else if (availableSpace > -shelfSize) {
// if we are exactly the last view, then we can show us still!
for (int j = i + 1; j < mNotificationStackScroller.getChildCount(); j++) {
- if (mNotificationStackScroller.getChildAt(
- j) instanceof ExpandableNotificationRow) {
+ ExpandableView view = (ExpandableView) mNotificationStackScroller.getChildAt(j);
+ if (view instanceof ExpandableNotificationRow &&
+ canShowViewOnLockscreen(view)) {
return count;
}
}
@@ -888,6 +882,51 @@ public class NotificationPanelViewController extends PanelViewController {
return count;
}
+ /**
+ * Can a view be shown on the lockscreen when calculating the number of allowed notifications
+ * to show?
+ *
+ * @param child the view in question
+ * @return true if it can be shown
+ */
+ private boolean canShowViewOnLockscreen(ExpandableView child) {
+ if (child.hasNoContentHeight()) {
+ return false;
+ }
+ if (child instanceof ExpandableNotificationRow &&
+ !canShowRowOnLockscreen((ExpandableNotificationRow) child)) {
+ return false;
+ } else if (child.getVisibility() == GONE) {
+ // ENRs can be gone and count because their visibility is only set after
+ // this calculation, but all other views should be up to date
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Can a row be shown on the lockscreen when calculating the number of allowed notifications
+ * to show?
+ *
+ * @param row the row in question
+ * @return true if it can be shown
+ */
+ private boolean canShowRowOnLockscreen(ExpandableNotificationRow row) {
+ boolean suppressedSummary =
+ mGroupManager != null && mGroupManager.isSummaryOfSuppressedGroup(
+ row.getEntry().getSbn());
+ if (suppressedSummary) {
+ return false;
+ }
+ if (!mLockscreenUserManager.shouldShowOnKeyguard(row.getEntry())) {
+ return false;
+ }
+ if (row.isRemoved()) {
+ return false;
+ }
+ return true;
+ }
+
private void updateClock() {
if (!mKeyguardStatusViewAnimating) {
mKeyguardStatusView.setAlpha(mClockPositionResult.clockAlpha);