Notify predictor on appIcon convert to folder
Bug:148749638
Test:Manual
Change-Id: I7eed1f309197479f708a23029c04106af0ac536f
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 109439f..cc6ec69 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.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 @@
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 c359423..b87fcf2 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.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;
@@ -169,6 +172,16 @@
}
@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) {
return Stream.concat(super.getSupportedShortcuts(),
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 445ebc0..db2daee 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1721,8 +1721,11 @@
}
}
- 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 @@
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 beaafda..b53889a 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1703,8 +1703,8 @@
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;