|
44 | 44 | import java.util.ArrayList; |
45 | 45 |
|
46 | 46 | public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwitchListener, |
47 | | - OnLongClickListener { |
| 47 | + OnLongClickListener, ChallengeLayout.OnBouncerStateChangedListener { |
48 | 48 |
|
49 | 49 | ZInterpolator mZInterpolator = new ZInterpolator(0.5f); |
50 | 50 | private static float CAMERA_DISTANCE = 10000; |
@@ -73,6 +73,10 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit |
73 | 73 |
|
74 | 74 | private int mWidgetToResetAfterFadeOut; |
75 | 75 |
|
| 76 | + // Bouncer |
| 77 | + protected int BOUNCER_ZOOM_IN_OUT_DURATION = 250; |
| 78 | + private float BOUNCER_SCALE_FACTOR = 0.67f; |
| 79 | + |
76 | 80 | // Background worker thread: used here for persistence, also made available to widget frames |
77 | 81 | private final HandlerThread mBackgroundWorkerThread; |
78 | 82 | private final Handler mBackgroundWorkerHandler; |
@@ -712,4 +716,46 @@ protected void setPageHoveringOverDeleteDropTarget(int viewIndex, boolean isHove |
712 | 716 | KeyguardWidgetFrame child = getWidgetPageAt(viewIndex); |
713 | 717 | child.setIsHoveringOverDeleteDropTarget(isHovering); |
714 | 718 | } |
| 719 | + |
| 720 | + // ChallengeLayout.OnBouncerStateChangedListener |
| 721 | + @Override |
| 722 | + public void onBouncerStateChanged(boolean bouncerActive) { |
| 723 | + if (bouncerActive) { |
| 724 | + zoomOutToBouncer(); |
| 725 | + } else { |
| 726 | + zoomInFromBouncer(); |
| 727 | + } |
| 728 | + } |
| 729 | + |
| 730 | + // Zoom in after the bouncer is dismissed |
| 731 | + void zoomInFromBouncer() { |
| 732 | + if (mZoomInOutAnim != null && mZoomInOutAnim.isRunning()) { |
| 733 | + mZoomInOutAnim.cancel(); |
| 734 | + } |
| 735 | + final View currentPage = getPageAt(getCurrentPage()); |
| 736 | + if (currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f) { |
| 737 | + mZoomInOutAnim = new AnimatorSet(); |
| 738 | + mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION); |
| 739 | + mZoomInOutAnim.playTogether( |
| 740 | + ObjectAnimator.ofFloat(currentPage, "scaleX", 1f), |
| 741 | + ObjectAnimator.ofFloat(currentPage , "scaleY", 1f)); |
| 742 | + mZoomInOutAnim.start(); |
| 743 | + } |
| 744 | + } |
| 745 | + |
| 746 | + // Zoom out after the bouncer is initiated |
| 747 | + void zoomOutToBouncer() { |
| 748 | + if (mZoomInOutAnim != null && mZoomInOutAnim.isRunning()) { |
| 749 | + mZoomInOutAnim.cancel(); |
| 750 | + } |
| 751 | + View currentPage = getPageAt(getCurrentPage()); |
| 752 | + if (!(currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f)) { |
| 753 | + mZoomInOutAnim = new AnimatorSet(); |
| 754 | + mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION); |
| 755 | + mZoomInOutAnim.playTogether( |
| 756 | + ObjectAnimator.ofFloat(currentPage, "scaleX", BOUNCER_SCALE_FACTOR), |
| 757 | + ObjectAnimator.ofFloat(currentPage, "scaleY", BOUNCER_SCALE_FACTOR)); |
| 758 | + mZoomInOutAnim.start(); |
| 759 | + } |
| 760 | + } |
715 | 761 | } |
0 commit comments