Pixel perfect drag animations in workspace and folders, including springloaded

Change-Id: I630c365bdc8e896a21dc17ebe8acb8d4664c77b5
This commit is contained in:
Adam Cohen
2011-07-13 11:15:27 -07:00
parent 06b9ecaf6f
commit ac8c87687b
5 changed files with 120 additions and 119 deletions
@@ -385,37 +385,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
protected void determineDraggingStart(android.view.MotionEvent ev) {
// Disable dragging by pulling an app down for now.
}
private void beginDraggingApplication(View v) {
// Make a copy of the ApplicationInfo
ApplicationInfo appInfo = new ApplicationInfo((ApplicationInfo) v.getTag());
// Compose the drag image (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
Bitmap.Config.ARGB_8888);
mCanvas.setBitmap(b);
mCanvas.save();
mCanvas.translate((v.getWidth() - icon.getIntrinsicWidth()) / 2, v.getPaddingTop());
icon.draw(mCanvas);
mCanvas.restore();
// Compose the visible rect of the drag image
Rect dragRect = null;
if (v instanceof TextView) {
int top = v.getPaddingTop();
int left = (b.getWidth() - mAppIconSize) / 2;
int right = left + mAppIconSize;
int bottom = top + mAppIconSize;
dragRect = new Rect(left, top, right, bottom);
}
// Start the drag
mLauncher.lockScreenOrientation();
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
mDragController.startDrag(v, b, this, appInfo, DragController.DRAG_ACTION_COPY, dragRect);
b.recycle();
mLauncher.getWorkspace().onDragStartedWithItem(v);
mLauncher.getWorkspace().beginDragShared(v, this);
}
private void beginDraggingWidget(View v) {
// Get the widget preview as the drag representation
ImageView image = (ImageView) v.findViewById(R.id.widget_preview);