Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +2 −2 Original line number Diff line number Diff line Loading @@ -842,8 +842,8 @@ public abstract class WMShellModule { @WMSingleton @Provides static ReturnToDragStartAnimator provideReturnToDragStartAnimator( Context context, InteractionJankMonitor interactionJankMonitor) { return new ReturnToDragStartAnimator(context, interactionJankMonitor); InteractionJankMonitor interactionJankMonitor) { return new ReturnToDragStartAnimator(interactionJankMonitor); } @WMSingleton Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +26 −6 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_NONE import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_FRONT import android.widget.Toast import android.window.DesktopModeFlags import android.window.DesktopModeFlags.DISABLE_NON_RESIZABLE_APP_SNAP_RESIZE import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY Loading Loading @@ -877,7 +878,6 @@ class DesktopTasksController( taskSurface, startBounds = currentDragBounds, endBounds = containerBounds, isResizable = taskInfo.isResizeable ) } return Loading Loading @@ -1012,7 +1012,6 @@ class DesktopTasksController( taskSurface, startBounds = currentDragBounds, endBounds = destinationBounds, isResizable = taskInfo.isResizeable, ) } return Loading Loading @@ -1046,7 +1045,13 @@ class DesktopTasksController( taskSurface, startBounds = currentDragBounds, endBounds = dragStartBounds, isResizable = taskInfo.isResizeable, doOnEnd = { Toast.makeText( context, com.android.wm.shell.R.string.desktop_mode_non_resizable_snap_text, Toast.LENGTH_SHORT ).show() }, ) } else { val resizeTrigger = if (position == SnapPosition.LEFT) { Loading Loading @@ -1984,17 +1989,32 @@ class DesktopTasksController( ) } IndicatorType.NO_INDICATOR -> { // Create a copy so that we can animate from the current bounds if we end up having // to snap the surface back without a WCT change. val destinationBounds = Rect(currentDragBounds) // If task bounds are outside valid drag area, snap them inward DragPositioningCallbackUtility.snapTaskBoundsIfNecessary( currentDragBounds, destinationBounds, validDragArea ) if (currentDragBounds == dragStartBounds) return if (destinationBounds == dragStartBounds) { // There's no actual difference between the start and end bounds, so while a // WCT change isn't needed, the dragged surface still needs to be snapped back // to its original location. releaseVisualIndicator() returnToDragStartAnimator.start( taskInfo.taskId, taskSurface, startBounds = currentDragBounds, endBounds = dragStartBounds, ) return } // Update task bounds so that the task position will match the position of its leash val wct = WindowContainerTransaction() wct.setBounds(taskInfo.token, currentDragBounds) wct.setBounds(taskInfo.token, destinationBounds) transitions.startTransition(TRANSIT_CHANGE, wct, null) releaseVisualIndicator() Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ReturnToDragStartAnimator.kt +4 −14 Original line number Diff line number Diff line Loading @@ -19,28 +19,24 @@ package com.android.wm.shell.desktopmode import android.animation.Animator import android.animation.RectEvaluator import android.animation.ValueAnimator import android.content.Context import android.graphics.Rect import android.view.SurfaceControl import android.widget.Toast import androidx.core.animation.addListener import com.android.internal.jank.Cuj import com.android.internal.jank.InteractionJankMonitor import com.android.wm.shell.R import com.android.wm.shell.windowdecor.OnTaskRepositionAnimationListener import java.util.function.Supplier /** Animates the task surface moving from its current drag position to its pre-drag position. */ class ReturnToDragStartAnimator( private val context: Context, private val transactionSupplier: Supplier<SurfaceControl.Transaction>, private val interactionJankMonitor: InteractionJankMonitor ) { private var boundsAnimator: Animator? = null private lateinit var taskRepositionAnimationListener: OnTaskRepositionAnimationListener constructor(context: Context, interactionJankMonitor: InteractionJankMonitor) : this(context, Supplier { SurfaceControl.Transaction() }, interactionJankMonitor) constructor(interactionJankMonitor: InteractionJankMonitor) : this(Supplier { SurfaceControl.Transaction() }, interactionJankMonitor) /** Sets a listener for the start and end of the reposition animation. */ fun setTaskRepositionAnimationListener(listener: OnTaskRepositionAnimationListener) { Loading @@ -53,7 +49,7 @@ class ReturnToDragStartAnimator( taskSurface: SurfaceControl, startBounds: Rect, endBounds: Rect, isResizable: Boolean doOnEnd: (() -> Unit)? = null, ) { val tx = transactionSupplier.get() Loading Loading @@ -87,13 +83,7 @@ class ReturnToDragStartAnimator( .apply() taskRepositionAnimationListener.onAnimationEnd(taskId) boundsAnimator = null if (!isResizable) { Toast.makeText( context, R.string.desktop_mode_non_resizable_snap_text, Toast.LENGTH_SHORT ).show() } doOnEnd?.invoke() interactionJankMonitor.end(Cuj.CUJ_DESKTOP_MODE_SNAP_RESIZE) } ) Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt +0 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,6 @@ class DesktopTilingWindowDecoration( resizeMetadata.getLeash(), startBounds = currentBounds, endBounds = destinationBounds, isResizable = taskInfo.isResizeable, ) } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -3029,7 +3029,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(mockSurface), eq(currentDragBounds), eq(STABLE_BOUNDS), eq(true) anyOrNull(), ) } Loading Loading @@ -3344,7 +3344,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(mockSurface), eq(currentDragBounds), eq(bounds), eq(true) anyOrNull(), ) verify(desktopModeEventLogger, times(1)).logTaskResizingEnded( ResizeTrigger.SNAP_LEFT_MENU, Loading Loading @@ -3401,7 +3401,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(mockSurface), eq(currentDragBounds), eq(preDragBounds), eq(false) any(), ) verify(desktopModeEventLogger, never()).logTaskResizingStarted( any(), Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +2 −2 Original line number Diff line number Diff line Loading @@ -842,8 +842,8 @@ public abstract class WMShellModule { @WMSingleton @Provides static ReturnToDragStartAnimator provideReturnToDragStartAnimator( Context context, InteractionJankMonitor interactionJankMonitor) { return new ReturnToDragStartAnimator(context, interactionJankMonitor); InteractionJankMonitor interactionJankMonitor) { return new ReturnToDragStartAnimator(interactionJankMonitor); } @WMSingleton Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +26 −6 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_NONE import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_FRONT import android.widget.Toast import android.window.DesktopModeFlags import android.window.DesktopModeFlags.DISABLE_NON_RESIZABLE_APP_SNAP_RESIZE import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY Loading Loading @@ -877,7 +878,6 @@ class DesktopTasksController( taskSurface, startBounds = currentDragBounds, endBounds = containerBounds, isResizable = taskInfo.isResizeable ) } return Loading Loading @@ -1012,7 +1012,6 @@ class DesktopTasksController( taskSurface, startBounds = currentDragBounds, endBounds = destinationBounds, isResizable = taskInfo.isResizeable, ) } return Loading Loading @@ -1046,7 +1045,13 @@ class DesktopTasksController( taskSurface, startBounds = currentDragBounds, endBounds = dragStartBounds, isResizable = taskInfo.isResizeable, doOnEnd = { Toast.makeText( context, com.android.wm.shell.R.string.desktop_mode_non_resizable_snap_text, Toast.LENGTH_SHORT ).show() }, ) } else { val resizeTrigger = if (position == SnapPosition.LEFT) { Loading Loading @@ -1984,17 +1989,32 @@ class DesktopTasksController( ) } IndicatorType.NO_INDICATOR -> { // Create a copy so that we can animate from the current bounds if we end up having // to snap the surface back without a WCT change. val destinationBounds = Rect(currentDragBounds) // If task bounds are outside valid drag area, snap them inward DragPositioningCallbackUtility.snapTaskBoundsIfNecessary( currentDragBounds, destinationBounds, validDragArea ) if (currentDragBounds == dragStartBounds) return if (destinationBounds == dragStartBounds) { // There's no actual difference between the start and end bounds, so while a // WCT change isn't needed, the dragged surface still needs to be snapped back // to its original location. releaseVisualIndicator() returnToDragStartAnimator.start( taskInfo.taskId, taskSurface, startBounds = currentDragBounds, endBounds = dragStartBounds, ) return } // Update task bounds so that the task position will match the position of its leash val wct = WindowContainerTransaction() wct.setBounds(taskInfo.token, currentDragBounds) wct.setBounds(taskInfo.token, destinationBounds) transitions.startTransition(TRANSIT_CHANGE, wct, null) releaseVisualIndicator() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ReturnToDragStartAnimator.kt +4 −14 Original line number Diff line number Diff line Loading @@ -19,28 +19,24 @@ package com.android.wm.shell.desktopmode import android.animation.Animator import android.animation.RectEvaluator import android.animation.ValueAnimator import android.content.Context import android.graphics.Rect import android.view.SurfaceControl import android.widget.Toast import androidx.core.animation.addListener import com.android.internal.jank.Cuj import com.android.internal.jank.InteractionJankMonitor import com.android.wm.shell.R import com.android.wm.shell.windowdecor.OnTaskRepositionAnimationListener import java.util.function.Supplier /** Animates the task surface moving from its current drag position to its pre-drag position. */ class ReturnToDragStartAnimator( private val context: Context, private val transactionSupplier: Supplier<SurfaceControl.Transaction>, private val interactionJankMonitor: InteractionJankMonitor ) { private var boundsAnimator: Animator? = null private lateinit var taskRepositionAnimationListener: OnTaskRepositionAnimationListener constructor(context: Context, interactionJankMonitor: InteractionJankMonitor) : this(context, Supplier { SurfaceControl.Transaction() }, interactionJankMonitor) constructor(interactionJankMonitor: InteractionJankMonitor) : this(Supplier { SurfaceControl.Transaction() }, interactionJankMonitor) /** Sets a listener for the start and end of the reposition animation. */ fun setTaskRepositionAnimationListener(listener: OnTaskRepositionAnimationListener) { Loading @@ -53,7 +49,7 @@ class ReturnToDragStartAnimator( taskSurface: SurfaceControl, startBounds: Rect, endBounds: Rect, isResizable: Boolean doOnEnd: (() -> Unit)? = null, ) { val tx = transactionSupplier.get() Loading Loading @@ -87,13 +83,7 @@ class ReturnToDragStartAnimator( .apply() taskRepositionAnimationListener.onAnimationEnd(taskId) boundsAnimator = null if (!isResizable) { Toast.makeText( context, R.string.desktop_mode_non_resizable_snap_text, Toast.LENGTH_SHORT ).show() } doOnEnd?.invoke() interactionJankMonitor.end(Cuj.CUJ_DESKTOP_MODE_SNAP_RESIZE) } ) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingWindowDecoration.kt +0 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,6 @@ class DesktopTilingWindowDecoration( resizeMetadata.getLeash(), startBounds = currentBounds, endBounds = destinationBounds, isResizable = taskInfo.isResizeable, ) } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -3029,7 +3029,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(mockSurface), eq(currentDragBounds), eq(STABLE_BOUNDS), eq(true) anyOrNull(), ) } Loading Loading @@ -3344,7 +3344,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(mockSurface), eq(currentDragBounds), eq(bounds), eq(true) anyOrNull(), ) verify(desktopModeEventLogger, times(1)).logTaskResizingEnded( ResizeTrigger.SNAP_LEFT_MENU, Loading Loading @@ -3401,7 +3401,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(mockSurface), eq(currentDragBounds), eq(preDragBounds), eq(false) any(), ) verify(desktopModeEventLogger, never()).logTaskResizingStarted( any(), Loading