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

Commit b87f3cdc authored by Tony Wickham's avatar Tony Wickham
Browse files

Add support for having more hotseat icons in the DB than we show

Split InvariantDeviceProfile#numHotseatIcons into two variables:
numDatabaseHotseatIcons and numShownHotseatIcons. These are generally
the same, but different DisplayOptions within the same GridOption
can choose to show different numbers of hotseat icons while sharing
the same database.

numDatabaseHotseatIcons is used for all reading/writing/migrating
purposes, while numShownHotseatIcons determines how many Hotseat
icons to show in the UI.

Test: Existing tests pass, added two new migration tests
Bug: 184789479
Bug: 171917176

Change-Id: I54583504f61a47a4444b6a637ebb7e3ab31528b7
parent 12eeecc3
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public class HotseatEduController {
        ArrayList<WorkspaceItemInfo> putIntoFolder = new ArrayList<>();

        //separate folders and items that can get in folders
        for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
        for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) {
            View view = mHotseat.getChildAt(i, 0);
            if (view == null) continue;
            ItemInfo info = (ItemInfo) view.getTag();
@@ -188,7 +188,7 @@ public class HotseatEduController {
                    .getInt(LauncherSettings.Settings.EXTRA_VALUE);
            mNewScreens = IntArray.wrap(pageId);
        }
        for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
        for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) {
            View child = mHotseat.getChildAt(i, 0);
            if (child == null || child.getTag() == null) continue;
            ItemInfo tag = (ItemInfo) child.getTag();
@@ -224,7 +224,7 @@ public class HotseatEduController {

    void showDimissTip() {
        if (mHotseat.getShortcutsAndWidgets().getChildCount()
                < mLauncher.getDeviceProfile().inv.numHotseatIcons) {
                < mLauncher.getDeviceProfile().numShownHotseatIcons) {
            Snackbar.show(mLauncher, R.string.hotseat_tip_gaps_filled,
                    R.string.hotseat_prediction_settings, null,
                    () -> mLauncher.startActivity(getSettingsIntent()));
+3 −3
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable
        Rect padding = grid.getHotseatLayoutPadding();

        mSampleHotseat.getLayoutParams().height = grid.cellHeightPx;
        mSampleHotseat.setGridSize(grid.inv.numHotseatIcons, 1);
        mSampleHotseat.setGridSize(grid.numShownHotseatIcons, 1);
        mSampleHotseat.setPadding(padding.left, 0, padding.right, 0);

        Button turnOnBtn = findViewById(R.id.turn_predictions_on);
@@ -178,7 +178,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable
    }

    private void populatePreview(List<WorkspaceItemInfo> predictions) {
        for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
        for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) {
            WorkspaceItemInfo info = predictions.get(i);
            PredictedAppIcon icon = PredictedAppIcon.createIcon(mSampleHotseat, info);
            icon.setEnabled(false);
@@ -194,7 +194,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable
     */
    public void show(List<WorkspaceItemInfo> predictions) {
        if (getParent() != null
                || predictions.size() < mLauncher.getDeviceProfile().inv.numHotseatIcons
                || predictions.size() < mLauncher.getDeviceProfile().numShownHotseatIcons
                || mHotseatEduController == null) {
            return;
        }
+7 −7
Original line number Diff line number Diff line
@@ -33,10 +33,10 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Hotseat;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimationSuccessListener;
@@ -68,7 +68,7 @@ import java.util.stream.Collectors;
 * pinning of predicted apps and manages replacement of predicted apps with user drag.
 */
public class HotseatPredictionController implements DragController.DragListener,
        SystemShortcut.Factory<QuickstepLauncher>, InvariantDeviceProfile.OnIDPChangeListener,
        SystemShortcut.Factory<QuickstepLauncher>, DeviceProfile.OnDeviceProfileChangeListener,
        DragSource, ViewGroup.OnHierarchyChangeListener {

    private static final int FLAG_UPDATE_PAUSED = 1 << 0;
@@ -115,10 +115,10 @@ public class HotseatPredictionController implements DragController.DragListener,
    public HotseatPredictionController(QuickstepLauncher launcher) {
        mLauncher = launcher;
        mHotseat = launcher.getHotseat();
        mHotSeatItemsCount = mLauncher.getDeviceProfile().inv.numHotseatIcons;
        mHotSeatItemsCount = mLauncher.getDeviceProfile().numShownHotseatIcons;
        mLauncher.getDragController().addDragListener(this);

        launcher.getDeviceProfile().inv.addOnChangeListener(this);
        launcher.addOnDeviceProfileChangeListener(this);
        mHotseat.getShortcutsAndWidgets().setOnHierarchyChangeListener(this);
    }

@@ -281,7 +281,7 @@ public class HotseatPredictionController implements DragController.DragListener,
     * Unregisters callbacks and frees resources
     */
    public void destroy() {
        mLauncher.getDeviceProfile().inv.removeOnChangeListener(this);
        mLauncher.removeOnDeviceProfileChangeListener(this);
    }

    /**
@@ -446,8 +446,8 @@ public class HotseatPredictionController implements DragController.DragListener,
    }

    @Override
    public void onIdpChanged(int changeFlags, InvariantDeviceProfile profile) {
        this.mHotSeatItemsCount = profile.numHotseatIcons;
    public void onDeviceProfileChanged(DeviceProfile profile) {
        this.mHotSeatItemsCount = profile.numShownHotseatIcons;
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class HotseatRestoreHelper {
                            .getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
                InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
                GridBackupTable backupTable = new GridBackupTable(context,
                        transaction.getDb(), idp.numHotseatIcons, idp.numColumns,
                        transaction.getDb(), idp.numDatabaseHotseatIcons, idp.numColumns,
                        idp.numRows);
                backupTable.createCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE);
                transaction.commit();
@@ -69,7 +69,7 @@ public class HotseatRestoreHelper {
                }
                InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
                GridBackupTable backupTable = new GridBackupTable(context,
                        transaction.getDb(), idp.numHotseatIcons, idp.numColumns,
                        transaction.getDb(), idp.numDatabaseHotseatIcons, idp.numColumns,
                        idp.numRows);
                backupTable.restoreFromCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE, true);
                transaction.commit();
+2 −2
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange
        mDataModel.extraItems.put(CONTAINER_PREDICTION, mAllAppsState.items);

        WorkspaceItemFactory hotseatFactory =
                new WorkspaceItemFactory(mApp, ums, pinnedShortcuts, mIDP.numHotseatIcons);
                new WorkspaceItemFactory(mApp, ums, pinnedShortcuts, mIDP.numDatabaseHotseatIcons);
        mHotseatState.items.setItems(
                mHotseatState.storage.read(mApp.getContext(), hotseatFactory, ums.allUsers::get));
        mDataModel.extraItems.put(CONTAINER_HOTSEAT_PREDICTION, mHotseatState.items);
@@ -211,7 +211,7 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange
        registerPredictor(mHotseatState, apm.createAppPredictionSession(
                new AppPredictionContext.Builder(context)
                        .setUiSurface("hotseat")
                        .setPredictedTargetCount(mIDP.numHotseatIcons)
                        .setPredictedTargetCount(mIDP.numDatabaseHotseatIcons)
                        .setExtras(convertDataModelToAppTargetBundle(context, mDataModel))
                        .build()));

Loading