diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-07-30 17:26:55 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-07-31 13:48:43 +0000 |
commit | 61d37f6d1c755263cbc4d9732d9d960e5bf8503d (patch) | |
tree | 800b6ca01b91a58970d3b8f13b4405bb0ebc3657 /packages | |
parent | 1045eee264c4ce834e8c08e33c68e5dfabde972f (diff) | |
download | frameworks_base-61d37f6d1c755263cbc4d9732d9d960e5bf8503d.zip frameworks_base-61d37f6d1c755263cbc4d9732d9d960e5bf8503d.tar.gz frameworks_base-61d37f6d1c755263cbc4d9732d9d960e5bf8503d.tar.bz2 |
Implement nice QS expansion transition in Keyguard
Bug: 16010455
Bug: 15192264
Change-Id: I764652e73ea8e87ad12b9241e038bff843a0a221
Diffstat (limited to 'packages')
3 files changed, 80 insertions, 27 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index e7e18cf..602b914 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -139,6 +139,7 @@ public class NotificationPanelView extends PanelView implements private boolean mIsLaunchTransitionRunning; private Runnable mLaunchAnimationEndRunnable; private boolean mOnlyAffordanceInThisMotion; + private boolean mKeyguardStatusBarAnimatingIn; public NotificationPanelView(Context context, AttributeSet attrs) { super(context, attrs); @@ -201,7 +202,7 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusView.setPivotY((FONT_HEIGHT - CAP_HEIGHT) / 2048f * mClockView.getTextSize()); // Calculate quick setting heights. - mQsMinExpansionHeight = mHeader.getCollapsedHeight() + mQsPeekHeight; + mQsMinExpansionHeight = mKeyguardShowing ? 0 : mHeader.getCollapsedHeight() + mQsPeekHeight; mQsMaxExpansionHeight = mHeader.getExpandedHeight() + mQsContainer.getHeight(); if (mQsExpanded) { if (mQsFullyExpanded) { @@ -673,6 +674,7 @@ public class NotificationPanelView extends PanelView implements public void setBarState(int statusBarState) { boolean keyguardShowing = statusBarState == StatusBarState.KEYGUARD || statusBarState == StatusBarState.SHADE_LOCKED; + mKeyguardStatusBar.setAlpha(1f); mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE); if (!mKeyguardShowing && keyguardShowing) { setQsTranslation(mQsExpansionHeight); @@ -686,7 +688,7 @@ public class NotificationPanelView extends PanelView implements private void updateQsState() { boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling; mHeader.setVisibility((mQsExpanded || !mKeyguardShowing) ? View.VISIBLE : View.INVISIBLE); - mHeader.setExpanded(mQsExpanded && !mStackScrollerOverscrolling); + mHeader.setExpanded(mKeyguardShowing || (mQsExpanded && !mStackScrollerOverscrolling)); mNotificationStackScroller.setScrollingEnabled( mStatusBarState != StatusBarState.KEYGUARD && (!mQsExpanded || mQsExpansionFromOverscroll)); @@ -705,10 +707,22 @@ public class NotificationPanelView extends PanelView implements setQsExpanded(false); } mQsExpansionHeight = height; - mHeader.setExpansion(getQsExpansionFraction()); + mHeader.setExpansion(getHeaderExpansionFraction()); setQsTranslation(height); requestScrollerTopPaddingUpdate(false /* animate */); updateNotificationScrim(height); + if (mKeyguardShowing) { + float alpha = getQsExpansionFraction(); + alpha *= 2; + alpha = Math.min(1, alpha); + alpha = 1 - alpha; + if (alpha == 0f) { + mKeyguardStatusBar.setVisibility(View.INVISIBLE); + } else { + mKeyguardStatusBar.setVisibility(View.VISIBLE); + mKeyguardStatusBar.setAlpha(alpha); + } + } } private void updateNotificationScrim(float height) { @@ -718,12 +732,33 @@ public class NotificationPanelView extends PanelView implements mNotificationStackScroller.setScrimAlpha(progress); } + private float getHeaderExpansionFraction() { + if (!mKeyguardShowing) { + return getQsExpansionFraction(); + } else { + return 1f; + } + } + private void setQsTranslation(float height) { mQsContainer.setY(height - mQsContainer.getHeight() + getHeaderTranslation()); + if (mKeyguardShowing) { + mHeader.setY(interpolate(getQsExpansionFraction(), -mHeader.getHeight(), 0)); + } + } + + private float calculateQsTopPadding() { + if (mKeyguardShowing) { + return interpolate(getQsExpansionFraction(), + mNotificationStackScroller.getIntrinsicPadding() - mNotificationTopPadding, + mQsMaxExpansionHeight); + } else { + return mQsExpansionHeight; + } } private void requestScrollerTopPaddingUpdate(boolean animate) { - mNotificationStackScroller.updateTopPadding(mQsExpansionHeight, + mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(), mScrollView.getScrollY(), mAnimateNextTopPaddingChange || animate); mAnimateNextTopPaddingChange = false; @@ -799,8 +834,9 @@ public class NotificationPanelView extends PanelView implements if (!mQsExpansionEnabled) { return false; } - boolean onHeader = x >= mHeader.getLeft() && x <= mHeader.getRight() - && y >= mHeader.getTop() && y <= mHeader.getBottom(); + View header = mKeyguardShowing ? mKeyguardStatusBar : mHeader; + boolean onHeader = x >= header.getLeft() && x <= header.getRight() + && y >= header.getTop() && y <= header.getBottom(); if (mQsExpanded) { return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0); } else { @@ -867,12 +903,9 @@ public class NotificationPanelView extends PanelView implements } int maxHeight; if (mTwoFingerQsExpand || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted) { - maxHeight = (int) calculatePanelHeightQsExpanded(); + maxHeight = Math.max(calculatePanelHeightQsExpanded(), calculatePanelHeightShade()); } else { - int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin(); - maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin - - mTopPaddingAdjustment; - maxHeight += mNotificationStackScroller.getTopPaddingOverflow(); + maxHeight = calculatePanelHeightShade(); } maxHeight = Math.max(maxHeight, min); return maxHeight; @@ -917,7 +950,15 @@ public class NotificationPanelView extends PanelView implements return qsTempMaxExpansion; } - private float calculatePanelHeightQsExpanded() { + private int calculatePanelHeightShade() { + int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin(); + int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin + - mTopPaddingAdjustment; + maxHeight += mNotificationStackScroller.getTopPaddingOverflow(); + return maxHeight; + } + + private int calculatePanelHeightQsExpanded() { float notificationHeight = mNotificationStackScroller.getHeight() - mNotificationStackScroller.getEmptyBottomMargin() - mNotificationStackScroller.getTopPadding(); @@ -930,7 +971,7 @@ public class NotificationPanelView extends PanelView implements - getScrollViewScrollY(); totalHeight = Math.max(fullyCollapsedHeight, mNotificationStackScroller.getHeight()); } - return totalHeight; + return (int) totalHeight; } private int getScrollViewScrollY() { @@ -1035,7 +1076,9 @@ public class NotificationPanelView extends PanelView implements } alpha = Math.max(0, Math.min(alpha, 1)); alpha = (float) Math.pow(alpha, 0.75); - mKeyguardStatusBar.setAlpha(alpha); + if (!mQsExpanded && !mKeyguardStatusBarAnimatingIn) { + mKeyguardStatusBar.setAlpha(alpha); + } mKeyguardBottomArea.setAlpha(alpha); setQsTranslation(mQsExpansionHeight); } @@ -1358,4 +1401,8 @@ public class NotificationPanelView extends PanelView implements mEmptyDragAmount = amount * factor; positionClockAndNotifications(); } + + private static float interpolate(float t, float start, float end) { + return (1 - t) * start + t * end; + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 6e7266e..5e54b30 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -409,8 +409,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private Interpolator mLinearOutSlowIn; private Interpolator mLinearInterpolator = new LinearInterpolator(); private Interpolator mBackdropInterpolator = new AccelerateDecelerateInterpolator(); - private Interpolator mAlphaIn = new PathInterpolator(0f, 0.2f, 1f, 1f); - private Interpolator mAlphaOut = new PathInterpolator(0f, 0f, 0.8f, 1f); + public static final Interpolator ALPHA_IN = new PathInterpolator(0.4f, 0f, 1f, 1f); + public static final Interpolator ALPHA_OUT = new PathInterpolator(0f, 0f, 0.8f, 1f); private FrameLayout mBackdrop; private ImageView mBackdropFront, mBackdropBack; @@ -1937,7 +1937,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, .alpha(0f) .setDuration(160) .setStartDelay(0) - .setInterpolator(mAlphaOut) + .setInterpolator(ALPHA_OUT) .withEndAction(new Runnable() { @Override public void run() { @@ -1959,7 +1959,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, v.animate() .alpha(1f) .setDuration(320) - .setInterpolator(mAlphaIn) + .setInterpolator(ALPHA_IN) .setStartDelay(50); // Synchronize the motion with the Keyguard fading if necessary. @@ -3414,20 +3414,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } private void updateDozingState() { - final boolean bottomGone = mKeyguardBottomArea.getVisibility() == View.GONE; + if (mState != StatusBarState.KEYGUARD) { + return; + } if (mDozing) { mNotificationPanel.setBackgroundColor(0xff000000); mKeyguardStatusBar.setVisibility(View.INVISIBLE); - if (!bottomGone) { - mKeyguardBottomArea.setVisibility(View.INVISIBLE); - } + mKeyguardBottomArea.setVisibility(View.INVISIBLE); mStackScroller.setDark(true, false /*animate*/); } else { mNotificationPanel.setBackground(null); mKeyguardStatusBar.setVisibility(View.VISIBLE); - if (!bottomGone) { mKeyguardBottomArea.setVisibility(View.VISIBLE); - } mStackScroller.setDark(false, false /*animate*/); } mScrimController.setDozing(mDozing); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java index 039b908..29b1403 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java @@ -286,13 +286,17 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL if (detached) { getOverlay().add(mSignalCluster); } else { - getOverlay().remove(mSignalCluster); - mSystemIcons.addView(mSignalCluster, 1); + reattachSignalCluster(); } } mSignalClusterDetached = detached; } + private void reattachSignalCluster() { + getOverlay().remove(mSignalCluster); + mSystemIcons.addView(mSignalCluster, 1); + } + private void updateSystemIconsLayoutParams() { RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsSuperContainer.getLayoutParams(); int rule = mExpanded @@ -441,9 +445,12 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL } public void onSystemIconsDetached() { + if (mSignalClusterDetached) { + reattachSignalCluster(); + mSignalClusterDetached = false; + } if (mStatusIcons != null) { mStatusIcons.setVisibility(View.VISIBLE); - mStatusIcons.setAlpha(1f); } if (mSignalCluster != null) { mSignalCluster.setVisibility(View.VISIBLE); @@ -504,6 +511,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL mShowEmergencyCallsOnly = show; if (mExpanded) { updateVisibilities(); + requestCaptureValues(); } } |