Skip to content

Commit 7bf93cf

Browse files
Winson ChungAndroid (Google) Code Review
authored andcommitted
Merge "Deferring zoom out animation until after snapToPage and animateDragViewToOriginalPosition." into jb-mr1-lockscreen-dev
2 parents 750d5e1 + 9dc9923 commit 7bf93cf

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public void setChallengeLayout(ChallengeLayout layout) {
4949
mChallengeLayout = layout;
5050
}
5151

52+
public boolean isChallengeShowing() {
53+
if (mChallengeLayout != null) {
54+
return mChallengeLayout.isChallengeShowing();
55+
}
56+
return false;
57+
}
58+
5259
public void setSecurityViewContainer(KeyguardSecurityView container) {
5360
mKeyguardSecurityContainer = container;
5461
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ public float getChildrenOutlineAlpha() {
519519

520520
@Override
521521
public boolean onLongClick(View v) {
522-
if (startReordering()) {
522+
// Disallow long pressing to reorder if the challenge is showing
523+
if (!mViewStateManager.isChallengeShowing() && startReordering()) {
523524
return true;
524525
}
525526
return false;

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

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
201201
// We use the min scale to determine how much to expand the actually PagedView measured
202202
// dimensions such that when we are zoomed out, the view is not clipped
203203
private int REORDERING_DROP_REPOSITION_DURATION = 200;
204-
protected int REORDERING_REORDER_REPOSITION_DURATION = 350;
204+
protected int REORDERING_REORDER_REPOSITION_DURATION = 300;
205205
protected int REORDERING_ZOOM_IN_OUT_DURATION = 250;
206-
private int REORDERING_SIDE_PAGE_HOVER_TIMEOUT = 500;
206+
private int REORDERING_SIDE_PAGE_HOVER_TIMEOUT = 300;
207207
private float REORDERING_SIDE_PAGE_BUFFER_PERCENTAGE = 0.1f;
208208
private float mMinScale = 1f;
209209
protected View mDragView;
@@ -215,6 +215,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
215215
// This variable's scope is for the duration of startReordering() and after the zoomIn()
216216
// animation after endReordering()
217217
private boolean mIsReordering;
218+
// The runnable that settles the page after snapToPage and animateDragViewToOriginalPosition
219+
private int NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT = 2;
220+
private int mPostReorderingPreZoomInRemainingAnimationCount;
221+
private Runnable mPostReorderingPreZoomInRunnable;
218222

219223
// Edge swiping
220224
private boolean mOnlyAllowEdgeSwipes = false;
@@ -536,6 +540,8 @@ protected boolean computeScrollHelper() {
536540
pageEndMoving();
537541
}
538542

543+
onPostReorderingAnimationCompleted();
544+
539545
// Notify the user when the page changes
540546
AccessibilityManager accessibilityManager = (AccessibilityManager)
541547
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
@@ -1971,13 +1977,19 @@ private void updateScrollingIndicatorPosition() {
19711977
}
19721978

19731979
// Animate the drag view back to the original position
1974-
void animateChildrenToOriginalPosition() {
1980+
void animateDragViewToOriginalPosition() {
19751981
if (mDragView != null) {
19761982
AnimatorSet anim = new AnimatorSet();
19771983
anim.setDuration(REORDERING_DROP_REPOSITION_DURATION);
19781984
anim.playTogether(
19791985
ObjectAnimator.ofFloat(mDragView, "translationX", 0f),
19801986
ObjectAnimator.ofFloat(mDragView, "translationY", 0f));
1987+
anim.addListener(new AnimatorListenerAdapter() {
1988+
@Override
1989+
public void onAnimationEnd(Animator animation) {
1990+
onPostReorderingAnimationCompleted();
1991+
}
1992+
});
19811993
anim.start();
19821994
}
19831995
}
@@ -2010,6 +2022,16 @@ protected void onStartReordering() {
20102022
invalidate();
20112023
}
20122024

2025+
private void onPostReorderingAnimationCompleted() {
2026+
// Trigger the callback when reordering has settled
2027+
--mPostReorderingPreZoomInRemainingAnimationCount;
2028+
if (mPostReorderingPreZoomInRunnable != null &&
2029+
mPostReorderingPreZoomInRemainingAnimationCount == 0) {
2030+
mPostReorderingPreZoomInRunnable.run();
2031+
mPostReorderingPreZoomInRunnable = null;
2032+
}
2033+
}
2034+
20132035
protected void onEndReordering() {
20142036
mIsReordering = false;
20152037
}
@@ -2047,21 +2069,28 @@ void endReordering() {
20472069
// In that case, we don't want to do anything.
20482070
if (!mReorderingStarted) return;
20492071
mReorderingStarted = false;
2050-
Runnable onCompleteRunnable = new Runnable() {
2051-
@Override
2052-
public void run() {
2053-
onEndReordering();
2054-
}
2055-
};
2056-
zoomIn(onCompleteRunnable);
20572072

20582073
// If we haven't flung-to-delete the current child, then we just animate the drag view
20592074
// back into position
20602075
if (!mIsFlingingToDelete) {
2061-
// Snap to the current page
2062-
snapToDestination();
2076+
mPostReorderingPreZoomInRunnable = new Runnable() {
2077+
public void run() {
2078+
Runnable onCompleteRunnable = new Runnable() {
2079+
@Override
2080+
public void run() {
2081+
onEndReordering();
2082+
}
2083+
};
2084+
zoomIn(onCompleteRunnable);
2085+
};
2086+
};
20632087

2064-
animateChildrenToOriginalPosition();
2088+
mPostReorderingPreZoomInRemainingAnimationCount =
2089+
NUM_ANIMATIONS_RUNNING_BEFORE_ZOOM_OUT;
2090+
// Snap to the current page
2091+
snapToPage(indexOfChild(mDragView), 0);
2092+
// Animate the drag view back to the front position
2093+
animateDragViewToOriginalPosition();
20652094
}
20662095
}
20672096

0 commit comments

Comments
 (0)