Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MaximizeMenu.kt +97 −17 Original line number Original line Diff line number Diff line Loading @@ -60,6 +60,7 @@ import androidx.core.animation.addListener import com.android.wm.shell.R import com.android.wm.shell.R import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.animation.Interpolators.EMPHASIZED_DECELERATE import com.android.wm.shell.animation.Interpolators.EMPHASIZED_DECELERATE import com.android.wm.shell.animation.Interpolators.FAST_OUT_LINEAR_IN import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalViewHostViewContainer import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalViewHostViewContainer Loading Loading @@ -120,8 +121,9 @@ class MaximizeMenu( /** Closes the maximize window and releases its view. */ /** Closes the maximize window and releases its view. */ fun close() { fun close() { maximizeMenuView?.cancelAnimation() maximizeMenuView?.animateCloseMenu { maximizeMenu?.releaseView() maximizeMenu?.releaseView() } maximizeMenu = null maximizeMenu = null maximizeMenuView = null maximizeMenuView = null } } Loading Loading @@ -255,7 +257,7 @@ class MaximizeMenu( .getDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_buttons_fill_radius) .getDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_buttons_fill_radius) private val hoverTempRect = Rect() private val hoverTempRect = Rect() private val openMenuAnimatorSet = AnimatorSet() private var menuAnimatorSet: AnimatorSet? = null private lateinit var taskInfo: RunningTaskInfo private lateinit var taskInfo: RunningTaskInfo private lateinit var style: MenuStyle private lateinit var style: MenuStyle Loading Loading @@ -346,15 +348,16 @@ class MaximizeMenu( fun animateOpenMenu() { fun animateOpenMenu() { maximizeButton.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeButton.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_HARDWARE, null) openMenuAnimatorSet.playTogether( menuAnimatorSet = AnimatorSet() menuAnimatorSet?.playTogether( ObjectAnimator.ofFloat(rootView, SCALE_Y, STARTING_MENU_HEIGHT_SCALE, 1f) ObjectAnimator.ofFloat(rootView, SCALE_Y, STARTING_MENU_HEIGHT_SCALE, 1f) .apply { .apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE }, }, ValueAnimator.ofFloat(STARTING_MENU_HEIGHT_SCALE, 1f) ValueAnimator.ofFloat(STARTING_MENU_HEIGHT_SCALE, 1f) .apply { .apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE addUpdateListener { addUpdateListener { // Animate padding so that controls stay pinned to the bottom of // Animate padding so that controls stay pinned to the bottom of Loading @@ -367,7 +370,7 @@ class MaximizeMenu( } } }, }, ValueAnimator.ofFloat(1 / STARTING_MENU_HEIGHT_SCALE, 1f).apply { ValueAnimator.ofFloat(1 / STARTING_MENU_HEIGHT_SCALE, 1f).apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE addUpdateListener { addUpdateListener { // Scale up the children of the maximize menu so that the menu // Scale up the children of the maximize menu so that the menu Loading @@ -381,7 +384,7 @@ class MaximizeMenu( }, }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight, 0f).apply { (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight, 0f).apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE }, }, ObjectAnimator.ofInt(rootView.background, "alpha", ObjectAnimator.ofInt(rootView.background, "alpha", Loading @@ -391,7 +394,7 @@ class MaximizeMenu( ValueAnimator.ofFloat(0f, 1f) ValueAnimator.ofFloat(0f, 1f) .apply { .apply { duration = ALPHA_ANIMATION_DURATION_MS duration = ALPHA_ANIMATION_DURATION_MS startDelay = CONTROLS_ALPHA_ANIMATION_DELAY_MS startDelay = CONTROLS_ALPHA_OPEN_MENU_ANIMATION_DELAY_MS addUpdateListener { addUpdateListener { val value = animatedValue as Float val value = animatedValue as Float maximizeButton.alpha = value maximizeButton.alpha = value Loading @@ -403,21 +406,96 @@ class MaximizeMenu( ObjectAnimator.ofFloat(rootView, TRANSLATION_Z, MENU_Z_TRANSLATION) ObjectAnimator.ofFloat(rootView, TRANSLATION_Z, MENU_Z_TRANSLATION) .apply { .apply { duration = ELEVATION_ANIMATION_DURATION_MS duration = ELEVATION_ANIMATION_DURATION_MS startDelay = CONTROLS_ALPHA_ANIMATION_DELAY_MS startDelay = CONTROLS_ALPHA_OPEN_MENU_ANIMATION_DELAY_MS } ) menuAnimatorSet?.addListener( onEnd = { maximizeButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_SOFTWARE, null) } ) menuAnimatorSet?.start() } /** Animate the closing of the menu */ fun animateCloseMenu(onEnd: (() -> Unit)) { maximizeButton.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_HARDWARE, null) cancelAnimation() menuAnimatorSet = AnimatorSet() menuAnimatorSet?.playTogether( ObjectAnimator.ofFloat(rootView, SCALE_Y, 1f, STARTING_MENU_HEIGHT_SCALE) .apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN }, ValueAnimator.ofFloat(1f, STARTING_MENU_HEIGHT_SCALE) .apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN addUpdateListener { // Animate padding so that controls stay pinned to the bottom of // the menu. val value = animatedValue as Float val topPadding = menuPadding - ((1 - value) * menuHeight).toInt() container.setPadding(menuPadding, topPadding, menuPadding, menuPadding) } }, ValueAnimator.ofFloat(1f, 1 / STARTING_MENU_HEIGHT_SCALE).apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN addUpdateListener { // Scale up the children of the maximize menu so that the menu // scale is cancelled out and only the background is scaled. val value = animatedValue as Float maximizeButton.scaleY = value snapButtonsLayout.scaleY = value maximizeText.scaleY = value snapWindowText.scaleY = value } }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, 0f, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight).apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN }, ObjectAnimator.ofInt(rootView.background, "alpha", MAX_DRAWABLE_ALPHA_VALUE, 0).apply { startDelay = CONTAINER_ALPHA_CLOSE_MENU_ANIMATION_DELAY_MS duration = ALPHA_ANIMATION_DURATION_MS }, ValueAnimator.ofFloat(1f, 0f) .apply { duration = ALPHA_ANIMATION_DURATION_MS addUpdateListener { val value = animatedValue as Float maximizeButton.alpha = value snapButtonsLayout.alpha = value maximizeText.alpha = value snapWindowText.alpha = value } }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Z, MENU_Z_TRANSLATION, 0f) .apply { duration = ELEVATION_ANIMATION_DURATION_MS } } ) ) openMenuAnimatorSet.addListener( menuAnimatorSet?.addListener( onEnd = { onEnd = { maximizeButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_SOFTWARE, null) onEnd?.invoke() } } ) ) openMenuAnimatorSet.start() menuAnimatorSet?.start() } } /** Cancel the open menu animation. */ /** Cancel the menu animation. */ fun cancelAnimation() { private fun cancelAnimation() { openMenuAnimatorSet.cancel() menuAnimatorSet?.cancel() } } /** Update the view state to a new snap to half selection. */ /** Update the view state to a new snap to half selection. */ Loading Loading @@ -645,9 +723,11 @@ class MaximizeMenu( private const val ALPHA_ANIMATION_DURATION_MS = 50L private const val ALPHA_ANIMATION_DURATION_MS = 50L private const val MAX_DRAWABLE_ALPHA_VALUE = 255 private const val MAX_DRAWABLE_ALPHA_VALUE = 255 private const val STARTING_MENU_HEIGHT_SCALE = 0.8f private const val STARTING_MENU_HEIGHT_SCALE = 0.8f private const val MENU_HEIGHT_ANIMATION_DURATION_MS = 300L private const val OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS = 300L private const val CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS = 200L private const val ELEVATION_ANIMATION_DURATION_MS = 50L private const val ELEVATION_ANIMATION_DURATION_MS = 50L private const val CONTROLS_ALPHA_ANIMATION_DELAY_MS = 33L private const val CONTROLS_ALPHA_OPEN_MENU_ANIMATION_DELAY_MS = 33L private const val CONTAINER_ALPHA_CLOSE_MENU_ANIMATION_DELAY_MS = 33L private const val MENU_Z_TRANSLATION = 1f private const val MENU_Z_TRANSLATION = 1f } } } } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MaximizeMenu.kt +97 −17 Original line number Original line Diff line number Diff line Loading @@ -60,6 +60,7 @@ import androidx.core.animation.addListener import com.android.wm.shell.R import com.android.wm.shell.R import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.animation.Interpolators.EMPHASIZED_DECELERATE import com.android.wm.shell.animation.Interpolators.EMPHASIZED_DECELERATE import com.android.wm.shell.animation.Interpolators.FAST_OUT_LINEAR_IN import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalViewHostViewContainer import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalViewHostViewContainer Loading Loading @@ -120,8 +121,9 @@ class MaximizeMenu( /** Closes the maximize window and releases its view. */ /** Closes the maximize window and releases its view. */ fun close() { fun close() { maximizeMenuView?.cancelAnimation() maximizeMenuView?.animateCloseMenu { maximizeMenu?.releaseView() maximizeMenu?.releaseView() } maximizeMenu = null maximizeMenu = null maximizeMenuView = null maximizeMenuView = null } } Loading Loading @@ -255,7 +257,7 @@ class MaximizeMenu( .getDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_buttons_fill_radius) .getDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_buttons_fill_radius) private val hoverTempRect = Rect() private val hoverTempRect = Rect() private val openMenuAnimatorSet = AnimatorSet() private var menuAnimatorSet: AnimatorSet? = null private lateinit var taskInfo: RunningTaskInfo private lateinit var taskInfo: RunningTaskInfo private lateinit var style: MenuStyle private lateinit var style: MenuStyle Loading Loading @@ -346,15 +348,16 @@ class MaximizeMenu( fun animateOpenMenu() { fun animateOpenMenu() { maximizeButton.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeButton.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_HARDWARE, null) openMenuAnimatorSet.playTogether( menuAnimatorSet = AnimatorSet() menuAnimatorSet?.playTogether( ObjectAnimator.ofFloat(rootView, SCALE_Y, STARTING_MENU_HEIGHT_SCALE, 1f) ObjectAnimator.ofFloat(rootView, SCALE_Y, STARTING_MENU_HEIGHT_SCALE, 1f) .apply { .apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE }, }, ValueAnimator.ofFloat(STARTING_MENU_HEIGHT_SCALE, 1f) ValueAnimator.ofFloat(STARTING_MENU_HEIGHT_SCALE, 1f) .apply { .apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE addUpdateListener { addUpdateListener { // Animate padding so that controls stay pinned to the bottom of // Animate padding so that controls stay pinned to the bottom of Loading @@ -367,7 +370,7 @@ class MaximizeMenu( } } }, }, ValueAnimator.ofFloat(1 / STARTING_MENU_HEIGHT_SCALE, 1f).apply { ValueAnimator.ofFloat(1 / STARTING_MENU_HEIGHT_SCALE, 1f).apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE addUpdateListener { addUpdateListener { // Scale up the children of the maximize menu so that the menu // Scale up the children of the maximize menu so that the menu Loading @@ -381,7 +384,7 @@ class MaximizeMenu( }, }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight, 0f).apply { (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight, 0f).apply { duration = MENU_HEIGHT_ANIMATION_DURATION_MS duration = OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = EMPHASIZED_DECELERATE interpolator = EMPHASIZED_DECELERATE }, }, ObjectAnimator.ofInt(rootView.background, "alpha", ObjectAnimator.ofInt(rootView.background, "alpha", Loading @@ -391,7 +394,7 @@ class MaximizeMenu( ValueAnimator.ofFloat(0f, 1f) ValueAnimator.ofFloat(0f, 1f) .apply { .apply { duration = ALPHA_ANIMATION_DURATION_MS duration = ALPHA_ANIMATION_DURATION_MS startDelay = CONTROLS_ALPHA_ANIMATION_DELAY_MS startDelay = CONTROLS_ALPHA_OPEN_MENU_ANIMATION_DELAY_MS addUpdateListener { addUpdateListener { val value = animatedValue as Float val value = animatedValue as Float maximizeButton.alpha = value maximizeButton.alpha = value Loading @@ -403,21 +406,96 @@ class MaximizeMenu( ObjectAnimator.ofFloat(rootView, TRANSLATION_Z, MENU_Z_TRANSLATION) ObjectAnimator.ofFloat(rootView, TRANSLATION_Z, MENU_Z_TRANSLATION) .apply { .apply { duration = ELEVATION_ANIMATION_DURATION_MS duration = ELEVATION_ANIMATION_DURATION_MS startDelay = CONTROLS_ALPHA_ANIMATION_DELAY_MS startDelay = CONTROLS_ALPHA_OPEN_MENU_ANIMATION_DELAY_MS } ) menuAnimatorSet?.addListener( onEnd = { maximizeButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_SOFTWARE, null) } ) menuAnimatorSet?.start() } /** Animate the closing of the menu */ fun animateCloseMenu(onEnd: (() -> Unit)) { maximizeButton.setLayerType(View.LAYER_TYPE_HARDWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_HARDWARE, null) cancelAnimation() menuAnimatorSet = AnimatorSet() menuAnimatorSet?.playTogether( ObjectAnimator.ofFloat(rootView, SCALE_Y, 1f, STARTING_MENU_HEIGHT_SCALE) .apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN }, ValueAnimator.ofFloat(1f, STARTING_MENU_HEIGHT_SCALE) .apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN addUpdateListener { // Animate padding so that controls stay pinned to the bottom of // the menu. val value = animatedValue as Float val topPadding = menuPadding - ((1 - value) * menuHeight).toInt() container.setPadding(menuPadding, topPadding, menuPadding, menuPadding) } }, ValueAnimator.ofFloat(1f, 1 / STARTING_MENU_HEIGHT_SCALE).apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN addUpdateListener { // Scale up the children of the maximize menu so that the menu // scale is cancelled out and only the background is scaled. val value = animatedValue as Float maximizeButton.scaleY = value snapButtonsLayout.scaleY = value maximizeText.scaleY = value snapWindowText.scaleY = value } }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Y, 0f, (STARTING_MENU_HEIGHT_SCALE - 1) * menuHeight).apply { duration = CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS interpolator = FAST_OUT_LINEAR_IN }, ObjectAnimator.ofInt(rootView.background, "alpha", MAX_DRAWABLE_ALPHA_VALUE, 0).apply { startDelay = CONTAINER_ALPHA_CLOSE_MENU_ANIMATION_DELAY_MS duration = ALPHA_ANIMATION_DURATION_MS }, ValueAnimator.ofFloat(1f, 0f) .apply { duration = ALPHA_ANIMATION_DURATION_MS addUpdateListener { val value = animatedValue as Float maximizeButton.alpha = value snapButtonsLayout.alpha = value maximizeText.alpha = value snapWindowText.alpha = value } }, ObjectAnimator.ofFloat(rootView, TRANSLATION_Z, MENU_Z_TRANSLATION, 0f) .apply { duration = ELEVATION_ANIMATION_DURATION_MS } } ) ) openMenuAnimatorSet.addListener( menuAnimatorSet?.addListener( onEnd = { onEnd = { maximizeButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_SOFTWARE, null) maximizeText.setLayerType(View.LAYER_TYPE_SOFTWARE, null) onEnd?.invoke() } } ) ) openMenuAnimatorSet.start() menuAnimatorSet?.start() } } /** Cancel the open menu animation. */ /** Cancel the menu animation. */ fun cancelAnimation() { private fun cancelAnimation() { openMenuAnimatorSet.cancel() menuAnimatorSet?.cancel() } } /** Update the view state to a new snap to half selection. */ /** Update the view state to a new snap to half selection. */ Loading Loading @@ -645,9 +723,11 @@ class MaximizeMenu( private const val ALPHA_ANIMATION_DURATION_MS = 50L private const val ALPHA_ANIMATION_DURATION_MS = 50L private const val MAX_DRAWABLE_ALPHA_VALUE = 255 private const val MAX_DRAWABLE_ALPHA_VALUE = 255 private const val STARTING_MENU_HEIGHT_SCALE = 0.8f private const val STARTING_MENU_HEIGHT_SCALE = 0.8f private const val MENU_HEIGHT_ANIMATION_DURATION_MS = 300L private const val OPEN_MENU_HEIGHT_ANIMATION_DURATION_MS = 300L private const val CLOSE_MENU_HEIGHT_ANIMATION_DURATION_MS = 200L private const val ELEVATION_ANIMATION_DURATION_MS = 50L private const val ELEVATION_ANIMATION_DURATION_MS = 50L private const val CONTROLS_ALPHA_ANIMATION_DELAY_MS = 33L private const val CONTROLS_ALPHA_OPEN_MENU_ANIMATION_DELAY_MS = 33L private const val CONTAINER_ALPHA_CLOSE_MENU_ANIMATION_DELAY_MS = 33L private const val MENU_Z_TRANSLATION = 1f private const val MENU_Z_TRANSLATION = 1f } } } } Loading