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

Commit 474ecb15 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

fix(reorder): Fix bug with reorder while taking icons out of folder

parent 384b98f4
Loading
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -2476,8 +2476,12 @@ public class CellLayout extends ViewGroup {
    }

    public void reArrangeIcons(int x, int y) {

        ItemConfiguration solution = new ItemConfiguration();
        copyCurrentStateToSolution(solution, false);

        solution.save();

        int[] intersecting = new int[2];
        ArrayList<View> views = new ArrayList<>();

@@ -2527,21 +2531,33 @@ public class CellLayout extends ViewGroup {
        }
        cluster.shift(ViewCluster.LEFT, 1);

        Rect clusterRect = cluster.getBoundingRect();
        boolean isSolution = false;
        if (clusterRect.left >= 0 && clusterRect.right <= mCountX && clusterRect.top >= 0 &&
                clusterRect.bottom <= mCountY) {
            isSolution = true;
        } else {
            solution.restore();
        }

        for (View v: cluster.views) {
            CellAndSpan c = solution.map.get(v);
            mTmpOccupied.markCells(c, true);
        }

        if (isSolution) {
            solution.cellX = intersecting[0];
            solution.cellY = intersecting[1];
            solution.spanX = 1;
            solution.spanY = 1;
            solution.isSolution = true;

        for (View v: cluster.views) {
            CellAndSpan c = solution.map.get(v);
            mTmpOccupied.markCells(c, true);
        }

            if (views.size() > 0 && views.get(0) != null) {
                performReorder(solution, views.get(0), MODE_ON_DROP);
            }
        }
    }

    public ReorderAlgorithm createReorderAlgorithm() {
        return new ReorderAlgorithm(this);