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

Commit 746d420f authored by Samuel Fufa's avatar Samuel Fufa
Browse files

Notify predictor on appIcon convert to folder

Bug:148749638
Test:Manual
Change-Id: I7eed1f309197479f708a23029c04106af0ac536f
parent 4e7a48f2
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.FolderInfo;
import com.android.launcher3.Hotseat;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
@@ -443,6 +444,20 @@ public class HotseatPredictionController implements DragController.DragListener,
        mHotseat.invalidate();
    }

    /**
     * Unpins pinned app when it's converted into a folder
     */
    public void folderCreatedFromIcon(ItemInfo info, FolderInfo folderInfo) {
        AppTarget target = getAppTargetFromItemInfo(info);
        if (folderInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT && !isInHotseat(
                info)) {
            notifyItemAction(target, APP_LOCATION_HOTSEAT, APPTARGET_ACTION_UNPIN);
        } else if (folderInfo.container == LauncherSettings.Favorites.CONTAINER_DESKTOP
                && folderInfo.screenId == Workspace.FIRST_SCREEN_ID && !isInFirstPage(info)) {
            notifyItemAction(target, APP_LOCATION_WORKSPACE, APPTARGET_ACTION_UNPIN);
        }
    }

    @Override
    public void onDragEnd() {
        if (mDragObject == null) {
+13 −0
Original line number Diff line number Diff line
@@ -26,11 +26,14 @@ import android.os.Bundle;
import android.view.Gravity;

import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.popup.SystemShortcut;
@@ -168,6 +171,16 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
        }
    }

    @Override
    public FolderIcon addFolder(CellLayout layout, WorkspaceItemInfo info, int container,
            int screenId, int cellX, int cellY) {
        FolderIcon fi =  super.addFolder(layout, info, container, screenId, cellX, cellY);
        if (mHotseatPredictionController != null) {
            mHotseatPredictionController.folderCreatedFromIcon(info, fi.getFolder().getInfo());
        }
        return fi;
    }

    @Override
    public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
        if (mHotseatPredictionController != null) {
+7 −3
Original line number Diff line number Diff line
@@ -1721,8 +1721,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        }
    }

    FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX,
            int cellY) {
    /**
     * Creates and adds new folder to CellLayout
     */
    public FolderIcon addFolder(CellLayout layout, WorkspaceItemInfo info, int container,
            final int screenId, int cellX, int cellY) {
        final FolderInfo folderInfo = new FolderInfo();
        folderInfo.title = "";

@@ -1730,7 +1733,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        getModelWriter().addItemToDatabase(folderInfo, container, screenId, cellX, cellY);

        // Create the view
        FolderIcon newFolder = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this, layout, folderInfo);
        FolderIcon newFolder = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, this, layout,
                folderInfo);
        mWorkspace.addInScreen(newFolder, folderInfo);
        // Force measure the new folder icon
        CellLayout parent = mWorkspace.getParentCellLayoutForView(newFolder);
+2 −2
Original line number Diff line number Diff line
@@ -1703,8 +1703,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
            float scale = mLauncher.getDragLayer().getDescendantRectRelativeToSelf(v, folderLocation);
            target.removeView(v);

            FolderIcon fi =
                mLauncher.addFolder(target, container, screenId, targetCell[0], targetCell[1]);
            FolderIcon fi = mLauncher.addFolder(target, sourceInfo, container, screenId,
                    targetCell[0], targetCell[1]);
            destInfo.cellX = -1;
            destInfo.cellY = -1;
            sourceInfo.cellX = -1;