diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index df77f8778e..7a13b89d25 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -44,7 +45,7 @@ import com.android.systemui.shared.recents.model.Task; /** * Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps. */ -public class TaskbarView extends LinearLayout { +public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconParent { private final ColorDrawable mBackgroundDrawable; private final int mItemMarginLeftRight; @@ -69,6 +70,8 @@ public class TaskbarView extends LinearLayout { private View mDelegateView; private boolean mIsDraggingItem; + // Only non-null when the corresponding Folder is open. + private @Nullable FolderIcon mLeaveBehindFolderIcon; public TaskbarView(@NonNull Context context) { this(context, null); @@ -387,6 +390,33 @@ public class TaskbarView extends LinearLayout { return mIsDraggingItem; } + // FolderIconParent implemented methods. + + @Override + public void drawFolderLeaveBehindForIcon(FolderIcon child) { + mLeaveBehindFolderIcon = child; + invalidate(); + } + + @Override + public void clearFolderLeaveBehind(FolderIcon child) { + mLeaveBehindFolderIcon = null; + invalidate(); + } + + // End FolderIconParent implemented methods. + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (mLeaveBehindFolderIcon != null) { + canvas.save(); + canvas.translate(mLeaveBehindFolderIcon.getLeft(), mLeaveBehindFolderIcon.getTop()); + mLeaveBehindFolderIcon.getFolderBackground().drawLeaveBehind(canvas); + canvas.restore(); + } + } + private View inflate(@LayoutRes int layoutResId) { TaskbarActivityContext taskbarActivityContext = ActivityContext.lookupContext(getContext()); return taskbarActivityContext.getLayoutInflater().inflate(layoutResId, this, false); diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index 1c5081cfca..eab8272431 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -26,10 +26,11 @@ import android.view.View; import android.view.ViewGroup; import com.android.launcher3.CellLayout.ContainerType; +import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.widget.LauncherAppWidgetHostView; -public class ShortcutAndWidgetContainer extends ViewGroup { +public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.FolderIconParent { static final String TAG = "ShortcutAndWidgetContainer"; // These are temporary variables to prevent having to allocate a new object just to @@ -228,4 +229,24 @@ public class ShortcutAndWidgetContainer extends ViewGroup { child.cancelLongPress(); } } + + @Override + public void drawFolderLeaveBehindForIcon(FolderIcon child) { + CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); + // While the folder is open, the position of the icon cannot change. + lp.canReorder = false; + if (mContainerType == CellLayout.HOTSEAT) { + CellLayout cl = (CellLayout) getParent(); + cl.setFolderLeaveBehindCell(lp.cellX, lp.cellY); + } + } + + @Override + public void clearFolderLeaveBehind(FolderIcon child) { + ((CellLayout.LayoutParams) child.getLayoutParams()).canReorder = true; + if (mContainerType == CellLayout.HOTSEAT) { + CellLayout cl = (CellLayout) getParent(); + cl.clearFolderLeaveBehind(); + } + } } diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 75d8f2296c..6b02021ed3 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -754,26 +754,14 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel } public void clearLeaveBehindIfExists() { - if (!(getLayoutParams() instanceof CellLayout.LayoutParams)) { - return; - } - ((CellLayout.LayoutParams) getLayoutParams()).canReorder = true; - if (isInHotseat()) { - CellLayout cl = (CellLayout) getParent().getParent(); - cl.clearFolderLeaveBehind(); + if (getParent() instanceof FolderIconParent) { + ((FolderIconParent) getParent()).clearFolderLeaveBehind(this); } } public void drawLeaveBehindIfExists() { - if (!(getLayoutParams() instanceof CellLayout.LayoutParams)) { - return; - } - CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams(); - // While the folder is open, the position of the icon cannot change. - lp.canReorder = false; - if (isInHotseat()) { - CellLayout cl = (CellLayout) getParent().getParent(); - cl.setFolderLeaveBehindCell(lp.cellX, lp.cellY); + if (getParent() instanceof FolderIconParent) { + ((FolderIconParent) getParent()).drawFolderLeaveBehindForIcon(this); } } @@ -842,4 +830,19 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel MAX_NUM_ITEMS_IN_PREVIEW); } } + + /** + * Interface that provides callbacks to a parent ViewGroup that hosts this FolderIcon. + */ + public interface FolderIconParent { + /** + * Tells the FolderIconParent to draw a "leave-behind" when the Folder is open and leaving a + * gap where the FolderIcon would be when the Folder is closed. + */ + void drawFolderLeaveBehindForIcon(FolderIcon child); + /** + * Tells the FolderIconParent to stop drawing the "leave-behind" as the Folder is closed. + */ + void clearFolderLeaveBehind(FolderIcon child); + } }