Fix QS expansion weirdness

- Fix that the clock/avatar could get too large.
- Fix QS collapsing when on Keyguard and scroll view is scrolled
- Fix that clock/avatar didn't grow after a layout when expanding
- Fix flicker in header when overexpanding the panel
- Fix flicker from QS panel when it changes size
- Fix that scroll view still was scrolled after collapsing QS

Bug: 16869692
Bug: 16894194
Change-Id: Ic0f89ab860979db4d0438007b4d0d044d3e8c4ae
This commit is contained in:
Jorim Jaggi
2014-08-14 19:17:11 +02:00
parent 99152aa0ce
commit 11c071a550
3 changed files with 31 additions and 12 deletions

View File

@@ -117,6 +117,7 @@ public class NotificationPanelView extends PanelView implements
private int mQsPeekHeight;
private boolean mStackScrollerOverscrolling;
private boolean mQsExpansionFromOverscroll;
private float mLastOverscroll;
private boolean mQsExpansionEnabled = true;
private ValueAnimator mQsExpansionAnimator;
private FlingAnimationUtils mFlingAnimationUtils;
@@ -273,9 +274,7 @@ public class NotificationPanelView extends PanelView implements
requestScrollerTopPaddingUpdate(false /* animate */);
}
} else {
if (!mStackScrollerOverscrolling) {
setQsExpansion(mQsMinExpansionHeight);
}
setQsExpansion(mQsMinExpansionHeight + mLastOverscroll);
positionClockAndNotifications();
mNotificationStackScroller.setStackHeight(getExpandedHeight());
}
@@ -552,8 +551,8 @@ public class NotificationPanelView extends PanelView implements
}
private float getQsExpansionFraction() {
return (mQsExpansionHeight - mQsMinExpansionHeight)
/ (getTempQsMaxExpansion() - mQsMinExpansionHeight);
return Math.min(1f, (mQsExpansionHeight - mQsMinExpansionHeight)
/ (getTempQsMaxExpansion() - mQsMinExpansionHeight));
}
@Override
@@ -727,6 +726,7 @@ public class NotificationPanelView extends PanelView implements
float rounded = amount >= 1f ? amount : 0f;
mStackScrollerOverscrolling = rounded != 0f && isRubberbanded;
mQsExpansionFromOverscroll = rounded != 0f;
mLastOverscroll = rounded;
updateQsState();
setQsExpansion(mQsMinExpansionHeight + rounded);
}
@@ -1034,7 +1034,9 @@ public class NotificationPanelView extends PanelView implements
}
private float calculateQsTopPadding() {
if (mKeyguardShowing) {
// We can only do the smoother transition on Keyguard when we also are not collapsing from a
// scrolled quick settings.
if (mKeyguardShowing && mScrollYOverride == -1) {
return interpolate(getQsExpansionFraction(),
mNotificationStackScroller.getIntrinsicPadding() - mNotificationTopPadding,
mQsMaxExpansionHeight);
@@ -1090,6 +1092,7 @@ public class NotificationPanelView extends PanelView implements
}
return;
}
mScrollView.setBlockFlinging(true);
ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target);
mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@@ -1101,6 +1104,7 @@ public class NotificationPanelView extends PanelView implements
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mScrollView.setBlockFlinging(false);
mScrollYOverride = -1;
mQsExpansionAnimator = null;
if (onFinishRunnable != null) {

View File

@@ -33,6 +33,7 @@ public class ObservableScrollView extends ScrollView {
private boolean mHandlingTouchEvent;
private float mLastX;
private float mLastY;
private boolean mBlockFlinging;
public ObservableScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -109,6 +110,17 @@ public class ObservableScrollView extends ScrollView {
maxOverScrollX, maxOverScrollY, isTouchEvent);
}
public void setBlockFlinging(boolean blockFlinging) {
mBlockFlinging = blockFlinging;
}
@Override
public void fling(int velocityY) {
if (!mBlockFlinging) {
super.fling(velocityY);
}
}
@Override
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);

View File

@@ -366,7 +366,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
mAlarmStatus.setText(KeyguardStatusView.formatNextAlarm(getContext(), nextAlarm));
}
mAlarmShowing = nextAlarm != null;
updateVisibilities();
updateEverything();
requestCaptureValues();
}
@@ -512,10 +512,13 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
}
public void setShowEmergencyCallsOnly(boolean show) {
mShowEmergencyCallsOnly = show;
if (mExpanded) {
updateVisibilities();
requestCaptureValues();
boolean changed = show != mShowEmergencyCallsOnly;
if (changed) {
mShowEmergencyCallsOnly = show;
if (mExpanded) {
updateEverything();
requestCaptureValues();
}
}
}
@@ -552,7 +555,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
}
private void applyAlpha(View v, float alpha) {
if (v == null) {
if (v == null || v.getVisibility() == View.GONE) {
return;
}
if (alpha == 0f) {