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

Commit da18b9e4 authored by Sebastián Franco's avatar Sebastián Franco Committed by Android (Google) Code Review
Browse files

Merge "Use the number of shown hotseat icons instead of database items to...

Merge "Use the number of shown hotseat icons instead of database items to store into the DB" into main
parents cc9ae30a 2d023e26
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -780,10 +780,10 @@ public class Launcher extends StatefulActivity<LauncherState>
        if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.isTwoPanels) {
            mCellPosMapper = new TwoPanelCellPosMapper(mDeviceProfile.inv.numColumns);
        } else {
            mCellPosMapper = CellPosMapper.DEFAULT;
            mCellPosMapper = new CellPosMapper(mDeviceProfile.isVerticalBarLayout(),
                    mDeviceProfile.numShownHotseatIcons);
        }
        mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true,
                mCellPosMapper, this);
        mModelWriter = mModel.getWriter(true, mCellPosMapper, this);
        return true;
    }

+4 −4
Original line number Diff line number Diff line
@@ -180,10 +180,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
    }

    @NonNull
    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);
    public ModelWriter getWriter(final boolean verifyChanges, CellPosMapper cellPosMapper,
            @Nullable final Callbacks owner) {
        return new ModelWriter(mApp.getContext(), this, mBgDataModel, verifyChanges, cellPosMapper,
                owner);
    }

    @Override
+22 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.launcher3.celllayout;

import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;

import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.data.ItemInfo;

import java.util.Objects;
@@ -26,9 +27,14 @@ import java.util.Objects;
 */
public class CellPosMapper {

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

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

    /**
     * Maps the position in model to the position in view
@@ -42,6 +48,10 @@ 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);
    }

@@ -53,6 +63,7 @@ public class CellPosMapper {
        private final int mColumnCount;

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

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

        @Override
        public String toString() {
            return "CellPos{"
                    + "cellX=" + cellX
                    + ", cellY=" + cellY
                    + ", screenId=" + screenId + '}';
        }
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ 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;
@@ -177,8 +176,8 @@ public class LauncherDelegate {
        @Override
        ModelWriter getModelWriter() {
            if (mWriter == null) {
                mWriter = LauncherAppState.getInstance((Context) mContext).getModel()
                        .getWriter(false, false, CellPosMapper.DEFAULT, null);
                mWriter = LauncherAppState.getInstance((Context) mContext).getModel().getWriter(
                        false, mContext.getCellPosMapper(), null);
            }
            return mWriter;
        }
+1 −2
Original line number Diff line number Diff line
@@ -101,8 +101,7 @@ 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 /* hasVerticalHotseat */, false /* verifyChanges */,
                CellPosMapper.DEFAULT, null);
        return mModel.getWriter(false /* verifyChanges */, CellPosMapper.DEFAULT, null);
    }

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