From 746d420f767df10d667dc8695ced03fe326bcf65 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Sun, 2 Feb 2020 18:55:44 -0800 Subject: [PATCH] Notify predictor on appIcon convert to folder Bug:148749638 Test:Manual Change-Id: I7eed1f309197479f708a23029c04106af0ac536f --- .../HotseatPredictionController.java | 15 +++++++++++++++ .../launcher3/uioverrides/QuickstepLauncher.java | 13 +++++++++++++ src/com/android/launcher3/Launcher.java | 10 +++++++--- src/com/android/launcher3/Workspace.java | 4 ++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 109439f41b..cc6ec6998d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -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) { diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index c359423085..b87fcf2546 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -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 getSupportedShortcuts() { if (mHotseatPredictionController != null) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 445ebc08eb..db2daeefcc 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -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); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index beaafda301..b53889a3d8 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1703,8 +1703,8 @@ public class Workspace extends PagedView 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;