diff options
| author | Winson Chung <winsonc@google.com> | 2012-10-29 17:53:28 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-29 17:53:28 -0700 |
| commit | 7bf93cf50fc028a50433741b4e1f1ee8b80f74f0 (patch) | |
| tree | 3023f4b6838a7e6c709e37141f883d383ed0cca1 | |
| parent | 750d5e11dffa89f90a71aa55244d069ebd8e39d0 (diff) | |
| parent | 9dc9923085c4407268e8b6aa32c06fe30e3a7f7f (diff) | |
| download | frameworks_base-7bf93cf50fc028a50433741b4e1f1ee8b80f74f0.zip frameworks_base-7bf93cf50fc028a50433741b4e1f1ee8b80f74f0.tar.gz frameworks_base-7bf93cf50fc028a50433741b4e1f1ee8b80f74f0.tar.bz2 | |
Merge "Deferring zoom out animation until after snapToPage and animateDragViewToOriginalPosition." into jb-mr1-lockscreen-dev
3 files changed, 51 insertions, 14 deletions
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java index abaf9ff..78d0e7e 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java @@ -49,6 +49,13 @@ public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChalle mChallengeLayout = layout; } + public boolean isChallengeShowing() { + if (mChallengeLayout != null) { + return mChallengeLayout.isChallengeShowing(); + } + return false; + } + public void setSecurityViewContainer(KeyguardSecurityView container) { mKeyguardSecurityContainer = container; } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java index a9bb7bb..15ce760 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java @@ -519,7 +519,8 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit @Override public boolean onLongClick(View v) { - if (startReordering()) { + // Disallow long pressing to reorder if the challenge is showing + if (!mViewStateManager.isChallengeShowing() && startReordering()) { return true; } return false; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java index 25ce6d0..657a31f 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java @@ -201,9 +201,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // We use the min scale to determine how much to expand the actually PagedView measured // dimensions such that when we are zoomed out, the view is not clipped private int REORDERING_DROP_REPOSITION_DURATION = 200; - protected int REORDERING_REORDER_REPOSITION_DURATION = 350; + protected int REORDERING_REORDER_REPOSITION_DURATION = 300; protected int REORDERING_ZOOM_IN_OUT_DURATION = 250; - private int REORDERING_SIDE_PAGE_HOVER_TIMEOUT = 500; + private int REORDERING_SIDE_PAGE_HOVER_TIMEOUT = 300; private float REORDERING_SIDE_PAGE_BUFFER_PERCENTAGE = 0.1f; private float mMinScale = 1f; protected View mDragView; @@ -215,6 +215,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // This variable's scope is for the duration of startReordering() and after the zoomIn() // animation after endReordering() private boolean mIsReordering; + // The runnable that settles the page after snapToPage and animateDragViewToOriginalPosition + private int NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT = 2; + private int mPostReorderingPreZoomInRemainingAnimationCount; + private Runnable mPostReorderingPreZoomInRunnable; // Edge swiping private boolean mOnlyAllowEdgeSwipes = false; @@ -536,6 +540,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc pageEndMoving(); } + onPostReorderingAnimationCompleted(); + // Notify the user when the page changes AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); @@ -1971,13 +1977,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } // Animate the drag view back to the original position - void animateChildrenToOriginalPosition() { + void animateDragViewToOriginalPosition() { if (mDragView != null) { AnimatorSet anim = new AnimatorSet(); anim.setDuration(REORDERING_DROP_REPOSITION_DURATION); anim.playTogether( ObjectAnimator.ofFloat(mDragView, "translationX", 0f), ObjectAnimator.ofFloat(mDragView, "translationY", 0f)); + anim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + onPostReorderingAnimationCompleted(); + } + }); anim.start(); } } @@ -2010,6 +2022,16 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc invalidate(); } + private void onPostReorderingAnimationCompleted() { + // Trigger the callback when reordering has settled + --mPostReorderingPreZoomInRemainingAnimationCount; + if (mPostReorderingPreZoomInRunnable != null && + mPostReorderingPreZoomInRemainingAnimationCount == 0) { + mPostReorderingPreZoomInRunnable.run(); + mPostReorderingPreZoomInRunnable = null; + } + } + protected void onEndReordering() { mIsReordering = false; } @@ -2047,21 +2069,28 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // In that case, we don't want to do anything. if (!mReorderingStarted) return; mReorderingStarted = false; - Runnable onCompleteRunnable = new Runnable() { - @Override - public void run() { - onEndReordering(); - } - }; - zoomIn(onCompleteRunnable); // If we haven't flung-to-delete the current child, then we just animate the drag view // back into position if (!mIsFlingingToDelete) { - // Snap to the current page - snapToDestination(); + mPostReorderingPreZoomInRunnable = new Runnable() { + public void run() { + Runnable onCompleteRunnable = new Runnable() { + @Override + public void run() { + onEndReordering(); + } + }; + zoomIn(onCompleteRunnable); + }; + }; - animateChildrenToOriginalPosition(); + mPostReorderingPreZoomInRemainingAnimationCount = + NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT; + // Snap to the current page + snapToPage(indexOfChild(mDragView), 0); + // Animate the drag view back to the front position + animateDragViewToOriginalPosition(); } } |
