Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f6a9165 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Expand bubble on the side it was released" into main

parents d67f2b30 83b7e7b9
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ enum class BubbleBarLocation : Parcelable {
        UpdateSource.A11Y_ACTION_BAR,
        UpdateSource.A11Y_ACTION_BUBBLE,
        UpdateSource.A11Y_ACTION_EXP_VIEW,
        UpdateSource.APP_ICON_DRAG
        UpdateSource.APP_ICON_DRAG,
        UpdateSource.DRAG_TASK,
    )
    @Retention(AnnotationRetention.SOURCE)
    annotation class UpdateSource {
@@ -95,6 +96,9 @@ enum class BubbleBarLocation : Parcelable {

            /** Location changed from dragging the application icon to the bubble bar */
            const val APP_ICON_DRAG = 7

            /** Location changed from dragging a running task to the bubble bar */
            const val DRAG_TASK = 8
        }
    }
}
+13 −1
Original line number Diff line number Diff line
@@ -845,6 +845,10 @@ public class BubbleController implements ConfigurationChangeListener,
                mLogger.log(onLeft ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_APP_ICON_DROP
                        : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_APP_ICON_DROP);
                break;
            case BubbleBarLocation.UpdateSource.DRAG_TASK:
                mLogger.log(onLeft ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_TASK
                        : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_TASK);
                break;
        }
    }

@@ -1598,13 +1602,21 @@ public class BubbleController implements ConfigurationChangeListener,
        if (!BubbleAnythingFlagHelper.enableBubbleToFullscreen()) return;
        Bubble b = mBubbleData.getOrCreateBubble(taskInfo); // Removes from overflow
        ProtoLog.v(WM_SHELL_BUBBLES, "expandStackAndSelectBubble - intent=%s", taskInfo.taskId);
        BubbleBarLocation location = null;
        if (dragData != null) {
            location =
                    dragData.isReleasedOnLeft() ? BubbleBarLocation.LEFT : BubbleBarLocation.RIGHT;
        }
        if (b.isInflated()) {
            mBubbleData.setSelectedBubbleAndExpandStack(b);
            mBubbleData.setSelectedBubbleAndExpandStack(b, location);
            if (dragData != null && dragData.getPendingWct() != null) {
                mTransitions.startTransition(TRANSIT_CHANGE,
                        dragData.getPendingWct(), /* handler= */ null);
            }
        } else {
            if (location != null) {
                setBubbleBarLocation(location, BubbleBarLocation.UpdateSource.DRAG_TASK);
            }
            b.enable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
            // Lazy init stack view when a bubble is created
            ensureBubbleViewsAndWindowCreated();
+6 −0
Original line number Diff line number Diff line
@@ -156,6 +156,12 @@ public class BubbleLogger {
        @UiEvent(doc = "while bubble bar is expanded, switch to another/existing bubble")
        BUBBLE_BAR_BUBBLE_SWITCHED(1977),

        @UiEvent(doc = "bubble bar moved to the left edge of the screen by dragging a task")
        BUBBLE_BAR_MOVED_LEFT_DRAG_TASK(2146),

        @UiEvent(doc = "bubble bar moved to the right edge of the screen by dragging a task")
        BUBBLE_BAR_MOVED_RIGHT_DRAG_TASK(2147),

        // endregion
        ;

+12 −1
Original line number Diff line number Diff line
@@ -156,14 +156,18 @@ public class BubbleTransitions {
    public static class DragData {
        private final Rect mBounds;
        private final WindowContainerTransaction mPendingWct;
        private final boolean mReleasedOnLeft;

        /**
         * @param bounds bounds of the dragged task when the drag was released
         * @param wct pending operations to be applied when finishing the drag
         * @param releasedOnLeft true if the bubble was released in the left drop target
         */
        public DragData(@Nullable Rect bounds, @Nullable WindowContainerTransaction wct) {
        public DragData(@Nullable Rect bounds, @Nullable WindowContainerTransaction wct,
                boolean releasedOnLeft) {
            mBounds = bounds;
            mPendingWct = wct;
            mReleasedOnLeft = releasedOnLeft;
        }

        /**
@@ -181,6 +185,13 @@ public class BubbleTransitions {
        public WindowContainerTransaction getPendingWct() {
            return mPendingWct;
        }

        /**
         * @return true if the bubble was released in the left drop target
         */
        public boolean isReleasedOnLeft() {
            return mReleasedOnLeft;
        }
    }

    /**
+11 −7
Original line number Diff line number Diff line
@@ -257,8 +257,8 @@ sealed class DragToDesktopTransitionHandler(
                // Animation is handled by BubbleController
                val wct = WindowContainerTransaction()
                restoreWindowOrder(wct, state)
                // TODO(b/388851898): pass along information about left or right side
                requestBubbleFromScaledTask(wct)
                val onLeft = cancelState == CancelState.CANCEL_BUBBLE_LEFT
                requestBubbleFromScaledTask(wct, onLeft)
            }
        } else {
            // There's no dragged task, this can happen when the "cancel" happened too quickly
@@ -318,23 +318,27 @@ sealed class DragToDesktopTransitionHandler(
        splitScreenController.requestEnterSplitSelect(taskInfo, wct, splitPosition, taskBounds)
    }

    private fun requestBubbleFromScaledTask(wct: WindowContainerTransaction) {
    private fun requestBubbleFromScaledTask(wct: WindowContainerTransaction, onLeft: Boolean) {
        // TODO(b/391928049): update density once we can drag from desktop to bubble
        val state = requireTransitionState()
        val taskInfo = state.draggedTaskChange?.taskInfo ?: error("Expected non-null taskInfo")
        val taskBounds = getAnimatedTaskBounds()
        state.dragAnimator.cancelAnimator()
        requestBubble(wct, taskInfo, taskBounds)
        requestBubble(wct, taskInfo, onLeft, taskBounds)
    }

    private fun requestBubble(
        wct: WindowContainerTransaction,
        taskInfo: RunningTaskInfo,
        onLeft: Boolean,
        taskBounds: Rect = Rect(taskInfo.configuration.windowConfiguration.bounds),
    ) {
        val controller =
            bubbleController.orElseThrow { IllegalStateException("BubbleController not set") }
        controller.expandStackAndSelectBubble(taskInfo, BubbleTransitions.DragData(taskBounds, wct))
        controller.expandStackAndSelectBubble(
            taskInfo,
            BubbleTransitions.DragData(taskBounds, wct, onLeft),
        )
    }

    override fun startAnimation(
@@ -497,8 +501,8 @@ sealed class DragToDesktopTransitionHandler(
                state.draggedTaskChange?.taskInfo ?: error("Expected non-null task info.")
            val wct = WindowContainerTransaction()
            restoreWindowOrder(wct)
            // TODO(b/388851898): pass along information about left or right side
            requestBubble(wct, taskInfo)
            val onLeft = state.cancelState == CancelState.CANCEL_BUBBLE_LEFT
            requestBubble(wct, taskInfo, onLeft)
        }
        return true
    }
Loading