Close Folder when an item is auto added to it.
This can happen when items (as part of a Work Profile) are auto added
to the Work profile Folder.
Bug: 35628160
Change-Id: I29d3b277b0e9cd4bb238fb5aff9a52c6b9e764f8
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java
index 2c69d0a..ffddccf 100644
--- a/src/com/android/launcher3/FolderInfo.java
+++ b/src/com/android/launcher3/FolderInfo.java
@@ -114,11 +114,18 @@
}
}
+ public void prepareAutoAdd() {
+ for (int i = 0; i < listeners.size(); i++) {
+ listeners.get(i).prepareAutoAdd();
+ }
+ }
+
public interface FolderListener {
public void onAdd(ShortcutInfo item);
public void onRemove(ShortcutInfo item);
public void onTitleChanged(CharSequence title);
public void onItemsChanged(boolean animate);
+ public void prepareAutoAdd();
}
public boolean hasOption(int optionFlag) {
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 4ad13d0..2695594 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -554,7 +554,7 @@
mFolderIcon.growAndFadeOut();
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
- int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
+ int width = getFolderWidth();
int height = getFolderHeight();
float transX = - 0.075f * (width / 2 - getPivotX());
@@ -1047,7 +1047,7 @@
DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
- int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
+ int width = getFolderWidth();
int height = getFolderHeight();
float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, sTempRect);
@@ -1121,6 +1121,10 @@
return Math.max(mContent.getDesiredWidth(), MIN_CONTENT_DIMEN);
}
+ private int getFolderWidth() {
+ return getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
+ }
+
private int getFolderHeight() {
return getFolderHeight(getContentAreaHeight());
}
@@ -1407,6 +1411,11 @@
updateTextViewFocus();
}
+ @Override
+ public void prepareAutoAdd() {
+ close(false);
+ }
+
public void onTitleChanged(CharSequence title) {
}
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 96d5675..fce902e 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -981,6 +981,10 @@
}
@Override
+ public void prepareAutoAdd() {
+ }
+
+ @Override
public void onAdd(ShortcutInfo item) {
int oldCount = mBadgeInfo.getNotificationCount();
mBadgeInfo.addBadgeInfo(mLauncher.getPopupDataProvider().getBadgeInfoForItem(item));
diff --git a/src/com/android/launcher3/util/ManagedProfileHeuristic.java b/src/com/android/launcher3/util/ManagedProfileHeuristic.java
index 577d19f..a1c2f0a 100644
--- a/src/com/android/launcher3/util/ManagedProfileHeuristic.java
+++ b/src/com/android/launcher3/util/ManagedProfileHeuristic.java
@@ -163,6 +163,7 @@
@Override
public void run() {
+ workFolder.prepareAutoAdd();
for (ShortcutInfo info : workFolderApps) {
workFolder.add(info, false);
}