Skip to content

Commit c065a5d

Browse files
author
Winson Chung
committed
Fixing issue where you can reorder/delete a non-widget page. (Bug 7493984)
- Laying out the drop target without padding from the multiuser picker Change-Id: Icd3528a13f84a789341a841645bfde4e51fd1747
1 parent de974f6 commit c065a5d

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
@@ -5815,6 +5815,8 @@
58155815
<!-- This is a handle that is used for expanding the
58165816
security challenge container when it is collapsed. -->
58175817
<enum name="expandChallengeHandle" value="6" />
5818+
<!-- Delete drop target. This will be the drop target to delete pages. -->
5819+
<enum name="pageDeleteDropTarget" value="7" />
58185820
</attr>
58195821

58205822
<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
@@ -507,14 +507,17 @@ public boolean isWidgetPage(int pageIndex) {
507507
return false;
508508
}
509509

510+
/**
511+
* Returns the bounded set of pages that are re-orderable. The range is fully inclusive.
512+
*/
510513
@Override
511514
void boundByReorderablePages(boolean isReordering, int[] range) {
512515
if (isReordering) {
513516
// Remove non-widget pages from the range
514-
while (range[1] > range[0] && !isWidgetPage(range[1])) {
517+
while (range[1] >= range[0] && !isWidgetPage(range[1])) {
515518
range[1]--;
516519
}
517-
while (range[0] < range[1] && !isWidgetPage(range[0])) {
520+
while (range[0] <= range[1] && !isWidgetPage(range[0])) {
518521
range[0]++;
519522
}
520523
}

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;
@@ -2455,7 +2456,13 @@ public void onAnimationEnd(Animator animation) {
24552456
/* Drag to delete */
24562457
private boolean isHoveringOverDeleteDropTarget(int x, int y) {
24572458
if (mDeleteDropTarget != null) {
2459+
mAltTmpRect.set(0, 0, 0, 0);
2460+
View parent = (View) mDeleteDropTarget.getParent();
2461+
if (parent != null) {
2462+
parent.getGlobalVisibleRect(mAltTmpRect);
2463+
}
24582464
mDeleteDropTarget.getGlobalVisibleRect(mTmpRect);
2465+
mTmpRect.offset(-mAltTmpRect.left, -mAltTmpRect.top);
24592466
return mTmpRect.contains(x, y);
24602467
}
24612468
return false;

0 commit comments

Comments
 (0)