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

Commit 5deef349 authored by Kshitij's avatar Kshitij Committed by Nishith Khanna
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.

Signed-off-by: default avatarSaalim Quadri <danascape@gmail.com>
parent c529f954
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -884,14 +884,12 @@ 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);
        updateFixedLandscape();
        return true;
    }
+2 −1
Original line number Diff line number Diff line
@@ -160,10 +160,11 @@ class LauncherModel(
    }

    fun getWriter(
        hasVerticalHotseat: Boolean,
        verifyChanges: Boolean,
        cellPosMapper: CellPosMapper?,
        owner: BgDataModel.Callbacks?,
    ) = ModelWriter(mApp.context, this, mBgDataModel, verifyChanges, cellPosMapper, owner)
    ) = ModelWriter(mApp.context, this, mBgDataModel, hasVerticalHotseat, verifyChanges, cellPosMapper, owner)

    /** Returns the [WidgetsFilterDataProvider] that manages widget filters. */
    fun getWidgetsFilterDataProvider(): WidgetsFilterDataProvider {
+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;
        }
+1 −1
Original line number Diff line number Diff line
@@ -387,7 +387,7 @@ public class BaseLauncherBinder {
            }

            ModelWriter writer = mApp.getModel()
                    .getWriter(false /* verifyChanges */, CellPosMapper.DEFAULT, null);
                    .getWriter(false /* hasVerticalHotseat */, false /* verifyChanges */, CellPosMapper.DEFAULT, null);
            List<Pair<ItemInfo, View>> bindItems = items.stream().map(i ->
                    Pair.create(i, inflater.inflateItem(i, writer, null))).toList();
            executeCallbacksTask(c -> c.bindInflatedItems(bindItems), executor);
Loading