Loading src/com/android/launcher3/BubbleTextView.java +17 −1 Original line number Diff line number Diff line Loading @@ -722,11 +722,27 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } @Override public void getVisualDragBounds(Rect bounds) { public void getWorkspaceVisualDragBounds(Rect bounds) { DeviceProfile grid = mActivity.getDeviceProfile(); BubbleTextView.getIconBounds(this, bounds, grid.iconSizePx); } private int getIconSizeForDisplay(int display) { DeviceProfile grid = mActivity.getDeviceProfile(); switch (display) { case DISPLAY_ALL_APPS: return grid.allAppsIconSizePx; case DISPLAY_WORKSPACE: case DISPLAY_FOLDER: default: return grid.iconSizePx; } } public void getSourceVisualDragBounds(Rect bounds) { BubbleTextView.getIconBounds(this, bounds, getIconSizeForDisplay(mDisplay)); } @Override public void prepareDrawDragView() { if (getIcon() instanceof FastBitmapDrawable) { Loading src/com/android/launcher3/Workspace.java +5 −5 Original line number Diff line number Diff line Loading @@ -1441,6 +1441,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator> mOutlineProvider = previewProvider; if (draggableView == null && child instanceof DraggableView) { draggableView = (DraggableView) child; } // The drag bitmap follows the touch point around on the screen final Bitmap b = previewProvider.createDragBitmap(); int halfPadding = previewProvider.previewPadding / 2; Loading @@ -1451,12 +1455,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator> Point dragVisualizeOffset = null; Rect dragRect = new Rect(); if (draggableView == null && child instanceof DraggableView) { draggableView = (DraggableView) child; } if (draggableView != null) { draggableView.getVisualDragBounds(dragRect); draggableView.getSourceVisualDragBounds(dragRect); dragLayerY += dragRect.top; dragVisualizeOffset = new Point(- halfPadding, halfPadding); } Loading src/com/android/launcher3/dragndrop/DragLayer.java +15 −5 Original line number Diff line number Diff line Loading @@ -274,19 +274,29 @@ public class DragLayer extends BaseDragLayer<Launcher> { scale *= childScale; int toX = Math.round(coord[0]); int toY = Math.round(coord[1]); float toScale = scale; if (child instanceof DraggableView) { // This code is fairly subtle. Please verify drag and drop is pixel-perfect in a number // of scenarios before modifying (from all apps, from workspace, different grid-sizes, // shortcuts from in and out of Launcher etc). DraggableView d = (DraggableView) child; d.getVisualDragBounds(dragViewBounds); Rect destRect = new Rect(); d.getWorkspaceVisualDragBounds(destRect); // In most cases this additional scale factor should be a no-op (1). It mainly accounts // for alternate grids where the source and destination icon sizes are different toScale *= ((1f * destRect.width()) / (dragView.getMeasuredWidth() - dragView.getBlurSizeOutline())); // This accounts for the offset of the DragView created by scaling it about its // center as it animates into place. float scaleShiftX = dragView.getMeasuredWidth() * (1 - scale) / 2; float scaleShiftY = dragView.getMeasuredHeight() * (1 - scale) / 2; float scaleShiftX = dragView.getMeasuredWidth() * (1 - toScale) / 2; float scaleShiftY = dragView.getMeasuredHeight() * (1 - toScale) / 2; toX += scale * (dragViewBounds.left - dragView.getBlurSizeOutline() / 2) - scaleShiftX; toY += scale * (dragViewBounds.top - dragView.getBlurSizeOutline() / 2) - scaleShiftY; toX += scale * destRect.left - toScale * dragView.getBlurSizeOutline() / 2 - scaleShiftX; toY += scale * destRect.top - toScale * dragView.getBlurSizeOutline() / 2 - scaleShiftY; } child.setVisibility(INVISIBLE); Loading src/com/android/launcher3/dragndrop/DraggableView.java +10 −1 Original line number Diff line number Diff line Loading @@ -53,5 +53,14 @@ public interface DraggableView { * * @param bounds Visual bounds in the views coordinates will be written here. */ default void getVisualDragBounds(Rect bounds) { } default void getWorkspaceVisualDragBounds(Rect bounds) { } /** * Same as above, but accounts for differing icon sizes between source and destination * * @param bounds Visual bounds in the views coordinates will be written here. */ default void getSourceVisualDragBounds(Rect bounds) { getWorkspaceVisualDragBounds(bounds); } } src/com/android/launcher3/folder/FolderIcon.java +1 −1 Original line number Diff line number Diff line Loading @@ -758,7 +758,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel } @Override public void getVisualDragBounds(Rect bounds) { public void getWorkspaceVisualDragBounds(Rect bounds) { getPreviewBounds(bounds); } } Loading
src/com/android/launcher3/BubbleTextView.java +17 −1 Original line number Diff line number Diff line Loading @@ -722,11 +722,27 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } @Override public void getVisualDragBounds(Rect bounds) { public void getWorkspaceVisualDragBounds(Rect bounds) { DeviceProfile grid = mActivity.getDeviceProfile(); BubbleTextView.getIconBounds(this, bounds, grid.iconSizePx); } private int getIconSizeForDisplay(int display) { DeviceProfile grid = mActivity.getDeviceProfile(); switch (display) { case DISPLAY_ALL_APPS: return grid.allAppsIconSizePx; case DISPLAY_WORKSPACE: case DISPLAY_FOLDER: default: return grid.iconSizePx; } } public void getSourceVisualDragBounds(Rect bounds) { BubbleTextView.getIconBounds(this, bounds, getIconSizeForDisplay(mDisplay)); } @Override public void prepareDrawDragView() { if (getIcon() instanceof FastBitmapDrawable) { Loading
src/com/android/launcher3/Workspace.java +5 −5 Original line number Diff line number Diff line Loading @@ -1441,6 +1441,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator> mOutlineProvider = previewProvider; if (draggableView == null && child instanceof DraggableView) { draggableView = (DraggableView) child; } // The drag bitmap follows the touch point around on the screen final Bitmap b = previewProvider.createDragBitmap(); int halfPadding = previewProvider.previewPadding / 2; Loading @@ -1451,12 +1455,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator> Point dragVisualizeOffset = null; Rect dragRect = new Rect(); if (draggableView == null && child instanceof DraggableView) { draggableView = (DraggableView) child; } if (draggableView != null) { draggableView.getVisualDragBounds(dragRect); draggableView.getSourceVisualDragBounds(dragRect); dragLayerY += dragRect.top; dragVisualizeOffset = new Point(- halfPadding, halfPadding); } Loading
src/com/android/launcher3/dragndrop/DragLayer.java +15 −5 Original line number Diff line number Diff line Loading @@ -274,19 +274,29 @@ public class DragLayer extends BaseDragLayer<Launcher> { scale *= childScale; int toX = Math.round(coord[0]); int toY = Math.round(coord[1]); float toScale = scale; if (child instanceof DraggableView) { // This code is fairly subtle. Please verify drag and drop is pixel-perfect in a number // of scenarios before modifying (from all apps, from workspace, different grid-sizes, // shortcuts from in and out of Launcher etc). DraggableView d = (DraggableView) child; d.getVisualDragBounds(dragViewBounds); Rect destRect = new Rect(); d.getWorkspaceVisualDragBounds(destRect); // In most cases this additional scale factor should be a no-op (1). It mainly accounts // for alternate grids where the source and destination icon sizes are different toScale *= ((1f * destRect.width()) / (dragView.getMeasuredWidth() - dragView.getBlurSizeOutline())); // This accounts for the offset of the DragView created by scaling it about its // center as it animates into place. float scaleShiftX = dragView.getMeasuredWidth() * (1 - scale) / 2; float scaleShiftY = dragView.getMeasuredHeight() * (1 - scale) / 2; float scaleShiftX = dragView.getMeasuredWidth() * (1 - toScale) / 2; float scaleShiftY = dragView.getMeasuredHeight() * (1 - toScale) / 2; toX += scale * (dragViewBounds.left - dragView.getBlurSizeOutline() / 2) - scaleShiftX; toY += scale * (dragViewBounds.top - dragView.getBlurSizeOutline() / 2) - scaleShiftY; toX += scale * destRect.left - toScale * dragView.getBlurSizeOutline() / 2 - scaleShiftX; toY += scale * destRect.top - toScale * dragView.getBlurSizeOutline() / 2 - scaleShiftY; } child.setVisibility(INVISIBLE); Loading
src/com/android/launcher3/dragndrop/DraggableView.java +10 −1 Original line number Diff line number Diff line Loading @@ -53,5 +53,14 @@ public interface DraggableView { * * @param bounds Visual bounds in the views coordinates will be written here. */ default void getVisualDragBounds(Rect bounds) { } default void getWorkspaceVisualDragBounds(Rect bounds) { } /** * Same as above, but accounts for differing icon sizes between source and destination * * @param bounds Visual bounds in the views coordinates will be written here. */ default void getSourceVisualDragBounds(Rect bounds) { getWorkspaceVisualDragBounds(bounds); } }
src/com/android/launcher3/folder/FolderIcon.java +1 −1 Original line number Diff line number Diff line Loading @@ -758,7 +758,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel } @Override public void getVisualDragBounds(Rect bounds) { public void getWorkspaceVisualDragBounds(Rect bounds) { getPreviewBounds(bounds); } }