summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2014-05-12 00:01:43 +0200
committer Selim Cinek <cinek@google.com> 2014-05-12 14:54:51 +0200
commit34c0a8d72aee1867cf7b6d04531c7faec76ab473 (patch)
tree20993c724612586427eb3061347c2d3736b0f92d
parentc8d31963d6af81465de9801e6a88ebcbf862da35 (diff)
Improved the notification stack logic further
The more card is now working correctly on the lock screen, as well as any other small cards. The slow down zone for the bottom stack was decreased to allow for more real estate in the scrolling area. Also improved the padding handling. Change-Id: I4816d8a96fc365083412e46af88e740a3fc735bc
-rw-r--r--packages/SystemUI/res/values/dimens.xml10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/PiecewiseLinearIndentationFunctor.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/StackIndentationFunctor.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java50
5 files changed, 82 insertions, 40 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 4810575b1d92..ab3403057049 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -243,7 +243,10 @@
<dimen name="top_stack_peek_amount">12dp</dimen>
<!-- Space reserved for the cards behind the top card in the bottom stack -->
- <dimen name="bottom_stack_peek_amount">18dp</dimen>
+ <dimen name="bottom_stack_peek_amount">12dp</dimen>
+
+ <!-- The height of the area before the bottom stack in which the notifications slow down -->
+ <dimen name="bottom_stack_slow_down_length">12dp</dimen>
<!-- The side padding of the notifications-->
<dimen name="notification_side_padding">8dp</dimen>
@@ -251,8 +254,11 @@
<!-- Z distance between notifications if they are in the stack -->
<dimen name="z_distance_between_notifications">2dp</dimen>
+ <!-- The padding between the individual notification cards when dimmed. -->
+ <dimen name="notification_padding_dimmed">0dp</dimen>
+
<!-- The padding between the individual notification cards. -->
- <dimen name="notification_padding">3dp</dimen>
+ <dimen name="notification_padding">4dp</dimen>
<!-- The total height of the stack in its collapsed size (i.e. when quick settings is open) -->
<dimen name="collapsed_stack_height">94dp</dimen>
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 afd506844550..27f661992cb1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -153,7 +153,10 @@ public class NotificationStackScrollLayout extends ViewGroup
if (DEBUG) {
int y = mCollapsedSize;
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
- y = (int) (getLayoutHeight() - mBottomStackPeekSize - mCollapsedSize);
+ y = (int) (getLayoutHeight() - mBottomStackPeekSize
+ - mStackScrollAlgorithm.getBottomStackSlowDownLength());
+ canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
+ y = (int) (getLayoutHeight() - mBottomStackPeekSize);
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
y = (int) getLayoutHeight();
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
@@ -1226,6 +1229,7 @@ public class NotificationStackScrollLayout extends ViewGroup
* See {@link AmbientState#setDimmed}.
*/
public void setDimmed(boolean dimmed, boolean animate) {
+ mStackScrollAlgorithm.setDimmed(dimmed);
mAmbientState.setDimmed(dimmed);
if (animate) {
mDimmedNeedsAnimation = true;
@@ -1311,6 +1315,7 @@ public class NotificationStackScrollLayout extends ViewGroup
// ANIMATION_TYPE_DIMMED
new AnimationFilter()
+ .animateY()
.animateScale()
.animateDimmed()
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/PiecewiseLinearIndentationFunctor.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/PiecewiseLinearIndentationFunctor.java
index 38b544f2cc01..1c37c35d49dc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/PiecewiseLinearIndentationFunctor.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/PiecewiseLinearIndentationFunctor.java
@@ -38,27 +38,26 @@ public class PiecewiseLinearIndentationFunctor extends StackIndentationFunctor {
* the actual visual distance below the top card but is a maximum,
* achieved when the next card just starts transitioning into the stack and
* the stack is full.
- * If totalTransitionDistance is equal to this, we directly start at the peek,
- * otherwise the first element transitions between 0 and
- * totalTransitionDistance - peekSize.
+ * If distanceToPeekStart is 0, we directly start at the peek, otherwise the
+ * first element transitions between 0 and distanceToPeekStart.
* Visualization:
* --------------------------------------------------- ---
* | | |
- * | FIRST ITEM | | <- totalTransitionDistance
+ * | FIRST ITEM | | <- distanceToPeekStart
* | | |
- * |---------------------------------------------------| | ---
- * |__________________SECOND ITEM______________________| | | <- peekSize
- * |===================================================| _|_ _|_
+ * |---------------------------------------------------| --- ---
+ * |__________________SECOND ITEM______________________| | <- peekSize
+ * |===================================================| _|_
*
- * @param totalTransitionDistance The total transition distance an element has to go through
+ * @param distanceToPeekStart The distance to the start of the peak.
* @param linearPart The interpolation factor between the linear and the quadratic amount taken.
* This factor must be somewhere in [0 , 1]
*/
PiecewiseLinearIndentationFunctor(int maxItemsInStack,
int peekSize,
- int totalTransitionDistance,
+ int distanceToPeekStart,
float linearPart) {
- super(maxItemsInStack, peekSize, totalTransitionDistance);
+ super(maxItemsInStack, peekSize, distanceToPeekStart);
mBaseValues = new ArrayList<Float>(maxItemsInStack+1);
initBaseValues();
mLinearPart = linearPart;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackIndentationFunctor.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackIndentationFunctor.java
index f72947a6476a..034eba6836ad 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackIndentationFunctor.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackIndentationFunctor.java
@@ -21,8 +21,8 @@ package com.android.systemui.statusbar.stack;
*/
public abstract class StackIndentationFunctor {
- protected final int mTotalTransitionDistance;
- protected final int mDistanceToPeekStart;
+ protected int mTotalTransitionDistance;
+ protected int mDistanceToPeekStart;
protected int mMaxItemsInStack;
protected int mPeekSize;
protected boolean mStackStartsAtPeek;
@@ -37,31 +37,41 @@ public abstract class StackIndentationFunctor {
* the actual visual distance below the top card but is a maximum,
* achieved when the next card just starts transitioning into the stack and
* the stack is full.
- * If totalTransitionDistance is equal to this, we directly start at the peek,
- * otherwise the first element transitions between 0 and
- * totalTransitionDistance - peekSize.
+ * If distanceToPeekStart is 0, we directly start at the peek, otherwise the
+ * first element transitions between 0 and distanceToPeekStart.
* Visualization:
* --------------------------------------------------- ---
* | | |
- * | FIRST ITEM | | <- totalTransitionDistance
+ * | FIRST ITEM | | <- distanceToPeekStart
* | | |
- * |---------------------------------------------------| | ---
- * |__________________SECOND ITEM______________________| | | <- peekSize
- * |===================================================| _|_ _|_
+ * |---------------------------------------------------| --- ---
+ * |__________________SECOND ITEM______________________| | <- peekSize
+ * |===================================================| _|_
*
- * @param totalTransitionDistance The total transition distance an element has to go through
+ * @param distanceToPeekStart The distance to the start of the peak.
*/
- StackIndentationFunctor(int maxItemsInStack, int peekSize, int totalTransitionDistance) {
- mTotalTransitionDistance = totalTransitionDistance;
- mDistanceToPeekStart = mTotalTransitionDistance - peekSize;
+ StackIndentationFunctor(int maxItemsInStack, int peekSize, int distanceToPeekStart) {
+ mDistanceToPeekStart = distanceToPeekStart;
mStackStartsAtPeek = mDistanceToPeekStart == 0;
mMaxItemsInStack = maxItemsInStack;
mPeekSize = peekSize;
+ updateTotalTransitionDistance();
}
+ private void updateTotalTransitionDistance() {
+ mTotalTransitionDistance = mDistanceToPeekStart + mPeekSize;
+ }
+
public void setPeekSize(int mPeekSize) {
this.mPeekSize = mPeekSize;
+ updateTotalTransitionDistance();
+ }
+
+ public void setDistanceToPeekStart(int distanceToPeekStart) {
+ mDistanceToPeekStart = distanceToPeekStart;
+ mStackStartsAtPeek = mDistanceToPeekStart == 0;
+ updateTotalTransitionDistance();
}
/**
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 5e4d496ee00f..7306c83e6abe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -65,13 +65,40 @@ public class StackScrollAlgorithm {
private ExpandableView mFirstChildWhileExpanding;
private boolean mExpandedOnStart;
private int mTopStackTotalSize;
+ private int mPaddingBetweenElementsDimmed;
+ private int mPaddingBetweenElementsNormal;
+ private int mBottomStackSlowDownLength;
public StackScrollAlgorithm(Context context) {
initConstants(context);
+ updatePadding(false);
+ }
+
+ private void updatePadding(boolean dimmed) {
+ mPaddingBetweenElements = dimmed
+ ? mPaddingBetweenElementsDimmed
+ : mPaddingBetweenElementsNormal;
+ mTopStackTotalSize = mCollapsedSize + mPaddingBetweenElements;
+ mTopStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
+ MAX_ITEMS_IN_TOP_STACK,
+ mTopStackPeekSize,
+ mTopStackTotalSize,
+ 0.5f);
+ mBottomStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
+ MAX_ITEMS_IN_BOTTOM_STACK,
+ mBottomStackPeekSize,
+ getBottomStackSlowDownLength(),
+ 0.5f);
+ }
+
+ public int getBottomStackSlowDownLength() {
+ return mBottomStackSlowDownLength + mPaddingBetweenElements;
}
private void initConstants(Context context) {
- mPaddingBetweenElements = context.getResources()
+ mPaddingBetweenElementsDimmed = context.getResources()
+ .getDimensionPixelSize(R.dimen.notification_padding_dimmed);
+ mPaddingBetweenElementsNormal = context.getResources()
.getDimensionPixelSize(R.dimen.notification_padding);
mCollapsedSize = context.getResources()
.getDimensionPixelSize(R.dimen.notification_min_height);
@@ -82,17 +109,8 @@ public class StackScrollAlgorithm {
mZDistanceBetweenElements = context.getResources()
.getDimensionPixelSize(R.dimen.z_distance_between_notifications);
mZBasicHeight = (MAX_ITEMS_IN_BOTTOM_STACK + 1) * mZDistanceBetweenElements;
- mTopStackTotalSize = mCollapsedSize + mPaddingBetweenElements;
- mTopStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
- MAX_ITEMS_IN_TOP_STACK,
- mTopStackPeekSize,
- mTopStackTotalSize,
- 0.5f);
- mBottomStackIndentationFunctor = new PiecewiseLinearIndentationFunctor(
- MAX_ITEMS_IN_BOTTOM_STACK,
- mBottomStackPeekSize,
- mCollapsedSize + mBottomStackPeekSize + mPaddingBetweenElements,
- 0.5f);
+ mBottomStackSlowDownLength = context.getResources()
+ .getDimensionPixelSize(R.dimen.bottom_stack_slow_down_length);
}
@@ -206,7 +224,7 @@ public class StackScrollAlgorithm {
float bottomPeekStart = mInnerHeight - mBottomStackPeekSize;
// The position where the bottom stack starts.
- float bottomStackStart = bottomPeekStart - mCollapsedSize;
+ float bottomStackStart = bottomPeekStart - mBottomStackSlowDownLength;
// The y coordinate of the current child.
float currentYPosition = 0.0f;
@@ -352,7 +370,7 @@ public class StackScrollAlgorithm {
algorithmState.itemsInBottomStack += algorithmState.partialInBottom;
childViewState.yTranslation = transitioningPositionStart + offset - childHeight
- mPaddingBetweenElements;
-
+
// We want at least to be at the end of the top stack when collapsing
clampPositionToTopStackEnd(childViewState, childHeight);
childViewState.location = StackScrollState.ViewState.LOCATION_MAIN_AREA;
@@ -621,6 +639,10 @@ public class StackScrollAlgorithm {
}
}
+ public void setDimmed(boolean dimmed) {
+ updatePadding(dimmed);
+ }
+
class StackScrollAlgorithmState {
/**