summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-03-28 17:33:39 -0700
committerAdam Cohen <adamcohen@google.com>2011-03-28 17:37:35 -0700
commitd5e42733799817d11d739b0a882da8dda721126d (patch)
treefbbb3caba47cd76d27f6adba810b460f3cabab5c
parent8878a32f26b7e6c287d970950526cd0e6eabb21d (diff)
downloadandroid_packages_apps_Trebuchet-d5e42733799817d11d739b0a882da8dda721126d.tar.gz
android_packages_apps_Trebuchet-d5e42733799817d11d739b0a882da8dda721126d.tar.bz2
android_packages_apps_Trebuchet-d5e42733799817d11d739b0a882da8dda721126d.zip
Fixing drop animation from AllApps on phone (bug 4174466)
Change-Id: I90d4c7e0cef6089d161c2ced7687e9edb3a3953a
-rw-r--r--src/com/android/launcher2/CellLayoutChildren.java28
-rw-r--r--src/com/android/launcher2/Workspace.java19
2 files changed, 31 insertions, 16 deletions
diff --git a/src/com/android/launcher2/CellLayoutChildren.java b/src/com/android/launcher2/CellLayoutChildren.java
index 11b2f9e70..e4e6fb197 100644
--- a/src/com/android/launcher2/CellLayoutChildren.java
+++ b/src/com/android/launcher2/CellLayoutChildren.java
@@ -75,27 +75,31 @@ public class CellLayoutChildren extends ViewGroup {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int cellWidth = mCellWidth;
- final int cellHeight = mCellHeight;
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
-
- lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap,
- mLeftPadding, mTopPadding);
-
- int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
- int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height,
- MeasureSpec.EXACTLY);
-
- child.measure(childWidthMeasureSpec, childheightMeasureSpec);
+ measureChild(child);
}
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSpecSize, heightSpecSize);
}
+ public void measureChild(View child) {
+ final int cellWidth = mCellWidth;
+ final int cellHeight = mCellHeight;
+ CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
+
+ lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap,
+ mLeftPadding, mTopPadding);
+
+ int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
+ int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height,
+ MeasureSpec.EXACTLY);
+
+ child.measure(childWidthMeasureSpec, childheightMeasureSpec);
+ }
+
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int count = getChildCount();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 15c164ad7..ce794bd70 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2173,8 +2173,8 @@ public class Workspace extends SmoothPagedView
final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
// Based on the position of the drag view, find the top left of the original view
- int viewX = dragViewX + (dragView.getWidth() - child.getWidth()) / 2;
- int viewY = dragViewY + (dragView.getHeight() - child.getHeight()) / 2;
+ int viewX = dragViewX + (dragView.getWidth() - child.getMeasuredWidth()) / 2;
+ int viewY = dragViewY + (dragView.getHeight() - child.getMeasuredHeight()) / 2;
viewX += getResources().getDimensionPixelSize(R.dimen.dragViewOffsetX);
viewY += getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
@@ -2313,7 +2313,7 @@ public class Workspace extends SmoothPagedView
((ItemInfo) dragInfo).dropPos = touchXY;
return;
}
- onDropExternal(touchXY, dragInfo, mDragTargetLayout, false);
+ onDropExternal(touchXY, dragInfo, mDragTargetLayout, false, dragView, originX, originY);
} else if (mDragInfo != null) {
final View cell = mDragInfo.cell;
CellLayout dropTargetLayout = mDragTargetLayout;
@@ -2866,6 +2866,11 @@ public class Workspace extends SmoothPagedView
return false;
}
+ private void onDropExternal(int[] touchXY, Object dragInfo,
+ CellLayout cellLayout, boolean insertAtFirst) {
+ onDropExternal(touchXY, dragInfo, cellLayout, insertAtFirst, null, 0, 0);
+ }
+
/**
* Drop an item that didn't originate on one of the workspace screens.
* It may have come from Launcher (e.g. from all apps or customize), or it may have
@@ -2875,7 +2880,8 @@ public class Workspace extends SmoothPagedView
* to add an item to one of the workspace screens.
*/
private void onDropExternal(int[] touchXY, Object dragInfo,
- CellLayout cellLayout, boolean insertAtFirst) {
+ CellLayout cellLayout, boolean insertAtFirst, DragView dragView,
+ int dragViewX, int dragViewY) {
int screen = indexOfChild(cellLayout);
if (dragInfo instanceof PendingAddItemInfo) {
PendingAddItemInfo info = (PendingAddItemInfo) dragInfo;
@@ -2931,6 +2937,11 @@ public class Workspace extends SmoothPagedView
cellLayout.onDropChild(view, animateDrop);
cellLayout.animateDrop();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
+ cellLayout.getChildrenLayout().measureChild(view);
+
+ if (dragView != null) {
+ setPositionForDropAnimation(dragView, dragViewX, dragViewY, cellLayout, view);
+ }
LauncherModel.addOrMoveItemInDatabase(mLauncher, info,
LauncherSettings.Favorites.CONTAINER_DESKTOP, screen,