From fa668cc930544e8b231c1fbf3ad496374b7aa21c Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Wed, 31 Oct 2012 16:09:21 -0700 Subject: Fix some drag behavior bugs in keyguard Integrate from proto app Make sure you can drag back up immediately without the delay of extra offset on the challenge view. There are still a few further tweaks to make here that will be dependent on another upcoming patch. Change-Id: I6af599e43d6be6da7b431dca5b87e39c157a54df --- core/res/res/layout-port/keyguard_widget_pager.xml | 2 +- core/res/res/values-land/dimens.xml | 6 ++++++ core/res/res/values-sw600dp/dimens.xml | 4 ++-- core/res/res/values-sw720dp/dimens.xml | 4 ++-- core/res/res/values/dimens.xml | 2 +- .../impl/keyguard/SlidingChallengeLayout.java | 23 ++++++++++++++-------- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/core/res/res/layout-port/keyguard_widget_pager.xml b/core/res/res/layout-port/keyguard_widget_pager.xml index 3b29db8516e6..7fd370b6bdb5 100644 --- a/core/res/res/layout-port/keyguard_widget_pager.xml +++ b/core/res/res/layout-port/keyguard_widget_pager.xml @@ -25,7 +25,7 @@ android:paddingLeft="25dp" android:paddingRight="25dp" android:paddingTop="25dp" - android:paddingBottom="64dp" + android:paddingBottom="@dimen/kg_widget_pager_bottom_padding" android:clipChildren="false" android:clipToPadding="false" androidprv:pageSpacing="10dp"> diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml index 07f62edf5521..36f26287a4fb 100644 --- a/core/res/res/values-land/dimens.xml +++ b/core/res/res/values-land/dimens.xml @@ -50,4 +50,10 @@ 0dp + + 0dp + + + 0dp + diff --git a/core/res/res/values-sw600dp/dimens.xml b/core/res/res/values-sw600dp/dimens.xml index 0d01df4e9824..52c230b16b39 100644 --- a/core/res/res/values-sw600dp/dimens.xml +++ b/core/res/res/values-sw600dp/dimens.xml @@ -98,10 +98,10 @@ 24dp - 24dp + 0dp - 16dp + 0dp diff --git a/core/res/res/values-sw720dp/dimens.xml b/core/res/res/values-sw720dp/dimens.xml index ffb4e1152a82..ccdb4be85d81 100644 --- a/core/res/res/values-sw720dp/dimens.xml +++ b/core/res/res/values-sw720dp/dimens.xml @@ -91,10 +91,10 @@ 80dp - 32dp + 0dp - 36dp + 0dp diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index c0b2b1fb4a78..4966b9733126 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -294,7 +294,7 @@ 0dp - 0dp + 64dp diff --git a/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java b/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java index 7cf995c4f3f2..2e735a05cd5f 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/SlidingChallengeLayout.java @@ -20,6 +20,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; @@ -247,12 +248,12 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout mMinVelocity = vc.getScaledMinimumFlingVelocity(); mMaxVelocity = vc.getScaledMaximumFlingVelocity(); - mDragHandleEdgeSlop = getResources().getDimensionPixelSize( - R.dimen.kg_edge_swipe_region_size); + final Resources res = getResources(); + mDragHandleEdgeSlop = res.getDimensionPixelSize(R.dimen.kg_edge_swipe_region_size); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); - final float density = getResources().getDisplayMetrics().density; + final float density = res.getDisplayMetrics().density; // top half of the lock icon, plus another 25% to be sure mDragHandleClosedAbove = (int) (DRAG_HANDLE_CLOSED_ABOVE * density + 0.5f); @@ -261,7 +262,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout mDragHandleOpenBelow = (int) (DRAG_HANDLE_OPEN_BELOW * density + 0.5f); // how much space to account for in the handle when closed - mChallengeBottomBound = mDragHandleClosedBelow; + mChallengeBottomBound = res.getDimensionPixelSize(R.dimen.kg_widget_pager_bottom_padding); setWillNotDraw(false); } @@ -535,6 +536,11 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout return expanded && mHasGlowpad ? 0 : mDragHandleEdgeSlop; } + private float getChallengeAlpha() { + float x = mChallengeOffset - 1; + return x * x * x + 1.f; + } + @Override public void requestDisallowInterceptTouchEvent(boolean allowIntercept) { // We'll intercept whoever we feel like! ...as long as it isn't a challenge view. @@ -570,7 +576,8 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout if (!mIsBouncing && (isInDragHandle(x, y) || crossedDragHandle(x, y, mGestureStartY) || - (isInChallengeView(x, y) && mScrollState == SCROLL_STATE_SETTLING)) && + (isInChallengeView(x, y) && + (mScrollState == SCROLL_STATE_SETTLING || !mChallengeShowing))) && mActivePointerId == INVALID_POINTER) { mActivePointerId = ev.getPointerId(i); mGestureStartX = x; @@ -860,7 +867,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout // we never want less than the handle size showing at the bottom. final int bottom = layoutBottom + (int) ((childHeight - mChallengeBottomBound) * (1 - mChallengeOffset)); - child.setAlpha(mChallengeOffset / 2 + 0.5f); + child.setAlpha(getChallengeAlpha()); child.layout(left, bottom - childHeight, left + childWidth, bottom); } else { // Non-challenge views lay out from the upper left, layered. @@ -938,7 +945,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout } if (mDragIconDrawable != null) { - final int closedTop = getLayoutBottom() - mChallengeBottomBound; + final int closedTop = getLayoutBottom() - mDragHandleClosedBelow; final int iconWidth = mDragIconDrawable.getIntrinsicWidth(); final int iconHeight = mDragIconDrawable.getIntrinsicHeight(); final int iconLeft = (challengeLeft + challengeRight - iconWidth) / 2; @@ -996,7 +1003,7 @@ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout mChallengeView.layout(mChallengeView.getLeft(), bottom - mChallengeView.getHeight(), mChallengeView.getRight(), bottom); - mChallengeView.setAlpha(offset / 2 + 0.5f); + mChallengeView.setAlpha(getChallengeAlpha()); if (mScrollListener != null) { mScrollListener.onScrollPositionChanged(offset, mChallengeView.getTop()); } -- cgit v1.2.3-59-g8ed1b