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

Commit f153d917 authored by Sebastian Franco's avatar Sebastian Franco Committed by Sebastián Franco
Browse files

Adding support for LauncherAppWidgetHostView in CellLayout

With the introduction of LauncherAppWidgetHostView, CellLayout
no longer reorder correctly when dragging a widget.

Fix: 221495448
Test: When dragging a widget and all spaces are occupied, other icons
should move to the place the widget being dragged used to occupy.

Change-Id: I59ab21eb2717b56a216900049bb4546504e773ba
parent 7183e4b4
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.util.CellAndSpan;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.ParcelableSparseArray;
@@ -2733,12 +2734,24 @@ public class CellLayout extends ViewGroup {
    }

    public void markCellsAsOccupiedForView(View view) {
        if (view instanceof LauncherAppWidgetHostView
                && view.getTag() instanceof LauncherAppWidgetInfo) {
            LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
            mOccupied.markCells(info.cellX, info.cellY, info.spanX, info.spanY, true);
            return;
        }
        if (view == null || view.getParent() != mShortcutsAndWidgets) return;
        LayoutParams lp = (LayoutParams) view.getLayoutParams();
        mOccupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, true);
    }

    public void markCellsAsUnoccupiedForView(View view) {
        if (view instanceof LauncherAppWidgetHostView
                && view.getTag() instanceof LauncherAppWidgetInfo) {
            LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
            mOccupied.markCells(info.cellX, info.cellY, info.spanX, info.spanY, false);
            return;
        }
        if (view == null || view.getParent() != mShortcutsAndWidgets) return;
        LayoutParams lp = (LayoutParams) view.getLayoutParams();
        mOccupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, false);