summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2013-10-14 00:06:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-14 00:06:49 +0000
commit05da328078b71f4aa9a42552f9c2b6713010686e (patch)
tree374a4eb8209c026a2291b32edc7f932f8073bae6 /packages/Keyguard
parent1ae1373aeddbd5f3e090db8d5862a22eab0e4ed6 (diff)
parentafef5b23a1c6c42b508f3e3705cea02ad24acba7 (diff)
downloadframeworks_base-05da328078b71f4aa9a42552f9c2b6713010686e.zip
frameworks_base-05da328078b71f4aa9a42552f9c2b6713010686e.tar.gz
frameworks_base-05da328078b71f4aa9a42552f9c2b6713010686e.tar.bz2
Merge "Fix warp animation in keyguard" into klp-dev
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/PagedView.java49
1 files changed, 34 insertions, 15 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/PagedView.java b/packages/Keyguard/src/com/android/keyguard/PagedView.java
index 6cf6953..23488d4 100644
--- a/packages/Keyguard/src/com/android/keyguard/PagedView.java
+++ b/packages/Keyguard/src/com/android/keyguard/PagedView.java
@@ -44,6 +44,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
+import android.view.ViewPropertyAnimator;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -134,6 +135,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected final static int TOUCH_STATE_PREV_PAGE = 2;
protected final static int TOUCH_STATE_NEXT_PAGE = 3;
protected final static int TOUCH_STATE_REORDERING = 4;
+ protected final static int TOUCH_STATE_READY = 5; // when finger is down
protected final static float ALPHA_QUANTIZE_LEVEL = 0.0001f;
protected final static float TOUCH_SLOP_SCALE = 1.0f;
@@ -260,11 +262,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Page warping
private int mPageSwapIndex = -1; // the page we swapped out if needed
private int mPageWarpIndex = -1; // the page we intend to warp
+ private boolean mWarpPageExposed;
+ private ViewPropertyAnimator mWarpAnimation;
private boolean mIsCameraEvent;
private float mWarpPeekAmount;
- private boolean mAnimatingWarp; // true while warped page is being animated
- private boolean mFingerDown;
public interface PageSwitchListener {
void onPageSwitching(View newPage, int newPageIndex);
@@ -1128,7 +1130,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
case MotionEvent.ACTION_DOWN: {
- if (mIsCameraEvent && !mAnimatingWarp) {
+ if (mIsCameraEvent) {
animateWarpPageOnScreen("interceptTouch(): DOWN");
}
// Remember where the motion event started
@@ -1196,6 +1198,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private void setTouchState(int touchState) {
if (mTouchState != touchState) {
+ if (DEBUG_WARP) Log.v(TAG, "mTouchState changing to " + touchState);
onTouchStateChanged(touchState);
mTouchState = touchState;
}
@@ -1223,8 +1226,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mTotalMotionX = 0;
mActivePointerId = ev.getPointerId(0);
- mFingerDown = true;
-
// Determine if the down event is within the threshold to be an edge swipe
int leftEdgeBoundary = getViewportOffsetX() + mEdgeSwipeRegionSize;
int rightEdgeBoundary = getMeasuredWidth() - getViewportOffsetX() - mEdgeSwipeRegionSize;
@@ -1399,9 +1400,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (mTouchState == TOUCH_STATE_SCROLLING) {
pageBeginMoving();
+ } else {
+ setTouchState(TOUCH_STATE_READY);
}
- if (mIsCameraEvent && !mAnimatingWarp) {
+ if (mIsCameraEvent) {
animateWarpPageOnScreen("onTouch(): DOWN");
}
break;
@@ -1635,6 +1638,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
onDropToDelete();
}
} else {
+ if (DEBUG_WARP) Log.v(TAG, "calling onUnhandledTap()");
+ if (mWarpPageExposed && !isAnimatingWarpPage()) {
+ animateWarpPageOffScreen("unhandled tap", true);
+ }
onUnhandledTap(ev);
}
@@ -1670,7 +1677,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
setTouchState(TOUCH_STATE_REST);
mActivePointerId = INVALID_POINTER;
mDownEventOnEdge = false;
- mFingerDown = false;
}
protected void onUnhandledTap(MotionEvent ev) {}
@@ -2675,16 +2681,24 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mIsCameraEvent = false;
}
- AnimatorListenerAdapter mFinishWarpAnimationListener = new AnimatorListenerAdapter() {
+ AnimatorListenerAdapter mOnScreenAnimationListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mAnimatingWarp = false;
- if (!mFingerDown) {
- animateWarpPageOffScreen("animation end", true);
+ mWarpAnimation = null;
+ if (mTouchState != TOUCH_STATE_SCROLLING && mTouchState != TOUCH_STATE_READY) {
+ animateWarpPageOffScreen("onScreen end", true);
}
}
};
+ AnimatorListenerAdapter mOffScreenAnimationListener = new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mWarpAnimation = null;
+ mWarpPageExposed = true;
+ }
+ };
+
private void cancelWarpAnimation(String msg) {
if (DEBUG_WARP) Log.v(TAG, "cancelWarpAnimation(" + msg + ")");
// We're done with the animation, let the scroller take over the positioning
@@ -2694,18 +2708,23 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
scrollBy((int) Math.round(v.getTranslationX() - mWarpPeekAmount), 0);
}
+ private boolean isAnimatingWarpPage() {
+ return mWarpAnimation != null;
+ }
+
private void animateWarpPageOnScreen(String reason) {
if (DEBUG_WARP) Log.v(TAG, "animateWarpPageOnScreen(" + reason + ")");
if (isWarping()) {
+ mWarpPageExposed = true;
onPageBeginWarp();
KeyguardWidgetFrame v = (KeyguardWidgetFrame) getPageAt(mPageWarpIndex);
if (DEBUG_WARP) Log.v(TAG, "moving page on screen: Tx=" + v.getTranslationX());
DecelerateInterpolator interp = new DecelerateInterpolator(1.5f);
- v.animate().translationX(mWarpPeekAmount)
+ mWarpAnimation = v.animate();
+ mWarpAnimation.translationX(mWarpPeekAmount)
.setInterpolator(interp)
.setDuration(WARP_PEEK_ANIMATION_DURATION)
- .setListener(mFinishWarpAnimationListener);
- mAnimatingWarp = true;
+ .setListener(mOnScreenAnimationListener);
}
}
@@ -2719,7 +2738,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
v.animate().translationX(0.0f)
.setInterpolator(interp)
.setDuration(animate ? WARP_PEEK_ANIMATION_DURATION : 0)
- .setListener(null);
+ .setListener(mOffScreenAnimationListener);
} else {
if (DEBUG_WARP) Log.e(TAG, "animateWarpPageOffScreen(): not warping", new Exception());
}