diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 6ca9385294..c18e3de504 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -257,6 +257,7 @@ public class TaskbarControllers { mAreAllControllersInitialized = false; mSharedState = null; + taskbarDragController.onDestroy(); navbarButtonsViewController.onDestroy(); uiController.onDestroy(); rotationButtonController.onDestroy(); @@ -277,7 +278,6 @@ public class TaskbarControllers { taskbarStashController.onDestroy(); bubbleControllers.ifPresent(controllers -> controllers.onDestroy()); taskbarDesktopModeController.onDestroy(); - mControllersToLog = null; mBackgroundRendererControllers = null; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index 1b516bef4d..eb1c8fcd26 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -132,6 +132,14 @@ public class TaskbarDragController extends DragController im public void init(TaskbarControllers controllers) { mControllers = controllers; + mControllers.bubbleControllers.ifPresent( + c -> c.bubbleBarViewController.addBubbleBarDropTargets(this)); + } + + /** Called when the controller is destroyed. */ + public void onDestroy() { + mControllers.bubbleControllers.ifPresent( + c -> c.bubbleBarViewController.removeBubbleBarDropTargets(this)); } public void setDisallowGlobalDrag(boolean disallowGlobalDrag) { diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt index 383f4d2020..24e7d99187 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarLocationDropTarget.kt @@ -60,8 +60,6 @@ class BubbleBarLocationDropTarget( override fun onDrop(dragObject: DropTarget.DragObject, options: DragOptions) { val itemInfo = dragObject.dragInfo ?: return - // TODO(b/397459664) : fix task bar icon animation after drop - // TODO(b/397459664) : update bubble bar location bubbleBarDragListener.onLauncherItemDroppedOverBubbleBarDragZone( bubbleBarLocation, itemInfo, @@ -77,8 +75,6 @@ class BubbleBarLocationDropTarget( } override fun onDragExit(dragObject: DropTarget.DragObject) { - // TODO(b/397459664) : fix the issue for no bubbles, when moving task bar icon out of - // the bubble bar drag zone drag ends and swipes gesture swipes the overview if (!isShowingDropTarget) return isShowingDropTarget = false bubbleBarDragListener.onLauncherItemDraggedOutsideBubbleBarDropZone() diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 2aa5925c4f..5fdbb1dcce 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -41,15 +41,16 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.app.animation.Interpolators; +import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; +import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.launcher3.taskbar.TaskbarControllers; -import com.android.launcher3.taskbar.TaskbarDragController; import com.android.launcher3.taskbar.TaskbarInsetsController; import com.android.launcher3.taskbar.TaskbarSharedState; import com.android.launcher3.taskbar.TaskbarStashController; @@ -144,6 +145,7 @@ public class BubbleBarViewController { @Override public void onLauncherItemDroppedOverBubbleBarDragZone(@NonNull BubbleBarLocation location, @NonNull ItemInfo itemInfo) { + AbstractFloatingView.closeAllOpenViews(mActivity); if (itemInfo instanceof WorkspaceItemInfo) { ShortcutInfo shortcutInfo = ((WorkspaceItemInfo) itemInfo).getDeepShortcutInfo(); if (shortcutInfo != null) { @@ -199,7 +201,6 @@ public class BubbleBarViewController { private BubbleBarFlyoutController mBubbleBarFlyoutController; private BubbleBarPinController mBubbleBarPinController; private TaskbarSharedState mTaskbarSharedState; - private TaskbarDragController mTaskbarDragController; private final BubbleBarLocationDropTarget mBubbleBarLeftDropTarget; private final BubbleBarLocationDropTarget mBubbleBarRightDropTarget; private final TimeSource mTimeSource = System::currentTimeMillis; @@ -236,7 +237,6 @@ public class BubbleBarViewController { /** Initializes controller. */ public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers, TaskbarViewPropertiesProvider taskbarViewPropertiesProvider) { - mTaskbarDragController = controllers.taskbarDragController; mTaskbarSharedState = controllers.getSharedState(); mBubbleStashController = bubbleControllers.bubbleStashController; mBubbleBarController = bubbleControllers.bubbleBarController; @@ -338,8 +338,18 @@ public class BubbleBarViewController { mBubbleBarController.updateBubbleBarLocation(location, source); } }; - mTaskbarDragController.addDropTarget(mBubbleBarLeftDropTarget); - mTaskbarDragController.addDropTarget(mBubbleBarRightDropTarget); + } + + /** Adds bubble bar locations drop zones to the drag controller. */ + public void addBubbleBarDropTargets(DragController dragController) { + dragController.addDropTarget(mBubbleBarLeftDropTarget); + dragController.addDropTarget(mBubbleBarRightDropTarget); + } + + /** Removes bubble bar locations drop zones to the drag controller. */ + public void removeBubbleBarDropTargets(DragController dragController) { + dragController.removeDropTarget(mBubbleBarLeftDropTarget); + dragController.removeDropTarget(mBubbleBarRightDropTarget); } /** Returns animated float property responsible for pinning transition animation. */ @@ -1356,8 +1366,6 @@ public class BubbleBarViewController { /** Called when the controller is destroyed. */ public void onDestroy() { adjustTaskbarAndHotseatToBubbleBarState(/*isBubbleBarExpanded = */false); - mTaskbarDragController.removeDropTarget(mBubbleBarLeftDropTarget); - mTaskbarDragController.removeDropTarget(mBubbleBarRightDropTarget); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java index 636d89bd55..ebb307b239 100644 --- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java @@ -66,6 +66,11 @@ public class TaskbarOverlayContext extends BaseTaskbarContext { mUiController = controllers.uiController; } + /** Called when the controller is destroyed. */ + public void onDestroy() { + mDragController.onDestroy(); + } + public @Nullable TaskbarSearchSessionController getSearchSessionController() { return mSearchSessionController; } diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java index 79cb748181..8b01e993dc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java +++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java @@ -150,9 +150,13 @@ public final class TaskbarOverlayController { /** Destroys the controller and any overlay window if present. */ public void onDestroy() { TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener); - Optional.ofNullable(mOverlayContext) - .map(c -> c.getSystemService(WindowManager.class)) - .ifPresent(m -> m.removeViewImmediate(mOverlayContext.getDragLayer())); + Optional.ofNullable(mOverlayContext).ifPresent(c -> { + c.onDestroy(); + WindowManager wm = c.getSystemService(WindowManager.class); + if (wm != null) { + wm.removeViewImmediate(mOverlayContext.getDragLayer()); + } + }); mOverlayContext = null; } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index cb3a0bc070..081aea7480 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -98,6 +98,7 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Objects; import java.util.function.Predicate; /** @@ -274,8 +275,12 @@ public final class Utilities { */ public static void mapCoordInSelfToDescendant(View descendant, View root, float[] coord) { sMatrix.reset(); + //TODO(b/307488755) when implemented this check should be removed + if (!Objects.equals(descendant.getWindowId(), root.getWindowId())) { + return; + } View v = descendant; - while(v != root) { + while (v != root) { sMatrix.postTranslate(-v.getScrollX(), -v.getScrollY()); sMatrix.postConcat(v.getMatrix()); sMatrix.postTranslate(v.getLeft(), v.getTop()); diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 613b4308eb..4127dd15ad 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -540,7 +540,7 @@ public abstract class DragController accepted = true; } } - final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null; + final View dropTargetAsView = dropTarget.getDropView(); dispatchDropComplete(dropTargetAsView, accepted); }