Skip to content

Commit 70c2f87

Browse files
author
Winson Chung
committed
Synchronizing bouncer duration with page scaling duration.
Change-Id: I9fba381582a083ce2ab26375698c5a6f3d554a1b
1 parent 838195d commit 70c2f87

File tree

5 files changed

+56
-13
lines changed

5 files changed

+56
-13
lines changed

policy/src/com/android/internal/policy/impl/keyguard/ChallengeLayout.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public interface ChallengeLayout {
5858
*/
5959
boolean isBouncing();
6060

61+
/**
62+
* Returns the duration of the bounce animation.
63+
*/
64+
int getBouncerAnimationDuration();
65+
6166
/**
6267
* Set a listener that will respond to changes in bouncer state.
6368
*

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ protected void onFinishInflate() {
207207
ChallengeLayout challenge = slider != null ? slider :
208208
(ChallengeLayout) findViewById(R.id.multi_pane_challenge);
209209
challenge.setOnBouncerStateChangedListener(mViewStateManager);
210+
mAppWidgetContainer.setBouncerAnimationDuration(challenge.getBouncerAnimationDuration());
210211
mViewStateManager.setPagedView(mAppWidgetContainer);
211212
mViewStateManager.setChallengeLayout(challenge);
212213
mSecurityViewContainer = (KeyguardSecurityViewFlipper) findViewById(R.id.view_flipper);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import android.view.ViewGroup;
3737
import android.view.accessibility.AccessibilityEvent;
3838
import android.view.accessibility.AccessibilityManager;
39+
import android.view.animation.DecelerateInterpolator;
3940
import android.widget.FrameLayout;
4041

4142
import com.android.internal.widget.LockPatternUtils;
@@ -71,7 +72,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
7172
private int mWidgetToResetAfterFadeOut;
7273

7374
// Bouncer
74-
protected int BOUNCER_ZOOM_IN_OUT_DURATION = 250;
75+
private int mBouncerZoomInOutDuration = 250;
7576
private float BOUNCER_SCALE_FACTOR = 0.67f;
7677

7778
// Background worker thread: used here for persistence, also made available to widget frames
@@ -747,6 +748,10 @@ public void onBouncerStateChanged(boolean bouncerActive) {
747748
}
748749
}
749750

751+
void setBouncerAnimationDuration(int duration) {
752+
mBouncerZoomInOutDuration = duration;
753+
}
754+
750755
// Zoom in after the bouncer is dismissed
751756
void zoomInFromBouncer() {
752757
if (mZoomInOutAnim != null && mZoomInOutAnim.isRunning()) {
@@ -755,10 +760,11 @@ void zoomInFromBouncer() {
755760
final View currentPage = getPageAt(getCurrentPage());
756761
if (currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f) {
757762
mZoomInOutAnim = new AnimatorSet();
758-
mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION);
759763
mZoomInOutAnim.playTogether(
760764
ObjectAnimator.ofFloat(currentPage, "scaleX", 1f),
761765
ObjectAnimator.ofFloat(currentPage , "scaleY", 1f));
766+
mZoomInOutAnim.setDuration(mBouncerZoomInOutDuration);
767+
mZoomInOutAnim.setInterpolator(new DecelerateInterpolator(1.5f));
762768
mZoomInOutAnim.start();
763769
}
764770
}
@@ -768,18 +774,22 @@ void zoomOutToBouncer() {
768774
if (mZoomInOutAnim != null && mZoomInOutAnim.isRunning()) {
769775
mZoomInOutAnim.cancel();
770776
}
771-
View currentPage = getPageAt(getCurrentPage());
772-
currentPage.setPivotY(0);
773-
// Note: we are working around the issue that setting the x-pivot to the same value as it
774-
// was does not actually work.
775-
currentPage.setPivotX(0);
776-
currentPage.setPivotX(currentPage.getMeasuredWidth() / 2);
777+
int curPage = getCurrentPage();
778+
View currentPage = getPageAt(curPage);
779+
if (shouldSetTopAlignedPivotForWidget(curPage)) {
780+
currentPage.setPivotY(0);
781+
// Note: we are working around the issue that setting the x-pivot to the same value as it
782+
// was does not actually work.
783+
currentPage.setPivotX(0);
784+
currentPage.setPivotX(currentPage.getMeasuredWidth() / 2);
785+
}
777786
if (!(currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f)) {
778787
mZoomInOutAnim = new AnimatorSet();
779-
mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION);
780788
mZoomInOutAnim.playTogether(
781789
ObjectAnimator.ofFloat(currentPage, "scaleX", BOUNCER_SCALE_FACTOR),
782790
ObjectAnimator.ofFloat(currentPage, "scaleY", BOUNCER_SCALE_FACTOR));
791+
mZoomInOutAnim.setDuration(mBouncerZoomInOutDuration);
792+
mZoomInOutAnim.setInterpolator(new DecelerateInterpolator(1.5f));
783793
mZoomInOutAnim.start();
784794
}
785795
}

policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
4040

4141
public static final int HORIZONTAL = LinearLayout.HORIZONTAL;
4242
public static final int VERTICAL = LinearLayout.VERTICAL;
43-
protected static final int ANIMATE_BOUNCE_DURATION = 750;
43+
public static final int ANIMATE_BOUNCE_DURATION = 350;
4444

4545
private KeyguardSecurityContainer mChallengeView;
4646
private View mUserSwitcherView;
@@ -96,6 +96,11 @@ public boolean isChallengeOverlapping() {
9696
public void showChallenge(boolean b) {
9797
}
9898

99+
@Override
100+
public int getBouncerAnimationDuration() {
101+
return ANIMATE_BOUNCE_DURATION;
102+
}
103+
99104
@Override
100105
public void showBouncer() {
101106
if (mIsBouncing) return;

policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout
5656
private static final int DRAG_HANDLE_OPEN_ABOVE = 8; // dp
5757
private static final int DRAG_HANDLE_OPEN_BELOW = 0; // dp
5858

59-
private static final int HANDLE_ANIMATE_DURATION = 200; // ms
59+
private static final int HANDLE_ANIMATE_DURATION = 250; // ms
6060

6161
// Drawn to show the drag handle in closed state; crossfades to the challenge view
6262
// when challenge is fully visible
@@ -468,14 +468,27 @@ public boolean isBouncing() {
468468
return mIsBouncing;
469469
}
470470

471+
@Override
472+
public int getBouncerAnimationDuration() {
473+
return HANDLE_ANIMATE_DURATION;
474+
}
475+
471476
@Override
472477
public void showBouncer() {
473478
if (mIsBouncing) return;
474479
mWasChallengeShowing = mChallengeShowing;
475480
mIsBouncing = true;
476481
showChallenge(true);
477482
if (mScrimView != null) {
478-
mScrimView.setVisibility(VISIBLE);
483+
Animator anim = ObjectAnimator.ofFloat(mScrimView, "alpha", 1f);
484+
anim.setDuration(HANDLE_ANIMATE_DURATION);
485+
anim.addListener(new AnimatorListenerAdapter() {
486+
@Override
487+
public void onAnimationStart(Animator animation) {
488+
mScrimView.setVisibility(VISIBLE);
489+
}
490+
});
491+
anim.start();
479492
}
480493
if (mChallengeView != null) {
481494
mChallengeView.showBouncer(HANDLE_ANIMATE_DURATION);
@@ -498,8 +511,17 @@ public void hideBouncer() {
498511
if (!mIsBouncing) return;
499512
if (!mWasChallengeShowing) showChallenge(false);
500513
mIsBouncing = false;
514+
501515
if (mScrimView != null) {
502-
mScrimView.setVisibility(GONE);
516+
Animator anim = ObjectAnimator.ofFloat(mScrimView, "alpha", 0f);
517+
anim.setDuration(HANDLE_ANIMATE_DURATION);
518+
anim.addListener(new AnimatorListenerAdapter() {
519+
@Override
520+
public void onAnimationEnd(Animator animation) {
521+
mScrimView.setVisibility(GONE);
522+
}
523+
});
524+
anim.start();
503525
}
504526
if (mChallengeView != null) {
505527
mChallengeView.hideBouncer(HANDLE_ANIMATE_DURATION);

0 commit comments

Comments
 (0)