Skip to content

Commit 077105b

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Fix some drag behavior bugs in keyguard" into jb-mr1-lockscreen-dev
2 parents 4f721f1 + fa668cc commit 077105b

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

core/res/res/layout-port/keyguard_widget_pager.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
android:paddingLeft="25dp"
2626
android:paddingRight="25dp"
2727
android:paddingTop="25dp"
28-
android:paddingBottom="64dp"
28+
android:paddingBottom="@dimen/kg_widget_pager_bottom_padding"
2929
android:clipChildren="false"
3030
android:clipToPadding="false"
3131
androidprv:pageSpacing="10dp">

core/res/res/values-land/dimens.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,10 @@
5050
<!-- Space reserved at the bottom of secure views (pin/pattern/password/SIM pin/SIM puk) -->
5151
<dimen name="kg_secure_padding_height">0dp</dimen>
5252

53+
<!-- Top padding for the widget pager -->
54+
<dimen name="kg_widget_pager_top_padding">0dp</dimen>
55+
56+
<!-- Bottom padding for the widget pager -->
57+
<dimen name="kg_widget_pager_bottom_padding">0dp</dimen>
58+
5359
</resources>

core/res/res/values-sw600dp/dimens.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@
9898
<dimen name="kg_widget_pager_horizontal_padding">24dp</dimen>
9999

100100
<!-- Top padding for the widget pager -->
101-
<dimen name="kg_widget_pager_top_padding">24dp</dimen>
101+
<dimen name="kg_widget_pager_top_padding">0dp</dimen>
102102

103103
<!-- Bottom padding for the widget pager -->
104-
<dimen name="kg_widget_pager_bottom_padding">16dp</dimen>
104+
<dimen name="kg_widget_pager_bottom_padding">0dp</dimen>
105105

106106
<!-- Top margin for the runway lights. We add a negative margin in large
107107
devices to account for the widget pager padding -->

core/res/res/values-sw720dp/dimens.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@
9191
<dimen name="kg_widget_pager_horizontal_padding">80dp</dimen>
9292

9393
<!-- Top padding for the widget pager -->
94-
<dimen name="kg_widget_pager_top_padding">32dp</dimen>
94+
<dimen name="kg_widget_pager_top_padding">0dp</dimen>
9595

9696
<!-- Bottom padding for the widget pager -->
97-
<dimen name="kg_widget_pager_bottom_padding">36dp</dimen>
97+
<dimen name="kg_widget_pager_bottom_padding">0dp</dimen>
9898

9999
<!-- Top margin for the runway lights. We add a negative margin in large
100100
devices to account for the widget pager padding -->

core/res/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
<dimen name="kg_widget_pager_top_padding">0dp</dimen>
295295

296296
<!-- Bottom padding for the widget pager -->
297-
<dimen name="kg_widget_pager_bottom_padding">0dp</dimen>
297+
<dimen name="kg_widget_pager_bottom_padding">64dp</dimen>
298298

299299
<!-- Top margin for the runway lights. We add a negative margin in large
300300
devices to account for the widget pager padding -->

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import android.animation.AnimatorListenerAdapter;
2121
import android.animation.ObjectAnimator;
2222
import android.content.Context;
23+
import android.content.res.Resources;
2324
import android.content.res.TypedArray;
2425
import android.graphics.Canvas;
2526
import android.graphics.Paint;
@@ -247,12 +248,12 @@ public SlidingChallengeLayout(Context context, AttributeSet attrs, int defStyle)
247248
mMinVelocity = vc.getScaledMinimumFlingVelocity();
248249
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
249250

250-
mDragHandleEdgeSlop = getResources().getDimensionPixelSize(
251-
R.dimen.kg_edge_swipe_region_size);
251+
final Resources res = getResources();
252+
mDragHandleEdgeSlop = res.getDimensionPixelSize(R.dimen.kg_edge_swipe_region_size);
252253

253254
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
254255

255-
final float density = getResources().getDisplayMetrics().density;
256+
final float density = res.getDisplayMetrics().density;
256257

257258
// top half of the lock icon, plus another 25% to be sure
258259
mDragHandleClosedAbove = (int) (DRAG_HANDLE_CLOSED_ABOVE * density + 0.5f);
@@ -261,7 +262,7 @@ public SlidingChallengeLayout(Context context, AttributeSet attrs, int defStyle)
261262
mDragHandleOpenBelow = (int) (DRAG_HANDLE_OPEN_BELOW * density + 0.5f);
262263

263264
// how much space to account for in the handle when closed
264-
mChallengeBottomBound = mDragHandleClosedBelow;
265+
mChallengeBottomBound = res.getDimensionPixelSize(R.dimen.kg_widget_pager_bottom_padding);
265266

266267
setWillNotDraw(false);
267268
}
@@ -535,6 +536,11 @@ private int getChallengeMargin(boolean expanded) {
535536
return expanded && mHasGlowpad ? 0 : mDragHandleEdgeSlop;
536537
}
537538

539+
private float getChallengeAlpha() {
540+
float x = mChallengeOffset - 1;
541+
return x * x * x + 1.f;
542+
}
543+
538544
@Override
539545
public void requestDisallowInterceptTouchEvent(boolean allowIntercept) {
540546
// We'll intercept whoever we feel like! ...as long as it isn't a challenge view.
@@ -570,7 +576,8 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
570576

571577
if (!mIsBouncing &&
572578
(isInDragHandle(x, y) || crossedDragHandle(x, y, mGestureStartY) ||
573-
(isInChallengeView(x, y) && mScrollState == SCROLL_STATE_SETTLING)) &&
579+
(isInChallengeView(x, y) &&
580+
(mScrollState == SCROLL_STATE_SETTLING || !mChallengeShowing))) &&
574581
mActivePointerId == INVALID_POINTER) {
575582
mActivePointerId = ev.getPointerId(i);
576583
mGestureStartX = x;
@@ -860,7 +867,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
860867
// we never want less than the handle size showing at the bottom.
861868
final int bottom = layoutBottom + (int) ((childHeight - mChallengeBottomBound)
862869
* (1 - mChallengeOffset));
863-
child.setAlpha(mChallengeOffset / 2 + 0.5f);
870+
child.setAlpha(getChallengeAlpha());
864871
child.layout(left, bottom - childHeight, left + childWidth, bottom);
865872
} else {
866873
// Non-challenge views lay out from the upper left, layered.
@@ -938,7 +945,7 @@ public void draw(Canvas c) {
938945
}
939946

940947
if (mDragIconDrawable != null) {
941-
final int closedTop = getLayoutBottom() - mChallengeBottomBound;
948+
final int closedTop = getLayoutBottom() - mDragHandleClosedBelow;
942949
final int iconWidth = mDragIconDrawable.getIntrinsicWidth();
943950
final int iconHeight = mDragIconDrawable.getIntrinsicHeight();
944951
final int iconLeft = (challengeLeft + challengeRight - iconWidth) / 2;
@@ -996,7 +1003,7 @@ private boolean moveChallengeTo(int bottom) {
9961003
mChallengeView.layout(mChallengeView.getLeft(),
9971004
bottom - mChallengeView.getHeight(), mChallengeView.getRight(), bottom);
9981005

999-
mChallengeView.setAlpha(offset / 2 + 0.5f);
1006+
mChallengeView.setAlpha(getChallengeAlpha());
10001007
if (mScrollListener != null) {
10011008
mScrollListener.onScrollPositionChanged(offset, mChallengeView.getTop());
10021009
}

0 commit comments

Comments
 (0)