Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MoveToDesktopAnimator.kt +20 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ class MoveToDesktopAnimator @JvmOverloads constructor( get() = dragToDesktopAnimator.animatedValue as Float * startBounds.width() val scale: Float get() = dragToDesktopAnimator.animatedValue as Float private val mostRecentInput = PointF() private val dragToDesktopAnimator: ValueAnimator = ValueAnimator.ofFloat(1f, DRAG_FREEFORM_SCALE) .setDuration(ANIMATION_DURATION.toLong()) Loading @@ -40,8 +41,12 @@ class MoveToDesktopAnimator @JvmOverloads constructor( val t = SurfaceControl.Transaction() val cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context) addUpdateListener { setTaskPosition(mostRecentInput.x, mostRecentInput.y) t.setScale(taskSurface, scale, scale) .setCornerRadius(taskSurface, cornerRadius) .setScale(taskSurface, scale, scale) .setCornerRadius(taskSurface, cornerRadius) .setPosition(taskSurface, position.x, position.y) .apply() } } Loading Loading @@ -78,18 +83,27 @@ class MoveToDesktopAnimator @JvmOverloads constructor( // allow dragging beyond its stage across any region of the display. Because of that, the // rawX/Y are more true to where the gesture is on screen and where the surface should be // positioned. position.x = ev.rawX - animatedTaskWidth / 2 position.y = ev.rawY mostRecentInput.set(ev.rawX, ev.rawY) if (!allowSurfaceChangesOnMove) { // If animator is running, allow it to set scale and position at the same time. if (!allowSurfaceChangesOnMove || dragToDesktopAnimator.isRunning) { return } setTaskPosition(ev.rawX, ev.rawY) val t = transactionFactory() t.setPosition(taskSurface, position.x, position.y) t.apply() } /** * Calculates the top left corner of task from input coordinates. * Top left will be needed for the resulting surface control transaction. */ private fun setTaskPosition(x: Float, y: Float) { position.x = x - animatedTaskWidth / 2 position.y = y } /** * Cancels the animation, intended to be used when another animator will take over. */ Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MoveToDesktopAnimator.kt +20 −6 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ class MoveToDesktopAnimator @JvmOverloads constructor( get() = dragToDesktopAnimator.animatedValue as Float * startBounds.width() val scale: Float get() = dragToDesktopAnimator.animatedValue as Float private val mostRecentInput = PointF() private val dragToDesktopAnimator: ValueAnimator = ValueAnimator.ofFloat(1f, DRAG_FREEFORM_SCALE) .setDuration(ANIMATION_DURATION.toLong()) Loading @@ -40,8 +41,12 @@ class MoveToDesktopAnimator @JvmOverloads constructor( val t = SurfaceControl.Transaction() val cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context) addUpdateListener { setTaskPosition(mostRecentInput.x, mostRecentInput.y) t.setScale(taskSurface, scale, scale) .setCornerRadius(taskSurface, cornerRadius) .setScale(taskSurface, scale, scale) .setCornerRadius(taskSurface, cornerRadius) .setPosition(taskSurface, position.x, position.y) .apply() } } Loading Loading @@ -78,18 +83,27 @@ class MoveToDesktopAnimator @JvmOverloads constructor( // allow dragging beyond its stage across any region of the display. Because of that, the // rawX/Y are more true to where the gesture is on screen and where the surface should be // positioned. position.x = ev.rawX - animatedTaskWidth / 2 position.y = ev.rawY mostRecentInput.set(ev.rawX, ev.rawY) if (!allowSurfaceChangesOnMove) { // If animator is running, allow it to set scale and position at the same time. if (!allowSurfaceChangesOnMove || dragToDesktopAnimator.isRunning) { return } setTaskPosition(ev.rawX, ev.rawY) val t = transactionFactory() t.setPosition(taskSurface, position.x, position.y) t.apply() } /** * Calculates the top left corner of task from input coordinates. * Top left will be needed for the resulting surface control transaction. */ private fun setTaskPosition(x: Float, y: Float) { position.x = x - animatedTaskWidth / 2 position.y = y } /** * Cancels the animation, intended to be used when another animator will take over. */ Loading