Merge "Drag and drop from the search view on the overview screen." into main

This commit is contained in:
Treehugger Robot
2025-03-11 18:26:48 -07:00
committed by Android (Google) Code Review
8 changed files with 43 additions and 17 deletions
@@ -260,6 +260,7 @@ public class TaskbarControllers {
mAreAllControllersInitialized = false;
mSharedState = null;
taskbarDragController.onDestroy();
navbarButtonsViewController.onDestroy();
uiController.onDestroy();
rotationButtonController.onDestroy();
@@ -280,7 +281,6 @@ public class TaskbarControllers {
taskbarStashController.onDestroy();
bubbleControllers.ifPresent(controllers -> controllers.onDestroy());
taskbarDesktopModeController.onDestroy();
mControllersToLog = null;
mBackgroundRendererControllers = null;
}
@@ -131,6 +131,14 @@ public class TaskbarDragController extends DragController<BaseTaskbarContext> 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) {
@@ -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()
@@ -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);
}
/**
@@ -67,6 +67,11 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
onViewCreated();
}
/** Called when the controller is destroyed. */
public void onDestroy() {
mDragController.onDestroy();
}
public @Nullable TaskbarSearchSessionController getSearchSessionController() {
return mSearchSessionController;
}
@@ -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;
}
+6 -1
View File
@@ -100,6 +100,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;
/**
@@ -276,8 +277,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());
@@ -540,7 +540,7 @@ public abstract class DragController<T extends ActivityContext>
accepted = true;
}
}
final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null;
final View dropTargetAsView = dropTarget.getDropView();
dispatchDropComplete(dropTargetAsView, accepted);
}