Skip to content

Commit 4181e8a

Browse files
Winson ChungAndroid (Google) Code Review
authored andcommitted
Merge "Fixing issue where you can reorder/delete a non-widget page. (Bug 7493984)" into jb-mr1-lockscreen-dev
2 parents 85c4281 + c065a5d commit 4181e8a

File tree

8 files changed

+31
-8
lines changed

8 files changed

+31
-8
lines changed

core/res/res/layout-land/keyguard_host_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
android:id="@+id/keyguard_widget_pager_delete_target"
3838
android:layout_width="wrap_content"
3939
android:layout_height="wrap_content"
40-
android:layout_gravity="top|center_horizontal" />
40+
android:layout_gravity="top|center_horizontal"
41+
androidprv:layout_childType="pageDeleteDropTarget" />
4142

4243
<include layout="@layout/keyguard_widget_pager"
4344
android:id="@+id/app_widget_container"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
<FrameLayout
3737
android:layout_width="match_parent"
38-
android:layout_height="wrap_content">
38+
android:layout_height="wrap_content"
39+
androidprv:layout_childType="pageDeleteDropTarget">
3940
<include layout="@layout/keyguard_widget_remove_drop_target"
4041
android:id="@+id/keyguard_widget_pager_delete_target"
4142
android:layout_width="wrap_content"

core/res/res/layout-sw600dp-port/keyguard_host_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
android:id="@+id/keyguard_widget_pager_delete_target"
3939
android:layout_width="wrap_content"
4040
android:layout_height="wrap_content"
41-
android:layout_gravity="top|center_horizontal" />
41+
android:layout_gravity="top|center_horizontal"
42+
androidprv:layout_childType="pageDeleteDropTarget" />
4243

4344
<include layout="@layout/keyguard_widget_pager"
4445
android:id="@+id/app_widget_container"

core/res/res/layout/keyguard_widget_remove_drop_target.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
<TextView
2020
xmlns:android="http://schemas.android.com/apk/res/android"
2121
android:gravity="center"
22-
android:padding="20dp"
23-
android:paddingLeft="40dp"
24-
android:paddingRight="40dp"
22+
android:padding="30dp"
23+
android:paddingLeft="60dp"
24+
android:paddingRight="60dp"
2525
android:drawableLeft="@drawable/kg_widget_delete_drop_target"
2626
android:drawablePadding="4dp"
2727
android:text="@string/kg_reordering_delete_drop_target_text"

core/res/res/values/attrs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5820,6 +5820,8 @@
58205820
<!-- This is a handle that is used for expanding the
58215821
security challenge container when it is collapsed. -->
58225822
<enum name="expandChallengeHandle" value="6" />
5823+
<!-- Delete drop target. This will be the drop target to delete pages. -->
5824+
<enum name="pageDeleteDropTarget" value="7" />
58235825
</attr>
58245826

58255827
<declare-styleable name="SlidingChallengeLayout_Layout">

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,17 @@ public boolean isWidgetPage(int pageIndex) {
511511
return false;
512512
}
513513

514+
/**
515+
* Returns the bounded set of pages that are re-orderable. The range is fully inclusive.
516+
*/
514517
@Override
515518
void boundByReorderablePages(boolean isReordering, int[] range) {
516519
if (isReordering) {
517520
// Remove non-widget pages from the range
518-
while (range[1] > range[0] && !isWidgetPage(range[1])) {
521+
while (range[1] >= range[0] && !isWidgetPage(range[1])) {
519522
range[1]--;
520523
}
521-
while (range[0] < range[1] && !isWidgetPage(range[0])) {
524+
while (range[0] <= range[1] && !isWidgetPage(range[0])) {
522525
range[0]++;
523526
}
524527
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
4848
private OnBouncerStateChangedListener mBouncerListener;
4949

5050
private final Rect mTempRect = new Rect();
51+
private final Rect mZeroPadding = new Rect();
5152

5253
private final DisplayMetrics mDisplayMetrics;
5354

@@ -187,6 +188,8 @@ private int getVirtualHeight(LayoutParams lp, int height, int heightUsed) {
187188
// on the window. We want to avoid resizing widgets when possible as it can
188189
// be ugly/expensive. This lets us simply clip them instead.
189190
return virtualHeight - heightUsed;
191+
} else if (lp.childType == LayoutParams.CHILD_TYPE_PAGE_DELETE_DROP_TARGET) {
192+
return height;
190193
}
191194
return Math.min(virtualHeight - heightUsed, height);
192195
}
@@ -330,13 +333,17 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
330333
final int count = getChildCount();
331334
for (int i = 0; i < count; i++) {
332335
final View child = getChildAt(i);
336+
LayoutParams lp = (LayoutParams) child.getLayoutParams();
333337

334338
// We did the user switcher above if we have one.
335339
if (child == mUserSwitcherView || child.getVisibility() == GONE) continue;
336340

337341
if (child == mScrimView) {
338342
child.layout(0, 0, width, height);
339343
continue;
344+
} else if (lp.childType == LayoutParams.CHILD_TYPE_PAGE_DELETE_DROP_TARGET) {
345+
layoutWithGravity(width, height, child, mZeroPadding, false);
346+
continue;
340347
}
341348

342349
layoutWithGravity(width, height, child, padding, false);
@@ -467,6 +474,7 @@ public static class LayoutParams extends MarginLayoutParams {
467474
public static final int CHILD_TYPE_CHALLENGE = 2;
468475
public static final int CHILD_TYPE_USER_SWITCHER = 3;
469476
public static final int CHILD_TYPE_SCRIM = 4;
477+
public static final int CHILD_TYPE_PAGE_DELETE_DROP_TARGET = 7;
470478

471479
public int gravity = Gravity.NO_GRAVITY;
472480

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
233233
private Matrix mTmpInvMatrix = new Matrix();
234234
private float[] mTmpPoint = new float[2];
235235
private Rect mTmpRect = new Rect();
236+
private Rect mAltTmpRect = new Rect();
236237

237238
// Fling to delete
238239
private int FLING_TO_DELETE_FADE_OUT_DURATION = 350;
@@ -2451,7 +2452,13 @@ public void onAnimationEnd(Animator animation) {
24512452
/* Drag to delete */
24522453
private boolean isHoveringOverDeleteDropTarget(int x, int y) {
24532454
if (mDeleteDropTarget != null) {
2455+
mAltTmpRect.set(0, 0, 0, 0);
2456+
View parent = (View) mDeleteDropTarget.getParent();
2457+
if (parent != null) {
2458+
parent.getGlobalVisibleRect(mAltTmpRect);
2459+
}
24542460
mDeleteDropTarget.getGlobalVisibleRect(mTmpRect);
2461+
mTmpRect.offset(-mAltTmpRect.left, -mAltTmpRect.top);
24552462
return mTmpRect.contains(x, y);
24562463
}
24572464
return false;

0 commit comments

Comments
 (0)