summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2014-05-30 23:17:03 +0200
committerJorim Jaggi <jjaggi@google.com>2014-05-31 02:48:06 +0200
commite29b2dbc762bfa66093d76f5a65f55328d8753c9 (patch)
tree715078ec5618bb210f671a9a8679289a301ffb95 /packages
parent283c907a6a84c5d9ffe38d3468e76131e6917105 (diff)
downloadframeworks_base-e29b2dbc762bfa66093d76f5a65f55328d8753c9.zip
frameworks_base-e29b2dbc762bfa66093d76f5a65f55328d8753c9.tar.gz
frameworks_base-e29b2dbc762bfa66093d76f5a65f55328d8753c9.tar.bz2
Fade scrim in unlock animation.
This also introduces a startTime which gets sent from window manager to SystemUI, which tells when the animation should start, to allow for a more synchronized animation with fading out the scrim and fading in the activity behind. Bug: 15163546 Change-Id: I16212b1ef9eb76f1f98734da1d14fc5b7e626937
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java31
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java47
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java9
7 files changed, 125 insertions, 28 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index 4c7f3df..b280ab7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -204,9 +204,9 @@ public class KeyguardService extends Service {
}
@Override
- public void startKeyguardExitAnimation(long fadeoutDuration) {
+ public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
checkPermission();
- mKeyguardViewMediator.startKeyguardExitAnimation(fadeoutDuration);
+ mKeyguardViewMediator.startKeyguardExitAnimation(startTime, fadeoutDuration);
}
};
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 7110d8d..f7b4994 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -1083,7 +1083,8 @@ public class KeyguardViewMediator extends SystemUI {
handleDismiss();
break;
case START_KEYGUARD_EXIT_ANIM:
- handleStartKeyguardExitAnimation((Long) msg.obj);
+ StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj;
+ handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration);
break;
}
}
@@ -1227,7 +1228,7 @@ public class KeyguardViewMediator extends SystemUI {
}
}
- private void handleStartKeyguardExitAnimation(long fadeoutDuration) {
+ private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration) {
synchronized (KeyguardViewMediator.this) {
// only play "unlock" noises if not on a call (since the incall UI
@@ -1236,7 +1237,7 @@ public class KeyguardViewMediator extends SystemUI {
playSounds(false);
}
- mStatusBarKeyguardViewManager.hide();
+ mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration);
mShowing = false;
mKeyguardDonePending = false;
updateActivityLockScreenState();
@@ -1346,12 +1347,24 @@ public class KeyguardViewMediator extends SystemUI {
return mStatusBarKeyguardViewManager;
}
- public void startKeyguardExitAnimation(long fadeoutDuration) {
- Message msg = mHandler.obtainMessage(START_KEYGUARD_EXIT_ANIM, fadeoutDuration);
+ public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
+ Message msg = mHandler.obtainMessage(START_KEYGUARD_EXIT_ANIM,
+ new StartKeyguardExitAnimParams(startTime, fadeoutDuration));
mHandler.sendMessage(msg);
}
public ViewMediatorCallback getViewMediatorCallback() {
return mViewMediatorCallback;
}
+
+ private static class StartKeyguardExitAnimParams {
+
+ long startTime;
+ long fadeoutDuration;
+
+ private StartKeyguardExitAnimParams(long startTime, long fadeoutDuration) {
+ this.startTime = startTime;
+ this.fadeoutDuration = fadeoutDuration;
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index b7a7b0a..3aaace4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -17,10 +17,14 @@
package com.android.systemui.statusbar.phone;
import android.content.Context;
+import android.os.SystemClock;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
+import android.view.animation.LinearInterpolator;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardViewBase;
@@ -43,6 +47,8 @@ public class KeyguardBouncer {
private StatusBarWindowManager mWindowManager;
private KeyguardViewBase mKeyguardView;
private ViewGroup mRoot;
+ private Interpolator mFadeOutInterpolator = new LinearInterpolator();
+ private boolean mFadingOut;
public KeyguardBouncer(Context context, ViewMediatorCallback callback,
LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
@@ -86,6 +92,29 @@ public class KeyguardBouncer {
}
}
+ public void animateHide(long delay, long duration) {
+ if (isShowing()) {
+ mFadingOut = true;
+ mKeyguardView.animate()
+ .alpha(0)
+ .withLayer()
+
+ // Make it disappear faster, as the focus should be on the activity behind.
+ .setDuration(duration / 3)
+ .setInterpolator(mFadeOutInterpolator)
+ .setStartDelay(delay)
+ .withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mFadingOut = false;
+ hide(true /* destroyView */);
+ }
+ });
+ } else {
+ hide(true /* destroyView */);
+ }
+ }
+
/**
* Reset the state of the view.
*/
@@ -110,7 +139,7 @@ public class KeyguardBouncer {
}
public boolean isShowing() {
- return mRoot != null && mRoot.getVisibility() == View.VISIBLE;
+ return mRoot != null && mRoot.getVisibility() == View.VISIBLE && !mFadingOut;
}
public void prepare() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index c5a9b85..220b691 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -200,8 +200,10 @@ public abstract class PanelView extends FrameLayout {
case MotionEvent.ACTION_CANCEL:
mTrackingPointer = -1;
trackMovement(event);
- boolean expand = flingWithCurrentVelocity();
+ float vel = getCurrentVelocity();
+ boolean expand = flingExpands(vel);
onTrackingStopped(expand);
+ fling(vel, expand);
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
@@ -323,18 +325,15 @@ public abstract class PanelView extends FrameLayout {
}
/**
- * @return whether the panel will be expanded after the animation
+ * @param vel the current velocity of the motion
+ * @return whether a fling should expands the panel; contracts otherwise
*/
- private boolean flingWithCurrentVelocity() {
- float vel = getCurrentVelocity();
- boolean expand;
+ private boolean flingExpands(float vel) {
if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
- expand = getExpandedFraction() > 0.5f;
+ return getExpandedFraction() > 0.5f;
} else {
- expand = vel > 0;
+ return vel > 0;
}
- fling(vel, expand);
- return expand;
}
protected void fling(float vel, boolean expand) {
@@ -342,6 +341,7 @@ public abstract class PanelView extends FrameLayout {
float target = expand ? getMaxPanelHeight() : 0.0f;
if (target == mExpandedHeight) {
onExpandingFinished();
+ mBar.panelExpansionChanged(this, mExpandedFraction);
return;
}
ValueAnimator animator = ValueAnimator.ofFloat(mExpandedHeight, target);
@@ -430,7 +430,7 @@ public abstract class PanelView extends FrameLayout {
public void setExpandedHeightInternal(float h) {
float fh = getMaxPanelHeight();
- mExpandedHeight = Math.min(fh, h);
+ mExpandedHeight = Math.max(0, Math.min(fh, h));
float overExpansion = h - fh;
overExpansion = Math.max(0, overExpansion);
if (overExpansion != mOverExpansion) {
@@ -442,7 +442,7 @@ public abstract class PanelView extends FrameLayout {
}
onHeightUpdated(mExpandedHeight);
- mExpandedFraction = Math.min(1f, (fh == 0) ? 0 : h / fh);
+ mExpandedFraction = Math.min(1f, (fh == 0) ? 0 : mExpandedHeight / fh);
}
protected void onOverExpansionChanged(float overExpansion) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 6156fc3..1264d75 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -19,16 +19,12 @@ package com.android.systemui.statusbar.phone;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
-import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.ViewTreeObserver;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
/**
* Controls both the scrim behind the notifications and in front of the notifications (when a
@@ -53,6 +49,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
private boolean mAnimateChange;
private boolean mUpdatePending;
private boolean mExpanding;
+ private boolean mAnimateKeyguardFadingOut;
+ private long mDurationOverride = -1;
+ private long mAnimationDelay;
+ private Runnable mOnAnimationFinished;
+ private boolean mAnimationStarted;
private final Interpolator mInterpolator = new DecelerateInterpolator();
@@ -87,14 +88,26 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
scheduleUpdate();
}
+ public void animateKeyguardFadingOut(long delay, long duration, Runnable onAnimationFinished) {
+ mAnimateKeyguardFadingOut = true;
+ mDurationOverride = duration;
+ mAnimationDelay = delay;
+ mAnimateChange = true;
+ mOnAnimationFinished = onAnimationFinished;
+ scheduleUpdate();
+ }
+
private void scheduleUpdate() {
if (mUpdatePending) return;
+
+ // Make sure that a frame gets scheduled.
+ mScrimBehind.invalidate();
mScrimBehind.getViewTreeObserver().addOnPreDrawListener(this);
mUpdatePending = true;
}
private void updateScrims() {
- if (!mKeyguardShowing) {
+ if (!mKeyguardShowing || mAnimateKeyguardFadingOut) {
updateScrimNormal();
setScrimInFrontColor(0);
} else {
@@ -170,8 +183,20 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
}
});
anim.setInterpolator(mInterpolator);
- anim.setDuration(ANIMATION_DURATION);
+ anim.setStartDelay(mAnimationDelay);
+ anim.setDuration(mDurationOverride != -1 ? mDurationOverride : ANIMATION_DURATION);
+ anim.addListener(new AnimatorListenerAdapter() {
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (mOnAnimationFinished != null) {
+ mOnAnimationFinished.run();
+ mOnAnimationFinished = null;
+ }
+ }
+ });
anim.start();
+ mAnimationStarted = true;
}
private int getBackgroundAlpha(View scrim) {
@@ -188,6 +213,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener {
mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this);
mUpdatePending = false;
updateScrims();
+ mAnimateKeyguardFadingOut = false;
+ mDurationOverride = -1;
+ mAnimationDelay = 0;
+
+ // Make sure that we always call the listener even if we didn't start an animation.
+ if (!mAnimationStarted && mOnAnimationFinished != null) {
+ mOnAnimationFinished.run();
+ mOnAnimationFinished = null;
+ }
+ mAnimationStarted = false;
return true;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index d5551b8..e3145a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
+import android.os.SystemClock;
import android.util.Slog;
import android.view.KeyEvent;
import android.view.View;
@@ -183,11 +184,23 @@ public class StatusBarKeyguardViewManager {
/**
* Hides the keyguard view
*/
- public void hide() {
+ public void hide(long startTime, long fadeoutDuration) {
mShowing = false;
mPhoneStatusBar.hideKeyguard();
+ mStatusBarWindowManager.setKeyguardFadingAway(true);
mStatusBarWindowManager.setKeyguardShowing(false);
- mBouncer.hide(true /* destroyView */);
+ long uptimeMillis = SystemClock.uptimeMillis();
+ long delay = startTime - uptimeMillis;
+ if (delay < 0) {
+ delay = 0;
+ }
+ mBouncer.animateHide(delay, fadeoutDuration);
+ mScrimController.animateKeyguardFadingOut(delay, fadeoutDuration, new Runnable() {
+ @Override
+ public void run() {
+ mStatusBarWindowManager.setKeyguardFadingAway(false);
+ }
+ });
mViewMediatorCallback.keyguardGone();
updateStates();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index b7bf6cd..fe57cef 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -124,7 +124,8 @@ public class StatusBarWindowManager {
}
private void applyHeight(State state) {
- boolean expanded = state.isKeyguardShowingAndNotOccluded() || state.statusBarExpanded;
+ boolean expanded = state.isKeyguardShowingAndNotOccluded() || state.statusBarExpanded
+ || state.keyguardFadingAway;
if (expanded) {
mLp.height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
@@ -201,6 +202,11 @@ public class StatusBarWindowManager {
apply(mCurrentState);
}
+ public void setKeyguardFadingAway(boolean keyguardFadingAway) {
+ mCurrentState.keyguardFadingAway = keyguardFadingAway;
+ apply(mCurrentState);
+ }
+
/**
* @param state The {@link StatusBarState} of the status bar.
*/
@@ -217,6 +223,7 @@ public class StatusBarWindowManager {
boolean statusBarFocusable;
long keyguardUserActivityTimeout;
boolean bouncerShowing;
+ boolean keyguardFadingAway;
/**
* The {@link BaseStatusBar} state from the status bar.