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
This commit is contained in:
Winson Chung
2012-11-07 17:17:33 -08:00
parent de974f6f20
commit c065a5d727
8 changed files with 31 additions and 8 deletions

View File

@@ -37,7 +37,8 @@
android:id="@+id/keyguard_widget_pager_delete_target"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal" />
android:layout_gravity="top|center_horizontal"
androidprv:layout_childType="pageDeleteDropTarget" />
<include layout="@layout/keyguard_widget_pager"
android:id="@+id/app_widget_container"

View File

@@ -35,7 +35,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
androidprv:layout_childType="pageDeleteDropTarget">
<include layout="@layout/keyguard_widget_remove_drop_target"
android:id="@+id/keyguard_widget_pager_delete_target"
android:layout_width="wrap_content"

View File

@@ -38,7 +38,8 @@
android:id="@+id/keyguard_widget_pager_delete_target"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal" />
android:layout_gravity="top|center_horizontal"
androidprv:layout_childType="pageDeleteDropTarget" />
<include layout="@layout/keyguard_widget_pager"
android:id="@+id/app_widget_container"

View File

@@ -19,9 +19,9 @@
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:padding="20dp"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:padding="30dp"
android:paddingLeft="60dp"
android:paddingRight="60dp"
android:drawableLeft="@drawable/kg_widget_delete_drop_target"
android:drawablePadding="4dp"
android:text="@string/kg_reordering_delete_drop_target_text"

View File

@@ -5815,6 +5815,8 @@
<!-- This is a handle that is used for expanding the
security challenge container when it is collapsed. -->
<enum name="expandChallengeHandle" value="6" />
<!-- Delete drop target. This will be the drop target to delete pages. -->
<enum name="pageDeleteDropTarget" value="7" />
</attr>
<declare-styleable name="SlidingChallengeLayout_Layout">

View File

@@ -507,14 +507,17 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
return false;
}
/**
* Returns the bounded set of pages that are re-orderable. The range is fully inclusive.
*/
@Override
void boundByReorderablePages(boolean isReordering, int[] range) {
if (isReordering) {
// Remove non-widget pages from the range
while (range[1] > range[0] && !isWidgetPage(range[1])) {
while (range[1] >= range[0] && !isWidgetPage(range[1])) {
range[1]--;
}
while (range[0] < range[1] && !isWidgetPage(range[0])) {
while (range[0] <= range[1] && !isWidgetPage(range[0])) {
range[0]++;
}
}

View File

@@ -48,6 +48,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
private OnBouncerStateChangedListener mBouncerListener;
private final Rect mTempRect = new Rect();
private final Rect mZeroPadding = new Rect();
private final DisplayMetrics mDisplayMetrics;
@@ -187,6 +188,8 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
// on the window. We want to avoid resizing widgets when possible as it can
// be ugly/expensive. This lets us simply clip them instead.
return virtualHeight - heightUsed;
} else if (lp.childType == LayoutParams.CHILD_TYPE_PAGE_DELETE_DROP_TARGET) {
return height;
}
return Math.min(virtualHeight - heightUsed, height);
}
@@ -330,6 +333,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
// We did the user switcher above if we have one.
if (child == mUserSwitcherView || child.getVisibility() == GONE) continue;
@@ -337,6 +341,9 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
if (child == mScrimView) {
child.layout(0, 0, width, height);
continue;
} else if (lp.childType == LayoutParams.CHILD_TYPE_PAGE_DELETE_DROP_TARGET) {
layoutWithGravity(width, height, child, mZeroPadding, false);
continue;
}
layoutWithGravity(width, height, child, padding, false);
@@ -467,6 +474,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
public static final int CHILD_TYPE_CHALLENGE = 2;
public static final int CHILD_TYPE_USER_SWITCHER = 3;
public static final int CHILD_TYPE_SCRIM = 4;
public static final int CHILD_TYPE_PAGE_DELETE_DROP_TARGET = 7;
public int gravity = Gravity.NO_GRAVITY;

View File

@@ -233,6 +233,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private Matrix mTmpInvMatrix = new Matrix();
private float[] mTmpPoint = new float[2];
private Rect mTmpRect = new Rect();
private Rect mAltTmpRect = new Rect();
// Fling to delete
private int FLING_TO_DELETE_FADE_OUT_DURATION = 350;
@@ -2455,7 +2456,13 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
/* Drag to delete */
private boolean isHoveringOverDeleteDropTarget(int x, int y) {
if (mDeleteDropTarget != null) {
mAltTmpRect.set(0, 0, 0, 0);
View parent = (View) mDeleteDropTarget.getParent();
if (parent != null) {
parent.getGlobalVisibleRect(mAltTmpRect);
}
mDeleteDropTarget.getGlobalVisibleRect(mTmpRect);
mTmpRect.offset(-mAltTmpRect.left, -mAltTmpRect.top);
return mTmpRect.contains(x, y);
}
return false;