More Heads Up bug fixes

Heads-up now has the correct height while expanding
and collapsing the shade.
Fading out while collapsing the shade was restored.
Fixed a bug where translation was not correctly replaced
with paddingOffset.

Change-Id: I9f1b28856b3ca52543460e7ddde84a1a7eb79cf2
This commit is contained in:
Selim Cinek
2015-04-10 14:37:46 -07:00
parent a7840af09d
commit d2281151ee
4 changed files with 58 additions and 28 deletions

View File

@@ -322,6 +322,11 @@ public class ExpandHelper implements Gefingerpoken {
isInside(mScrollAdapter.getHostView(), x, y)
&& mScrollAdapter.isScrolledToTop();
mResizedView = findView(x, y);
if (mResizedView != null && (isFullyExpanded(mResizedView)
|| !mCallback.canChildBeExpanded(mResizedView))) {
mResizedView = null;
mWatchingForPull = false;
}
mInitialTouchY = ev.getY();
break;

View File

@@ -185,6 +185,7 @@ public class NotificationPanelView extends PanelView implements
private boolean mPinnedHeadsUpExist;
private boolean mExpansionIsFromHeadsUp;
private int mBottomBarHeight;
private boolean mExpandingFromHeadsUp;
private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() {
@Override
public void run() {
@@ -1515,16 +1516,21 @@ public class NotificationPanelView extends PanelView implements
}
}
private void updateNotificationTranslucency() {
float alpha = (getNotificationsTopY() + mNotificationStackScroller.getItemHeight())
/ (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize()
- mNotificationStackScroller.getCollapseSecondCardPadding());
alpha = Math.max(0, Math.min(alpha, 1));
alpha = (float) Math.pow(alpha, 0.75);
if (alpha != 1f && mNotificationStackScroller.getLayerType() != LAYER_TYPE_HARDWARE) {
mNotificationStackScroller.setLayerType(LAYER_TYPE_HARDWARE, null);
} else if (alpha == 1f
&& mNotificationStackScroller.getLayerType() == LAYER_TYPE_HARDWARE) {
mNotificationStackScroller.setLayerType(LAYER_TYPE_NONE, null);
float alpha;
if (mExpandingFromHeadsUp || mHeadsUpManager.hasPinnedHeadsUp()) {
alpha = 1f;
} else {
alpha = (getNotificationsTopY() + mNotificationStackScroller.getItemHeight())
/ (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize()
- mNotificationStackScroller.getCollapseSecondCardPadding());
alpha = Math.max(0, Math.min(alpha, 1));
alpha = (float) Math.pow(alpha, 0.75);
if (alpha != 1f && mNotificationStackScroller.getLayerType() != LAYER_TYPE_HARDWARE) {
mNotificationStackScroller.setLayerType(LAYER_TYPE_HARDWARE, null);
} else if (alpha == 1f
&& mNotificationStackScroller.getLayerType() == LAYER_TYPE_HARDWARE) {
mNotificationStackScroller.setLayerType(LAYER_TYPE_NONE, null);
}
}
mNotificationStackScroller.setAlpha(alpha);
}
@@ -1588,11 +1594,10 @@ public class NotificationPanelView extends PanelView implements
return mExpandedHeight / HEADER_RUBBERBAND_FACTOR - mQsMinExpansionHeight;
}
}
float paddingOffset = mNotificationStackScroller.getPaddingOffset();
float translation = paddingOffset / HEADER_RUBBERBAND_FACTOR;
float stackTranslation = mNotificationStackScroller.getStackTranslation();
float translation = stackTranslation / HEADER_RUBBERBAND_FACTOR;
if (mHeadsUpManager.hasPinnedHeadsUp() || mExpansionIsFromHeadsUp) {
translation = mNotificationStackScroller.getTopPadding()
+ mNotificationStackScroller.getPaddingOffset()
translation = mNotificationStackScroller.getTopPadding() + stackTranslation
- mNotificationTopPadding - mQsMinExpansionHeight;
}
return Math.min(0, translation);
@@ -1669,6 +1674,7 @@ public class NotificationPanelView extends PanelView implements
mTwoFingerQsExpandPossible = false;
mExpansionIsFromHeadsUp = false;
mNotificationStackScroller.setTrackingHeadsUp(mHeadsUpTouchHelper.isTrackingHeadsUp());
mExpandingFromHeadsUp = mHeadsUpTouchHelper.isTrackingHeadsUp();
}
private void setListening(boolean listening) {
@@ -2137,11 +2143,12 @@ public class NotificationPanelView extends PanelView implements
public void OnPinnedHeadsUpExistChanged(final boolean exist, boolean changeImmediatly) {
if (exist != mPinnedHeadsUpExist) {
mPinnedHeadsUpExist = exist;
if (!exist) {
if (exist) {
mHeadsUpExistenceChangedRunnable.run();
updateNotificationTranslucency();
} else {
mNotificationStackScroller.performOnAnimationFinished(
mHeadsUpExistenceChangedRunnable);
} else {
mHeadsUpExistenceChangedRunnable.run();
}
}
}
@@ -2166,6 +2173,7 @@ public class NotificationPanelView extends PanelView implements
if (tracking) {
// otherwise we update the state when the expansion is finished
mNotificationStackScroller.setTrackingHeadsUp(true);
mExpandingFromHeadsUp = true;
}
}
}

