Adding drag outlines for dragging out of folders

Change-Id: I264f66af5f03035bac17ff00eacc1a1da3d027a4
This commit is contained in:
Adam Cohen 2011-04-15 17:50:36 -07:00
parent 10b1737910
commit 6639687cd6
4 changed files with 39 additions and 25 deletions

View File

@ -16,7 +16,7 @@
package com.android.launcher2;
import com.android.launcher.R;
import java.util.Arrays;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@ -39,7 +39,6 @@ import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
@ -48,7 +47,7 @@ import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LayoutAnimationController;
import java.util.Arrays;
import com.android.launcher.R;
public class CellLayout extends ViewGroup {
static final String TAG = "CellLayout";
@ -983,6 +982,10 @@ public class CellLayout extends ViewGroup {
// outside the bounds of the view.
left += (v.getWidth() - dragOutline.getWidth()) / 2;
top += (v.getHeight() - dragOutline.getHeight()) / 2;
} else {
// Center the drag outline in the cell
left += (mCellWidth - dragOutline.getWidth()) / 2;
top += (mCellHeight - dragOutline.getHeight()) / 2;
}
final int oldIndex = mDragOutlineCurrent;

View File

@ -21,9 +21,7 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.AdapterView.OnItemClickListener;

View File

@ -1,18 +1,15 @@
package com.android.launcher2;
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.TextView;
import com.android.launcher.R;
import java.util.ArrayList;
/**
* Folder which contains applications or shortcuts chosen by the user.
@ -81,7 +78,9 @@ public class UserFolder extends Folder implements DropTarget {
return false;
}
mLauncher.getWorkspace().onDragStartedWithItem(v);
mDragController.startDrag(v, this, item, DragController.DRAG_ACTION_COPY);
mLauncher.closeFolder(this);
mDragItem = item;

View File

@ -16,8 +16,9 @@
package com.android.launcher2;
import com.android.launcher.R;
import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@ -66,9 +67,8 @@ import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import com.android.launcher.R;
import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
/**
* The workspace is a wide area with a wallpaper and a finite number of pages.
@ -1731,13 +1731,25 @@ public class Workspace extends SmoothPagedView
/*
*
* We call these methods (onDragStartedWithItemSpans/onDragStartedWithItemMinSize) whenever we
* We call these methods (onDragStartedWithItemSpans/onDragStartedWithSize) whenever we
* start a drag in Launcher, regardless of whether the drag has ever entered the Workspace
*
* These methods mark the appropriate pages as accepting drops (which alters their visual
* appearance).
*
*/
public void onDragStartedWithItem(View v) {
mIsDragInProcess = true;
final Canvas canvas = new Canvas();
// We need to add extra padding to the bitmap to make room for the glow effect
final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
// The outline is used to visualize where the item will land if dropped
mDragOutline = createDragOutline(v, canvas, bitmapPadding);
}
public void onDragStartedWithItemSpans(int spanX, int spanY, Bitmap b) {
mIsDragInProcess = true;
@ -1747,9 +1759,11 @@ public class Workspace extends SmoothPagedView
final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
CellLayout cl = (CellLayout) getChildAt(0);
int[] desiredSize = cl.cellSpansToSize(spanX, spanY);
int[] size = cl.cellSpansToSize(spanX, spanY);
// The outline is used to visualize where the item will land if dropped
mDragOutline = createDragOutline(b, canvas, bitmapPadding, desiredSize[0], desiredSize[1]);
mDragOutline = createDragOutline(b, canvas, bitmapPadding, size[0], size[1]);
updateWhichPagesAcceptDropsDuringDrag(mShrinkState, spanX, spanY);
}