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

Commit 518e862e authored by Kshitij's avatar Kshitij
Browse files

Revert "Use the number of shown hotseat icons instead of database items to store into the DB"

- We rely on altering number of hotseat icons, which does
  not reflect with the now-reverted change correctly. This breaks
  index values in the db when reordering in transpose (landscape)
- Reverting this change and adapting to our changes fixes the issue

This reverts commit 2d023e26.
parent 7bdda63e
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -847,14 +847,13 @@ public class Launcher extends StatefulActivity<LauncherState>
            mCellPosMapper = new TwoPanelCellPosMapper(mDeviceProfile.inv.numColumns);
        } else {
            if (mDeviceProfile.isLandscape) {
                mCellPosMapper = new CellPosMapper.TransposeCellPosMapper(mDeviceProfile.inv,
                        mDeviceProfile.isVerticalBarLayout(), mDeviceProfile.numShownHotseatIcons);
                mCellPosMapper = new CellPosMapper.TransposeCellPosMapper(mDeviceProfile.inv);
            } else {
                mCellPosMapper = new CellPosMapper(mDeviceProfile.isVerticalBarLayout(),
                        mDeviceProfile.numShownHotseatIcons);
                mCellPosMapper = CellPosMapper.DEFAULT;
            }
        }
        mModelWriter = mModel.getWriter(true, mCellPosMapper, this);
        mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true,
                mCellPosMapper, this);
        return true;
    }

+4 −4
Original line number Diff line number Diff line
@@ -207,10 +207,10 @@ public class LauncherModel implements InstallSessionTracker.Callback {
    }

    @NonNull
    public ModelWriter getWriter(final boolean verifyChanges, CellPosMapper cellPosMapper,
            @Nullable final Callbacks owner) {
        return new ModelWriter(mApp.getContext(), this, mBgDataModel, verifyChanges, cellPosMapper,
                owner);
    public ModelWriter getWriter(final boolean hasVerticalHotseat, final boolean verifyChanges,
            CellPosMapper cellPosMapper, @Nullable final Callbacks owner) {
        return new ModelWriter(mApp.getContext(), this, mBgDataModel,
                hasVerticalHotseat, verifyChanges, cellPosMapper, owner);
    }

    /**
+4 −24
Original line number Diff line number Diff line
@@ -29,14 +29,9 @@ import java.util.Objects;
 */
public class CellPosMapper {

    public static final CellPosMapper DEFAULT = new CellPosMapper(false, -1);
    private final boolean mHasVerticalHotseat;
    private final int mNumOfHotseat;
    public static final CellPosMapper DEFAULT = new CellPosMapper();

    public CellPosMapper(boolean hasVerticalHotseat, int numOfHotseat) {
        mHasVerticalHotseat = hasVerticalHotseat;
        mNumOfHotseat = numOfHotseat;
    }
    private CellPosMapper() { }

    /**
     * Maps the position in model to the position in view
@@ -50,10 +45,6 @@ public class CellPosMapper {
     */
    public CellPos mapPresenterToModel(int presenterX, int presenterY, int presenterScreen,
            int container) {
        if (container == Favorites.CONTAINER_HOTSEAT) {
            presenterScreen = mHasVerticalHotseat
                    ? mNumOfHotseat - presenterY - 1 : presenterX;
        }
        return new CellPos(presenterX, presenterY, presenterScreen);
    }

@@ -65,9 +56,7 @@ public class CellPosMapper {

        private final InvariantDeviceProfile mIDP;

        public TransposeCellPosMapper(InvariantDeviceProfile idp,
                boolean hasVerticalHotseat, int numOfHotseat) {
            super(hasVerticalHotseat, numOfHotseat);
        public TransposeCellPosMapper(InvariantDeviceProfile idp) {
            this.mIDP = idp;
        }

@@ -105,7 +94,6 @@ public class CellPosMapper {
        private final int mColumnCount;

        public TwoPanelCellPosMapper(int columnCount) {
            super(false, -1);
            mColumnCount = columnCount;
        }

@@ -156,13 +144,5 @@ public class CellPosMapper {
        public int hashCode() {
            return Objects.hash(cellX, cellY, screenId);
        }

        @Override
        public String toString() {
            return "CellPos{"
                    + "cellX=" + cellX
                    + ", cellY=" + cellY
                    + ", screenId=" + screenId + '}';
        }
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.celllayout.CellPosMapper;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
@@ -185,8 +186,8 @@ public class LauncherDelegate {
        @Override
        ModelWriter getModelWriter() {
            if (mWriter == null) {
                mWriter = LauncherAppState.getInstance((Context) mContext).getModel().getWriter(
                        false, mContext.getCellPosMapper(), null);
                mWriter = LauncherAppState.getInstance((Context) mContext).getModel()
                        .getWriter(false, false, CellPosMapper.DEFAULT, null);
            }
            return mWriter;
        }
+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
    public ModelWriter getModelWriter() {
        // Updates from model task, do not deal with icon position in hotseat. Also no need to
        // verify changes as the ModelTasks always push the changes to callbacks
        return mModel.getWriter(false /* verifyChanges */, CellPosMapper.DEFAULT, null);
        return mModel.getWriter(false /* hasVerticalHotseat */, false /* verifyChanges */,
                CellPosMapper.DEFAULT, null);
    }

    public void bindUpdatedWorkspaceItems(@NonNull final List<WorkspaceItemInfo> allUpdates) {
Loading