Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51e1bc22 authored by Thales Lima's avatar Thales Lima Committed by Cherrypicker Worker
Browse files

Show resize handle on cancel widget drop

Fix: 233834133
Test: manual on handheld and large screens, until we have create a way to resize widgets in TAPL b/241385885

Change-Id: I427dfaadd219d33a5371c3ae92c4e2311d3d3c6a
(cherry picked from commit 84fa75cc)
Merged-In: I427dfaadd219d33a5371c3ae92c4e2311d3d3c6a
parent c784f76c
Loading
Loading
Loading
Loading
+27 −13
Original line number Original line Diff line number Diff line
@@ -2063,20 +2063,11 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>


                    if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
                    if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
                            cell instanceof LauncherAppWidgetHostView) {
                            cell instanceof LauncherAppWidgetHostView) {
                        final CellLayout cellLayout = dropTargetLayout;

                        // We post this call so that the widget has a chance to be placed
                        // We post this call so that the widget has a chance to be placed
                        // in its final location
                        // in its final location

                        onCompleteRunnable = getWidgetResizeFrameRunnable(options,
                        final LauncherAppWidgetHostView hostView = (LauncherAppWidgetHostView) cell;
                                (LauncherAppWidgetHostView) cell, dropTargetLayout);
                        AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo();
                        if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE
                                && !options.isAccessibleDrag) {
                            onCompleteRunnable = () -> {
                                if (!isPageInTransition()) {
                                    AppWidgetResizeFrame.showForWidget(hostView, cellLayout);
                                }
                            };
                        }
                    }
                    }
                    mLauncher.getModelWriter().modifyItemInDatabase(info, container, screenId,
                    mLauncher.getModelWriter().modifyItemInDatabase(info, container, screenId,
                            lp.cellX, lp.cellY, item.spanX, item.spanY);
                            lp.cellX, lp.cellY, item.spanX, item.spanY);
@@ -2097,8 +2088,16 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
                }
                }
            } else {
            } else {
                // When drag is cancelled, reattach content view back to its original parent.
                // When drag is cancelled, reattach content view back to its original parent.
                if (mDragInfo.cell instanceof LauncherAppWidgetHostView) {
                if (cell instanceof LauncherAppWidgetHostView) {
                    d.dragView.detachContentView(/* reattachToPreviousParent= */ true);
                    d.dragView.detachContentView(/* reattachToPreviousParent= */ true);

                    final CellLayout cellLayout = getParentCellLayoutForView(cell);
                    boolean pageIsVisible = isVisible(cellLayout);

                    if (pageIsVisible) {
                        onCompleteRunnable = getWidgetResizeFrameRunnable(options,
                                (LauncherAppWidgetHostView) cell, cellLayout);
                    }
                }
                }
            }
            }


@@ -2150,6 +2149,21 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
        }
        }
    }
    }


    @Nullable
    private Runnable getWidgetResizeFrameRunnable(DragOptions options,
            LauncherAppWidgetHostView hostView, CellLayout cellLayout) {
        AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo();
        if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE
                && !options.isAccessibleDrag) {
            return () -> {
                if (!isPageInTransition()) {
                    AppWidgetResizeFrame.showForWidget(hostView, cellLayout);
                }
            };
        }
        return null;
    }

    public void onNoCellFound(
    public void onNoCellFound(
            View dropTargetLayout, ItemInfo itemInfo, @Nullable InstanceId logInstanceId) {
            View dropTargetLayout, ItemInfo itemInfo, @Nullable InstanceId logInstanceId) {
        int strId = mLauncher.isHotseatLayout(dropTargetLayout)
        int strId = mLauncher.isHotseatLayout(dropTargetLayout)