Initiate Hotseat drag from long pressing corresponding Taskbar item

When you long press on the taskbar hotseat item, the following happens:
- We start a system drag and drop with an invisible drag shadow
- We create a new DragOptions with the simulatedDndStartPoint set to the
  drag down position, and tell Launcher to use that for the next drag
- We perform a long click on the equivalent Hotseat item in Launcher
- We pass the drag events of that operation to Launcher's DragController

This allows Launcher to handle the entire drag operation, including the
pre-drag (with popup), and taskbar already hides when the drag starts.

Test: Long press items in taskbar hotseat, able to drag them to workspace

Bug: 179886115
Bug: 171917176
Change-Id: I576b80cb1bd0225cdc91cf7689fdee0481265109
This commit is contained in:
Tony Wickham
2021-02-26 09:15:31 -08:00
parent 3ca4b0d88f
commit 39938cbc94
9 changed files with 170 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ClipDescriptionCompat;
@@ -57,7 +58,7 @@ public class TaskbarDragController {
* generate the ClipDescription and Intent.
* @return Whether {@link View#startDragAndDrop} started successfully.
*/
protected boolean startDragOnLongClick(View view) {
protected boolean startSystemDragOnLongClick(View view) {
if (!(view instanceof BubbleTextView)) {
return false;
}
@@ -124,6 +125,38 @@ public class TaskbarDragController {
return false;
}
/**
* Starts a drag and drop operation that controls a real Workspace (Hotseat) view.
* @param view The Taskbar item that was long clicked.
* @return Whether {@link View#startDragAndDrop} started successfully.
*/
protected boolean startWorkspaceDragOnLongClick(View view) {
View.DragShadowBuilder transparentShadowBuilder = new View.DragShadowBuilder(view) {
private static final int ARBITRARY_SHADOW_SIZE = 10;
@Override
public void onDrawShadow(Canvas canvas) {
}
@Override
public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) {
outShadowSize.set(ARBITRARY_SHADOW_SIZE, ARBITRARY_SHADOW_SIZE);
outShadowTouchPoint.set(ARBITRARY_SHADOW_SIZE / 2, ARBITRARY_SHADOW_SIZE / 2);
}
};
TaskbarDragListener taskbarDragListener = new TaskbarDragListener(mLauncher,
(ItemInfo) view.getTag());
if (view.startDragAndDrop(new ClipData("", new String[] {taskbarDragListener.getMimeType()},
new ClipData.Item("")),
transparentShadowBuilder, null /* localState */, View.DRAG_FLAG_GLOBAL)) {
view.setOnDragListener(getDraggedViewDragListener());
taskbarDragListener.init(mLauncher.getDragLayer());
return true;
}
return false;
}
/**
* Hide the original Taskbar item while it is being dragged.
*/