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

Commit a8f07d91 authored by Jason Monk's avatar Jason Monk
Browse files

QS Edit: fix some move logic

Make sure its possible to add tiles when none are there and remove
tiles when all are added.

Bug: 28067638
Change-Id: Ia5a145f095cd33cf8d4a85a0a8aabb2344e3dec6
parent f3bd7a30
Loading
Loading
Loading
Loading
+23 −14
Original line number Diff line number Diff line
@@ -330,9 +330,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta

    private boolean move(int from, int to, View v) {
        if (to >= mEditIndex) {
            if (from >= mEditIndex) {
                return false;
            }
            if (from < mEditIndex) {
                // Removing a tile.
                // Sort tiles into system/non-system groups.
                TileInfo tile = mTiles.get(from);
                if (tile.isSystem) {
@@ -348,6 +347,16 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
                        to = mTileDividerIndex;
                    }
                }
            } else {
                if (to > mEditIndex) {
                    // Don't allow tiles to be dragged around when they aren't added.
                    return false;
                }
                // Allow the case where to == mEditIndex to fall through and swap which
                // side the tile is currently on.
                // This lets the the cases where all tiles are on one side of the line
                // work.
            }
        }
        CharSequence fromLabel = mTiles.get(from).state.label;
        move(from, to, mTiles);