Implement spring-loading of folders when dragging over.

Bug: 8912132
Change-Id: Id81889a133e56461df2e20599c4b40020818ba18
This commit is contained in:
Jorim Jaggi
2014-01-16 15:30:42 -08:00
parent f180497bc3
commit 55bd9725d5
5 changed files with 148 additions and 62 deletions

View File

@@ -65,8 +65,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
private boolean mHoverPointClosesFolder = false;
private Rect mHitRect = new Rect();
private int mWorkspaceIndex = -1;
private int mQsbIndex = -1;
public static final int ANIMATION_END_DISAPPEAR = 0;
public static final int ANIMATION_END_FADE_OUT = 1;
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
@@ -75,6 +73,8 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
private final Rect mInsets = new Rect();
private int mDragViewIndex;
/**
* Used to create a new DragLayer from XML.
*
@@ -771,31 +771,26 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
}
private void updateChildIndices() {
if (mLauncher != null) {
mWorkspaceIndex = indexOfChild(mLauncher.getWorkspace());
mQsbIndex = indexOfChild(mLauncher.getSearchBar());
mDragViewIndex = -1;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
if (getChildAt(i) instanceof DragView) {
mDragViewIndex = i;
}
}
}
@Override
protected int getChildDrawingOrder(int childCount, int i) {
// TODO: We have turned off this custom drawing order because it now effects touch
// dispatch order. We need to sort that issue out and then decide how to go about this.
if (true || LauncherAppState.isScreenLandscape(getContext()) ||
mWorkspaceIndex == -1 || mQsbIndex == -1 ||
mLauncher.getWorkspace().isDrawingBackgroundGradient()) {
if (mDragViewIndex == -1) {
return i;
} else if (i == mDragViewIndex) {
return getChildCount()-1;
} else if (i < mDragViewIndex) {
return i;
}
// This ensures that the workspace is drawn above the hotseat and qsb,
// except when the workspace is drawing a background gradient, in which
// case we want the workspace to stay behind these elements.
if (i == mQsbIndex) {
return mWorkspaceIndex;
} else if (i == mWorkspaceIndex) {
return mQsbIndex;
} else {
return i;
// i > mDragViewIndex
return i-1;
}
}