diff options
| author | 2017-12-04 12:03:44 +0000 | |
|---|---|---|
| committer | 2017-12-04 12:03:44 +0000 | |
| commit | 5826e469e9d03eaa5511d413733edde0a1b99048 (patch) | |
| tree | eb79a60a3ac16931531ec0da66122a2a40db3e02 | |
| parent | f1a4b25c1eb8e3f16cd3db4bc5ad9e1643adef84 (diff) | |
| parent | 9b9d6e16bcd02661b2e94decc2ebc3058bab408b (diff) | |
Merge "Heads up notification can now scroll away after it was seen"
6 files changed, 50 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 23d9caeeae80..e04bd0e72929 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -112,6 +112,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private int mNotificationMaxHeight; private int mNotificationAmbientHeight; private int mIncreasedPaddingBetweenElements; + private boolean mMustStayOnScreen; /** Does this row contain layouts that can adapt to row expansion */ private boolean mExpandable; @@ -491,6 +492,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView notifyHeightChanged(false /* needsAnimation */); } if (isHeadsUp) { + mMustStayOnScreen = true; setAboveShelf(true); } else if (isAboveShelf() != wasAboveShelf) { mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf); @@ -517,6 +519,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView addChildNotification(row, -1); } + @Override + public void setHeadsUpIsVisible() { + super.setHeadsUpIsVisible(); + mMustStayOnScreen = false; + } + /** * Add a child notification to this view. * @@ -1942,7 +1950,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView @Override public boolean mustStayOnScreen() { - return mIsHeadsUp; + return mIsHeadsUp && mMustStayOnScreen; } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java index 18b986027a4a..f762513d2947 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java @@ -478,6 +478,9 @@ public abstract class ExpandableView extends FrameLayout { return false; } + public void setHeadsUpIsVisible() { + } + public boolean isChildInGroup() { return false; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/ExpandableViewState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/ExpandableViewState.java index e0fd481c4cc2..0650e23db883 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/ExpandableViewState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/ExpandableViewState.java @@ -95,6 +95,12 @@ public class ExpandableViewState extends ViewState { public boolean inShelf; /** + * A state indicating whether a headsup is currently fully visible, even when not scrolled. + * Only valid if the view is heads upped. + */ + public boolean headsUpIsVisible; + + /** * How much the child overlaps with the previous child on top. This is used to * show the background properly when the child on top is translating away. */ @@ -126,6 +132,7 @@ public class ExpandableViewState extends ViewState { clipTopAmount = svs.clipTopAmount; notGoneIndex = svs.notGoneIndex; location = svs.location; + headsUpIsVisible = svs.headsUpIsVisible; } } @@ -175,6 +182,10 @@ public class ExpandableViewState extends ViewState { expandableView.setTransformingInShelf(false); expandableView.setInShelf(inShelf); + + if (headsUpIsVisible) { + expandableView.setHeadsUpIsVisible(); + } } } @@ -229,6 +240,10 @@ public class ExpandableViewState extends ViewState { expandableView.setTransformingInShelf(true); } expandableView.setInShelf(this.inShelf); + + if (headsUpIsVisible) { + expandableView.setHeadsUpIsVisible(); + } } private void startHeightAnimation(final ExpandableView child, AnimationProperties properties) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index ebebfacfac4b..a3d2423f5df1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -624,7 +624,7 @@ public class NotificationStackScrollLayout extends ViewGroup if (childViewState == null) { return false; } - if ((childViewState.location &= ExpandableViewState.VISIBLE_LOCATIONS) == 0) { + if ((childViewState.location & ExpandableViewState.VISIBLE_LOCATIONS) == 0) { return false; } if (row.getVisibility() != View.VISIBLE) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index c060b0882060..195607dce81f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -135,7 +135,7 @@ public class StackScrollAlgorithm { for (int i = 0; i < childCount; i++) { ExpandableView child = algorithmState.visibleChildren.get(i); ExpandableViewState state = resultState.getViewStateForView(child); - if (!child.mustStayOnScreen()) { + if (!child.mustStayOnScreen() || state.headsUpIsVisible) { previousNotificationEnd = Math.max(drawStart, previousNotificationEnd); previousNotificationStart = Math.max(drawStart, previousNotificationStart); } @@ -378,6 +378,13 @@ public class StackScrollAlgorithm { boolean isEmptyShadeView = child instanceof EmptyShadeView; childViewState.location = ExpandableViewState.LOCATION_MAIN_AREA; + float inset = ambientState.getTopPadding() + ambientState.getStackTranslation(); + if (child.mustStayOnScreen() && childViewState.yTranslation >= 0) { + // Even if we're not scrolled away we're in view and we're also not in the + // shelf. We can relax the constraints and let us scroll off the top! + float end = childViewState.yTranslation + childViewState.height + inset; + childViewState.headsUpIsVisible = end < ambientState.getMaxHeadsUpTranslation(); + } if (isDismissView) { childViewState.yTranslation = Math.min(childViewState.yTranslation, ambientState.getInnerHeight() - childHeight); @@ -396,8 +403,7 @@ public class StackScrollAlgorithm { Log.wtf(LOG_TAG, "Failed to assign location for child " + i); } - childViewState.yTranslation += ambientState.getTopPadding() - + ambientState.getStackTranslation(); + childViewState.yTranslation += inset; return currentYPosition; } @@ -420,19 +426,21 @@ public class StackScrollAlgorithm { break; } ExpandableViewState childState = resultState.getViewStateForView(row); - if (topHeadsUpEntry == null) { + if (topHeadsUpEntry == null && row.mustStayOnScreen() && !childState.headsUpIsVisible) { topHeadsUpEntry = row; childState.location = ExpandableViewState.LOCATION_FIRST_HUN; } boolean isTopEntry = topHeadsUpEntry == row; float unmodifiedEndLocation = childState.yTranslation + childState.height; if (mIsExpanded) { - // Ensure that the heads up is always visible even when scrolled off - clampHunToTop(ambientState, row, childState); - if (i == 0 && ambientState.isAboveShelf(row)) { - // the first hun can't get off screen. - clampHunToMaxTranslation(ambientState, row, childState); - childState.hidden = false; + if (row.mustStayOnScreen() && !childState.headsUpIsVisible) { + // Ensure that the heads up is always visible even when scrolled off + clampHunToTop(ambientState, row, childState); + if (i == 0 && ambientState.isAboveShelf(row)) { + // the first hun can't get off screen. + clampHunToMaxTranslation(ambientState, row, childState); + childState.hidden = false; + } } } if (row.isPinned()) { @@ -493,6 +501,7 @@ public class StackScrollAlgorithm { if (childViewState.yTranslation >= shelfStart) { childViewState.hidden = true; childViewState.inShelf = true; + childViewState.headsUpIsVisible = false; } if (!ambientState.isShadeExpanded()) { childViewState.height = (int) (mStatusBarHeight - childViewState.yTranslation); @@ -531,7 +540,8 @@ public class StackScrollAlgorithm { ExpandableViewState childViewState = resultState.getViewStateForView(child); int zDistanceBetweenElements = ambientState.getZDistanceBetweenElements(); float baseZ = ambientState.getBaseZHeight(); - if (child.mustStayOnScreen() && !ambientState.isDozingAndNotPulsing(child) + if (child.mustStayOnScreen() && !childViewState.headsUpIsVisible + && !ambientState.isDozingAndNotPulsing(child) && childViewState.yTranslation < ambientState.getTopPadding() + ambientState.getStackTranslation()) { if (childrenOnTop != 0.0f) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java index e3c746bf0d32..588b75881a4a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java @@ -84,6 +84,7 @@ public class StackScrollState { viewState.scaleX = view.getScaleX(); viewState.scaleY = view.getScaleY(); viewState.inShelf = false; + viewState.headsUpIsVisible = false; } public ExpandableViewState getViewStateForView(View requestedView) { |