Merge "Use just the preview for drag and drop in the standalone activity" into main

This commit is contained in:
Treehugger Robot
2024-06-07 01:30:34 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 2 deletions

View File

@@ -194,6 +194,11 @@ public class WidgetPickerActivity extends BaseActivity {
return false;
}
View dragView = widgetCell.getDragAndDropView();
if (dragView == null) {
return false;
}
ClipData clipData = new ClipData(
new ClipDescription(
/* label= */ "", // not displayed anywhere; so, set to empty.
@@ -209,9 +214,9 @@ public class WidgetPickerActivity extends BaseActivity {
.putExtra(EXTRA_IS_PENDING_WIDGET_DRAG, true));
// DRAG_FLAG_GLOBAL permits dragging data beyond app window.
return view.startDragAndDrop(
return dragView.startDragAndDrop(
clipData,
new View.DragShadowBuilder(view),
new View.DragShadowBuilder(dragView),
/* myLocalState= */ null,
View.DRAG_FLAG_GLOBAL
);

View File

@@ -372,6 +372,13 @@ public class WidgetCell extends LinearLayout {
}
}
/**
* Returns a view (holding the previews) that can be dragged and dropped.
*/
public View getDragAndDropView() {
return mWidgetImageContainer;
}
public WidgetImageView getWidgetView() {
return mWidgetImage;
}