View File

@@ -179,7 +179,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private float mMinTopOverScrollToEscape;
private int mIntrinsicPadding;
private int mNotificationTopPadding;
private float mPaddingOffset;
private float mStackTranslation;
private float mTopPaddingOverflow;
private boolean mDontReportNextOverScroll;
private boolean mRequestViewResizeAnimationOnLayout;
@@ -516,17 +516,17 @@ public class NotificationStackScrollLayout extends ViewGroup
updateAlgorithmHeightAndPadding();
requestChildrenUpdate();
}
setPaddingOffset(paddingOffset);
setStackTranslation(paddingOffset);
}
public float getPaddingOffset() {
return mPaddingOffset;
public float getStackTranslation() {
return mStackTranslation;
}
private void setPaddingOffset(float paddingOffset) {
if (paddingOffset != mPaddingOffset) {
mPaddingOffset = paddingOffset;
mAmbientState.setStackTranslation(paddingOffset);
private void setStackTranslation(float stackTranslation) {
if (stackTranslation != mStackTranslation) {
mStackTranslation = stackTranslation;
mAmbientState.setStackTranslation(stackTranslation);
requestChildrenUpdate();
}
}
@@ -2381,7 +2381,7 @@ public class NotificationStackScrollLayout extends ViewGroup
* @return the y position of the first notification
*/
public float getNotificationsTopY() {
return mTopPadding + getTranslationY();
return mTopPadding + getStackTranslation();
}
@Override
@@ -2568,7 +2568,7 @@ public class NotificationStackScrollLayout extends ViewGroup
max = bottom;
}
}
return max + getTranslationY();
return max + getStackTranslation();
}
/**
@@ -2684,6 +2684,7 @@ public class NotificationStackScrollLayout extends ViewGroup
public void setHeadsUpManager(HeadsUpManager headsUpManager) {
mHeadsUpManager = headsUpManager;
mAmbientState.setHeadsUpManager(headsUpManager);
mStackScrollAlgorithm.setHeadsUpManager(headsUpManager);
}
public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) {

View File

@@ -71,6 +71,7 @@ public class StackScrollAlgorithm {
private boolean mIsSmallScreen;
private int mMaxNotificationHeight;
private boolean mScaleDimmed;
private HeadsUpManager mHeadsUpManager;
public StackScrollAlgorithm(Context context) {
initConstants(context);
@@ -570,7 +571,8 @@ public class StackScrollAlgorithm {
private int getMaxAllowedChildHeight(View child, AmbientState ambientState) {
if (child instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) child;
if (ambientState != null && ambientState.getTopHeadsUpEntry() == child) {
if (ambientState == null && row.isHeadsUp()
|| ambientState != null && ambientState.getTopHeadsUpEntry() == child) {
int extraSize = row.getIntrinsicHeight() - row.getHeadsUpHeight();
return mCollapsedSize + extraSize;
}
@@ -834,6 +836,13 @@ public class StackScrollAlgorithm {
// current height or the end value of the animation.
mFirstChildMaxHeight = StackStateAnimator.getFinalActualHeight(
mFirstChildWhileExpanding);
if (mFirstChildWhileExpanding instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row =
(ExpandableNotificationRow) mFirstChildWhileExpanding;
if (row.isHeadsUp()) {
mFirstChildMaxHeight += mCollapsedSize - row.getHeadsUpHeight();
}
}
} else {
updateFirstChildMaxSizeToMaxHeight();
}
@@ -876,6 +885,9 @@ public class StackScrollAlgorithm {
}
private View findFirstVisibleChild(ViewGroup container) {
if (mHeadsUpManager != null && mHeadsUpManager.getTopEntry() != null) {
return mHeadsUpManager.getTopEntry().entry.row;
}
int childCount = container.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = container.getChildAt(i);
@@ -916,6 +928,10 @@ public class StackScrollAlgorithm {
}
}
public void setHeadsUpManager(HeadsUpManager headsUpManager) {
mHeadsUpManager = headsUpManager;
}
class StackScrollAlgorithmState {
/**