summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt233
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/animation/ViewHierarchyAnimatorTest.kt555
2 files changed, 420 insertions, 368 deletions
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt
index 00d905652987..300bdf2ffb01 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt
@@ -48,7 +48,7 @@ class ViewHierarchyAnimator {
Bound.LEFT to createViewProperty(Bound.LEFT),
Bound.TOP to createViewProperty(Bound.TOP),
Bound.RIGHT to createViewProperty(Bound.RIGHT),
- Bound.BOTTOM to createViewProperty(Bound.BOTTOM)
+ Bound.BOTTOM to createViewProperty(Bound.BOTTOM),
)
private fun createViewProperty(bound: Bound): IntProperty<View> {
@@ -89,7 +89,7 @@ class ViewHierarchyAnimator {
interpolator: Interpolator = DEFAULT_INTERPOLATOR,
duration: Long = DEFAULT_DURATION,
animateChildren: Boolean = true,
- excludedViews: Set<View> = emptySet()
+ excludedViews: Set<View> = emptySet(),
): Boolean {
return animate(
rootView,
@@ -97,7 +97,7 @@ class ViewHierarchyAnimator {
duration,
ephemeral = false,
animateChildren = animateChildren,
- excludedViews = excludedViews
+ excludedViews = excludedViews,
)
}
@@ -111,7 +111,7 @@ class ViewHierarchyAnimator {
interpolator: Interpolator = DEFAULT_INTERPOLATOR,
duration: Long = DEFAULT_DURATION,
animateChildren: Boolean = true,
- excludedViews: Set<View> = emptySet()
+ excludedViews: Set<View> = emptySet(),
): Boolean {
return animate(
rootView,
@@ -119,7 +119,7 @@ class ViewHierarchyAnimator {
duration,
ephemeral = true,
animateChildren = animateChildren,
- excludedViews = excludedViews
+ excludedViews = excludedViews,
)
}
@@ -129,7 +129,7 @@ class ViewHierarchyAnimator {
duration: Long,
ephemeral: Boolean,
animateChildren: Boolean,
- excludedViews: Set<View> = emptySet()
+ excludedViews: Set<View> = emptySet(),
): Boolean {
if (
!occupiesSpace(
@@ -137,7 +137,7 @@ class ViewHierarchyAnimator {
rootView.left,
rootView.top,
rootView.right,
- rootView.bottom
+ rootView.bottom,
)
) {
return false
@@ -149,7 +149,7 @@ class ViewHierarchyAnimator {
listener,
recursive = true,
animateChildren = animateChildren,
- excludedViews = excludedViews
+ excludedViews = excludedViews,
)
return true
}
@@ -164,7 +164,7 @@ class ViewHierarchyAnimator {
private fun createUpdateListener(
interpolator: Interpolator,
duration: Long,
- ephemeral: Boolean
+ ephemeral: Boolean,
): View.OnLayoutChangeListener {
return createListener(interpolator, duration, ephemeral)
}
@@ -196,9 +196,9 @@ class ViewHierarchyAnimator {
*
* @param includeFadeIn true if the animator should also fade in the view and child views.
* @param fadeInInterpolator the interpolator to use when fading in the view. Unused if
- * [includeFadeIn] is false.
- * @param onAnimationEnd an optional runnable that will be run once the animation
- * finishes successfully. Will not be run if the animation is cancelled.
+ * [includeFadeIn] is false.
+ * @param onAnimationEnd an optional runnable that will be run once the animation finishes,
+ * regardless of whether the animation is cancelled or finishes successfully.
*/
@JvmOverloads
fun animateAddition(
@@ -217,7 +217,7 @@ class ViewHierarchyAnimator {
rootView.left,
rootView.top,
rootView.right,
- rootView.bottom
+ rootView.bottom,
)
) {
return false
@@ -241,7 +241,10 @@ class ViewHierarchyAnimator {
// First, fade in the container view
val containerDuration = duration / 6
createAndStartFadeInAnimator(
- rootView, containerDuration, startDelay = 0, interpolator = fadeInInterpolator
+ rootView,
+ containerDuration,
+ startDelay = 0,
+ interpolator = fadeInInterpolator,
)
// Then, fade in the child views
@@ -253,7 +256,7 @@ class ViewHierarchyAnimator {
childDuration,
// Wait until the container fades in before fading in the children
startDelay = containerDuration,
- interpolator = fadeInInterpolator
+ interpolator = fadeInInterpolator,
)
}
// For now, we don't recursively fade in additional sub views (e.g. grandchild
@@ -264,7 +267,7 @@ class ViewHierarchyAnimator {
rootView,
duration / 2,
startDelay = 0,
- interpolator = fadeInInterpolator
+ interpolator = fadeInInterpolator,
)
}
@@ -323,7 +326,7 @@ class ViewHierarchyAnimator {
previousLeft: Int,
previousTop: Int,
previousRight: Int,
- previousBottom: Int
+ previousBottom: Int,
) {
if (view == null) return
@@ -353,14 +356,14 @@ class ViewHierarchyAnimator {
startTop,
startRight,
startBottom,
- ignorePreviousValues
+ ignorePreviousValues,
)
val endValues =
mapOf(
Bound.LEFT to left,
Bound.TOP to top,
Bound.RIGHT to right,
- Bound.BOTTOM to bottom
+ Bound.BOTTOM to bottom,
)
val boundsToAnimate = mutableSetOf<Bound>()
@@ -396,8 +399,8 @@ class ViewHierarchyAnimator {
* added on the side(s) of the [destination], the translation of those margins can be
* included by specifying [includeMargins].
*
- * @param onAnimationEnd an optional runnable that will be run once the animation finishes
- * successfully. Will not be run if the animation is cancelled.
+ * @param onAnimationEnd an optional runnable that will be run once the animation finishes,
+ * regardless of whether the animation is cancelled or finishes successfully.
*/
@JvmOverloads
fun animateRemoval(
@@ -414,7 +417,7 @@ class ViewHierarchyAnimator {
rootView.left,
rootView.top,
rootView.right,
- rootView.bottom
+ rootView.bottom,
)
) {
return false
@@ -458,7 +461,7 @@ class ViewHierarchyAnimator {
Bound.LEFT to rootView.left,
Bound.TOP to rootView.top,
Bound.RIGHT to rootView.right,
- Bound.BOTTOM to rootView.bottom
+ Bound.BOTTOM to rootView.bottom,
)
val endValues =
processEndValuesForRemoval(
@@ -550,7 +553,7 @@ class ViewHierarchyAnimator {
destination: Hotspot,
endValues: Map<Bound, Int>,
interpolator: Interpolator,
- duration: Long
+ duration: Long,
) {
for (i in 0 until rootView.childCount) {
val child = rootView.getChildAt(i)
@@ -559,7 +562,7 @@ class ViewHierarchyAnimator {
Bound.LEFT to child.left,
Bound.TOP to child.top,
Bound.RIGHT to child.right,
- Bound.BOTTOM to child.bottom
+ Bound.BOTTOM to child.bottom,
)
val childEndValues =
processChildEndValuesForRemoval(
@@ -569,7 +572,7 @@ class ViewHierarchyAnimator {
child.right,
child.bottom,
endValues.getValue(Bound.RIGHT) - endValues.getValue(Bound.LEFT),
- endValues.getValue(Bound.BOTTOM) - endValues.getValue(Bound.TOP)
+ endValues.getValue(Bound.BOTTOM) - endValues.getValue(Bound.TOP),
)
val boundsToAnimate = mutableSetOf<Bound>()
@@ -587,7 +590,7 @@ class ViewHierarchyAnimator {
childEndValues,
interpolator,
duration,
- ephemeral = true
+ ephemeral = true,
)
}
}
@@ -601,7 +604,7 @@ class ViewHierarchyAnimator {
left: Int,
top: Int,
right: Int,
- bottom: Int
+ bottom: Int,
): Boolean {
return visibility != View.GONE && left != right && top != bottom
}
@@ -616,6 +619,7 @@ class ViewHierarchyAnimator {
* not newly introduced margins are included.
*
* Base case
+ *
* ```
* 1) origin=TOP
* x---------x x---------x x---------x x---------x x---------x
@@ -636,9 +640,11 @@ class ViewHierarchyAnimator {
* x-----x x-------x | |
* x---------x
* ```
+ *
* In case the start and end values differ in the direction of the origin, and
* [ignorePreviousValues] is false, the previous values are used and a translation is
* included in addition to the view expansion.
+ *
* ```
* origin=TOP_LEFT - (0,0,0,0) -> (30,30,70,70)
* x
@@ -660,7 +666,7 @@ class ViewHierarchyAnimator {
previousTop: Int,
previousRight: Int,
previousBottom: Int,
- ignorePreviousValues: Boolean
+ ignorePreviousValues: Boolean,
): Map<Bound, Int> {
val startLeft = if (ignorePreviousValues) newLeft else previousLeft
val startTop = if (ignorePreviousValues) newTop else previousTop
@@ -727,7 +733,7 @@ class ViewHierarchyAnimator {
Bound.LEFT to left,
Bound.TOP to top,
Bound.RIGHT to right,
- Bound.BOTTOM to bottom
+ Bound.BOTTOM to bottom,
)
}
@@ -777,18 +783,17 @@ class ViewHierarchyAnimator {
includeMargins: Boolean = false,
): Map<Bound, Int> {
val marginAdjustment =
- if (includeMargins &&
- (rootView.layoutParams is ViewGroup.MarginLayoutParams)) {
+ if (includeMargins && (rootView.layoutParams is ViewGroup.MarginLayoutParams)) {
val marginLp = rootView.layoutParams as ViewGroup.MarginLayoutParams
DimenHolder(
left = marginLp.leftMargin,
top = marginLp.topMargin,
right = marginLp.rightMargin,
- bottom = marginLp.bottomMargin
+ bottom = marginLp.bottomMargin,
)
- } else {
- DimenHolder(0, 0, 0, 0)
- }
+ } else {
+ DimenHolder(0, 0, 0, 0)
+ }
// These are the end values to use *if* this bound is part of the destination.
val endLeft = left - marginAdjustment.left
@@ -805,60 +810,69 @@ class ViewHierarchyAnimator {
// - If destination=BOTTOM_LEFT, then endBottom == endTop AND endLeft == endRight.
return when (destination) {
- Hotspot.TOP -> mapOf(
- Bound.TOP to endTop,
- Bound.BOTTOM to endTop,
- Bound.LEFT to left,
- Bound.RIGHT to right,
- )
- Hotspot.TOP_RIGHT -> mapOf(
- Bound.TOP to endTop,
- Bound.BOTTOM to endTop,
- Bound.RIGHT to endRight,
- Bound.LEFT to endRight,
- )
- Hotspot.RIGHT -> mapOf(
- Bound.RIGHT to endRight,
- Bound.LEFT to endRight,
- Bound.TOP to top,
- Bound.BOTTOM to bottom,
- )
- Hotspot.BOTTOM_RIGHT -> mapOf(
- Bound.BOTTOM to endBottom,
- Bound.TOP to endBottom,
- Bound.RIGHT to endRight,
- Bound.LEFT to endRight,
- )
- Hotspot.BOTTOM -> mapOf(
- Bound.BOTTOM to endBottom,
- Bound.TOP to endBottom,
- Bound.LEFT to left,
- Bound.RIGHT to right,
- )
- Hotspot.BOTTOM_LEFT -> mapOf(
- Bound.BOTTOM to endBottom,
- Bound.TOP to endBottom,
- Bound.LEFT to endLeft,
- Bound.RIGHT to endLeft,
- )
- Hotspot.LEFT -> mapOf(
- Bound.LEFT to endLeft,
- Bound.RIGHT to endLeft,
- Bound.TOP to top,
- Bound.BOTTOM to bottom,
- )
- Hotspot.TOP_LEFT -> mapOf(
- Bound.TOP to endTop,
- Bound.BOTTOM to endTop,
- Bound.LEFT to endLeft,
- Bound.RIGHT to endLeft,
- )
- Hotspot.CENTER -> mapOf(
- Bound.LEFT to (endLeft + endRight) / 2,
- Bound.RIGHT to (endLeft + endRight) / 2,
- Bound.TOP to (endTop + endBottom) / 2,
- Bound.BOTTOM to (endTop + endBottom) / 2,
- )
+ Hotspot.TOP ->
+ mapOf(
+ Bound.TOP to endTop,
+ Bound.BOTTOM to endTop,
+ Bound.LEFT to left,
+ Bound.RIGHT to right,
+ )
+ Hotspot.TOP_RIGHT ->
+ mapOf(
+ Bound.TOP to endTop,
+ Bound.BOTTOM to endTop,
+ Bound.RIGHT to endRight,
+ Bound.LEFT to endRight,
+ )
+ Hotspot.RIGHT ->
+ mapOf(
+ Bound.RIGHT to endRight,
+ Bound.LEFT to endRight,
+ Bound.TOP to top,
+ Bound.BOTTOM to bottom,
+ )
+ Hotspot.BOTTOM_RIGHT ->
+ mapOf(
+ Bound.BOTTOM to endBottom,
+ Bound.TOP to endBottom,
+ Bound.RIGHT to endRight,
+ Bound.LEFT to endRight,
+ )
+ Hotspot.BOTTOM ->
+ mapOf(
+ Bound.BOTTOM to endBottom,
+ Bound.TOP to endBottom,
+ Bound.LEFT to left,
+ Bound.RIGHT to right,
+ )
+ Hotspot.BOTTOM_LEFT ->
+ mapOf(
+ Bound.BOTTOM to endBottom,
+ Bound.TOP to endBottom,
+ Bound.LEFT to endLeft,
+ Bound.RIGHT to endLeft,
+ )
+ Hotspot.LEFT ->
+ mapOf(
+ Bound.LEFT to endLeft,
+ Bound.RIGHT to endLeft,
+ Bound.TOP to top,
+ Bound.BOTTOM to bottom,
+ )
+ Hotspot.TOP_LEFT ->
+ mapOf(
+ Bound.TOP to endTop,
+ Bound.BOTTOM to endTop,
+ Bound.LEFT to endLeft,
+ Bound.RIGHT to endLeft,
+ )
+ Hotspot.CENTER ->
+ mapOf(
+ Bound.LEFT to (endLeft + endRight) / 2,
+ Bound.RIGHT to (endLeft + endRight) / 2,
+ Bound.TOP to (endTop + endBottom) / 2,
+ Bound.BOTTOM to (endTop + endBottom) / 2,
+ )
}
}
@@ -887,7 +901,7 @@ class ViewHierarchyAnimator {
right: Int,
bottom: Int,
parentWidth: Int,
- parentHeight: Int
+ parentHeight: Int,
): Map<Bound, Int> {
val halfWidth = (right - left) / 2
val halfHeight = (bottom - top) / 2
@@ -945,7 +959,7 @@ class ViewHierarchyAnimator {
Bound.LEFT to endLeft,
Bound.TOP to endTop,
Bound.RIGHT to endRight,
- Bound.BOTTOM to endBottom
+ Bound.BOTTOM to endBottom,
)
}
@@ -954,7 +968,7 @@ class ViewHierarchyAnimator {
listener: View.OnLayoutChangeListener,
recursive: Boolean = false,
animateChildren: Boolean = true,
- excludedViews: Set<View> = emptySet()
+ excludedViews: Set<View> = emptySet(),
) {
if (excludedViews.contains(view)) return
@@ -973,7 +987,7 @@ class ViewHierarchyAnimator {
listener,
recursive = true,
animateChildren = animateChildren,
- excludedViews = excludedViews
+ excludedViews = excludedViews,
)
}
}
@@ -1027,7 +1041,7 @@ class ViewHierarchyAnimator {
PropertyValuesHolder.ofInt(
PROPERTIES[bound],
startValues.getValue(bound),
- endValues.getValue(bound)
+ endValues.getValue(bound),
)
)
}
@@ -1056,9 +1070,10 @@ class ViewHierarchyAnimator {
// listener.
recursivelyRemoveListener(view)
}
- if (!cancelled) {
- onAnimationEnd?.run()
- }
+ // Run the end runnable regardless of whether the animation was cancelled or
+ // not - this ensures critical actions (like removing a window) always occur
+ // (see b/344049884).
+ onAnimationEnd?.run()
}
override fun onAnimationCancel(animation: Animator) {
@@ -1077,17 +1092,19 @@ class ViewHierarchyAnimator {
view: View,
duration: Long,
startDelay: Long,
- interpolator: Interpolator
+ interpolator: Interpolator,
) {
val animator = ObjectAnimator.ofFloat(view, "alpha", 1f)
animator.startDelay = startDelay
animator.duration = duration
animator.interpolator = interpolator
- animator.addListener(object : AnimatorListenerAdapter() {
- override fun onAnimationEnd(animation: Animator) {
- view.setTag(R.id.tag_alpha_animator, null /* tag */)
+ animator.addListener(
+ object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator) {
+ view.setTag(R.id.tag_alpha_animator, null /* tag */)
+ }
}
- })
+ )
(view.getTag(R.id.tag_alpha_animator) as? ObjectAnimator)?.cancel()
view.setTag(R.id.tag_alpha_animator, animator)
@@ -1105,7 +1122,7 @@ class ViewHierarchyAnimator {
RIGHT,
BOTTOM_RIGHT,
BOTTOM,
- BOTTOM_LEFT
+ BOTTOM_LEFT,
}
private enum class Bound(val label: String, val overrideTag: Int) {
@@ -1147,14 +1164,10 @@ class ViewHierarchyAnimator {
};
abstract fun setValue(view: View, value: Int)
+
abstract fun getValue(view: View): Int
}
/** Simple data class to hold a set of dimens for left, top, right, bottom. */
- private data class DimenHolder(
- val left: Int,
- val top: Int,
- val right: Int,
- val bottom: Int,
- )
+ private data class DimenHolder(val left: Int, val top: Int, val right: Int, val bottom: Int)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/ViewHierarchyAnimatorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/ViewHierarchyAnimatorTest.kt
index a8c3af9488f0..8db82d58ecc5 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/ViewHierarchyAnimatorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/animation/ViewHierarchyAnimatorTest.kt
@@ -24,8 +24,7 @@ import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
-class
-ViewHierarchyAnimatorTest : SysuiTestCase() {
+class ViewHierarchyAnimatorTest : SysuiTestCase() {
companion object {
private const val TEST_DURATION = 1000L
private val TEST_INTERPOLATOR = Interpolators.LINEAR
@@ -49,9 +48,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
rootView.layout(10 /* l */, 10 /* t */, 50 /* r */, 50 /* b */)
// animate()
- var success = ViewHierarchyAnimator.animate(
- rootView, interpolator = TEST_INTERPOLATOR, duration = TEST_DURATION
- )
+ var success =
+ ViewHierarchyAnimator.animate(
+ rootView,
+ interpolator = TEST_INTERPOLATOR,
+ duration = TEST_DURATION,
+ )
rootView.layout(0 /* l */, 0 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -64,9 +66,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.stopAnimating(rootView)
// animateNextUpdate()
- success = ViewHierarchyAnimator.animateNextUpdate(
- rootView, interpolator = TEST_INTERPOLATOR, duration = TEST_DURATION
- )
+ success =
+ ViewHierarchyAnimator.animateNextUpdate(
+ rootView,
+ interpolator = TEST_INTERPOLATOR,
+ duration = TEST_DURATION,
+ )
rootView.layout(10 /* l */, 10 /* t */, 50 /* r */, 50 /* b */)
assertTrue(success)
@@ -79,9 +84,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// animateAddition()
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView, interpolator = TEST_INTERPOLATOR, duration = TEST_DURATION
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ interpolator = TEST_INTERPOLATOR,
+ duration = TEST_DURATION,
+ )
rootView.layout(10 /* l */, 10 /* t */, 50 /* r */, 50 /* b */)
assertTrue(success)
@@ -93,9 +101,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// animateRemoval()
setUpRootWithChildren()
val child = rootView.getChildAt(0)
- success = ViewHierarchyAnimator.animateRemoval(
- child, interpolator = TEST_INTERPOLATOR, duration = TEST_DURATION
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ child,
+ interpolator = TEST_INTERPOLATOR,
+ duration = TEST_DURATION,
+ )
assertTrue(success)
assertNotNull(child.getTag(R.id.tag_animator))
@@ -185,7 +196,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// Change all bounds.
rootView.measure(
View.MeasureSpec.makeMeasureSpec(190, View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY)
+ View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
)
rootView.layout(10 /* l */, 20 /* t */, 200 /* r */, 120 /* b */)
@@ -211,14 +222,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
fun animatesRootAndChildren_withExcludedViews() {
setUpRootWithChildren()
- val success = ViewHierarchyAnimator.animate(
- rootView,
- excludedViews = setOf(rootView.getChildAt(0))
- )
+ val success =
+ ViewHierarchyAnimator.animate(rootView, excludedViews = setOf(rootView.getChildAt(0)))
// Change all bounds.
rootView.measure(
- View.MeasureSpec.makeMeasureSpec(180, View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY)
+ View.MeasureSpec.makeMeasureSpec(180, View.MeasureSpec.EXACTLY),
+ View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
)
rootView.layout(10 /* l */, 20 /* t */, 200 /* r */, 120 /* b */)
@@ -245,14 +254,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
fun animatesRootOnly() {
setUpRootWithChildren()
- val success = ViewHierarchyAnimator.animate(
- rootView,
- animateChildren = false
- )
+ val success = ViewHierarchyAnimator.animate(rootView, animateChildren = false)
// Change all bounds.
rootView.measure(
- View.MeasureSpec.makeMeasureSpec(180, View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY)
+ View.MeasureSpec.makeMeasureSpec(180, View.MeasureSpec.EXACTLY),
+ View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
)
rootView.layout(10 /* l */, 20 /* t */, 200 /* r */, 120 /* b */)
@@ -351,10 +357,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
fun animatesAppearingViewsRespectingOrigin() {
// CENTER.
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- var success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.CENTER
- )
+ var success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.CENTER,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -364,10 +371,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// LEFT.
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.LEFT
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.LEFT,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -377,10 +385,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// TOP_LEFT.
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.TOP_LEFT
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.TOP_LEFT,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -390,10 +399,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// TOP.
rootView.layout(150 /* l */, 0 /* t */, 150 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.TOP
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.TOP,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -403,10 +413,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// TOP_RIGHT.
rootView.layout(150 /* l */, 0 /* t */, 150 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.TOP_RIGHT
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.TOP_RIGHT,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -416,10 +427,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// RIGHT.
rootView.layout(150 /* l */, 150 /* t */, 150 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.RIGHT
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.RIGHT,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -429,10 +441,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// BOTTOM_RIGHT.
rootView.layout(150 /* l */, 150 /* t */, 150 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -442,10 +455,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// BOTTOM.
rootView.layout(0 /* l */, 150 /* t */, 0 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.BOTTOM
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.BOTTOM,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -455,10 +469,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// BOTTOM_LEFT.
rootView.layout(0 /* l */, 150 /* t */, 0 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -471,11 +486,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
fun animatesAppearingViewsRespectingMargins() {
// CENTER.
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- var success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.CENTER,
- includeMargins = true
- )
+ var success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.CENTER,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -485,10 +501,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// LEFT.
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView, origin = ViewHierarchyAnimator.Hotspot.LEFT,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.LEFT,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -498,11 +516,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// TOP_LEFT.
rootView.layout(0 /* l */, 0 /* t */, 0 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.TOP_LEFT,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.TOP_LEFT,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -512,10 +531,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// TOP.
rootView.layout(150 /* l */, 0 /* t */, 150 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView, origin = ViewHierarchyAnimator.Hotspot.TOP,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.TOP,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -525,11 +546,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// TOP_RIGHT.
rootView.layout(150 /* l */, 0 /* t */, 150 /* r */, 0 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.TOP_RIGHT,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.TOP_RIGHT,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -539,11 +561,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// RIGHT.
rootView.layout(150 /* l */, 150 /* t */, 150 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.RIGHT,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.RIGHT,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -553,11 +576,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// BOTTOM_RIGHT.
rootView.layout(150 /* l */, 150 /* t */, 150 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -567,11 +591,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// BOTTOM.
rootView.layout(0 /* l */, 150 /* t */, 0 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.BOTTOM,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.BOTTOM,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -581,11 +606,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// BOTTOM_LEFT.
rootView.layout(0 /* l */, 150 /* t */, 0 /* r */, 150 /* b */)
- success = ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT,
- includeMargins = true
- )
+ success =
+ ViewHierarchyAnimator.animateAddition(
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT,
+ includeMargins = true,
+ )
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
assertTrue(success)
@@ -626,7 +652,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.animateAddition(
rootView,
includeFadeIn = true,
- fadeInInterpolator = Interpolators.LINEAR
+ fadeInInterpolator = Interpolators.LINEAR,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -641,7 +667,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.animateAddition(
rootView,
includeFadeIn = true,
- fadeInInterpolator = Interpolators.LINEAR
+ fadeInInterpolator = Interpolators.LINEAR,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -663,7 +689,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.animateAddition(
rootView,
includeFadeIn = true,
- fadeInInterpolator = Interpolators.LINEAR
+ fadeInInterpolator = Interpolators.LINEAR,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -680,7 +706,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.animateAddition(
rootView,
includeFadeIn = true,
- fadeInInterpolator = Interpolators.LINEAR
+ fadeInInterpolator = Interpolators.LINEAR,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -692,7 +718,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.animateAddition(
rootView,
includeFadeIn = true,
- fadeInInterpolator = Interpolators.LINEAR
+ fadeInInterpolator = Interpolators.LINEAR,
)
// THEN the alpha remains at its current value (it doesn't get reset to 0)
@@ -721,7 +747,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.animateAddition(
rootView,
includeFadeIn = false,
- fadeInInterpolator = Interpolators.LINEAR
+ fadeInInterpolator = Interpolators.LINEAR,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -738,10 +764,10 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val onAnimationEndRunnable = { runnableRun = true }
ViewHierarchyAnimator.animateAddition(
- rootView,
- origin = ViewHierarchyAnimator.Hotspot.CENTER,
- includeMargins = true,
- onAnimationEnd = onAnimationEndRunnable
+ rootView,
+ origin = ViewHierarchyAnimator.Hotspot.CENTER,
+ includeMargins = true,
+ onAnimationEnd = onAnimationEndRunnable,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -751,7 +777,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
}
@Test
- fun animateAddition_runnableDoesNotRunWhenAnimationCancelled() {
+ fun animateAddition_runnableRunsWhenAnimationCancelled() {
var runnableRun = false
val onAnimationEndRunnable = { runnableRun = true }
@@ -759,13 +785,13 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
rootView,
origin = ViewHierarchyAnimator.Hotspot.CENTER,
includeMargins = true,
- onAnimationEnd = onAnimationEndRunnable
+ onAnimationEnd = onAnimationEndRunnable,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
cancelAnimation(rootView)
- assertEquals(false, runnableRun)
+ assertEquals(true, runnableRun)
}
@Test
@@ -777,7 +803,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
rootView,
origin = ViewHierarchyAnimator.Hotspot.CENTER,
includeMargins = true,
- onAnimationEnd = onAnimationEndRunnable
+ onAnimationEnd = onAnimationEndRunnable,
)
rootView.layout(50 /* l */, 50 /* t */, 100 /* r */, 100 /* b */)
@@ -791,11 +817,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
val child = rootView.getChildAt(0)
- val success = ViewHierarchyAnimator.animateRemoval(
- child,
- destination = ViewHierarchyAnimator.Hotspot.LEFT,
- interpolator = Interpolators.LINEAR
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ child,
+ destination = ViewHierarchyAnimator.Hotspot.LEFT,
+ interpolator = Interpolators.LINEAR,
+ )
assertTrue(success)
assertNotNull(child.getTag(R.id.tag_animator))
@@ -820,11 +847,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
rootView.addView(onlyChild)
forceLayout()
- val success = ViewHierarchyAnimator.animateRemoval(
- onlyChild,
- destination = ViewHierarchyAnimator.Hotspot.LEFT,
- interpolator = Interpolators.LINEAR
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ onlyChild,
+ destination = ViewHierarchyAnimator.Hotspot.LEFT,
+ interpolator = Interpolators.LINEAR,
+ )
assertTrue(success)
assertNotNull(onlyChild.getTag(R.id.tag_animator))
@@ -845,9 +873,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
var removedChild = rootView.getChildAt(0)
var remainingChild = rootView.getChildAt(1)
- var success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.CENTER
- )
+ var success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.CENTER,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -863,9 +893,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.LEFT
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.LEFT,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -881,9 +913,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.TOP_LEFT
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.TOP_LEFT,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -899,9 +933,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.TOP
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.TOP,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -917,9 +953,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.TOP_RIGHT
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.TOP_RIGHT,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -935,9 +973,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.RIGHT
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.RIGHT,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -953,9 +993,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -971,9 +1013,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.BOTTOM
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.BOTTOM,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -989,9 +1033,11 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
setUpRootWithChildren()
removedChild = rootView.getChildAt(0)
remainingChild = rootView.getChildAt(1)
- success = ViewHierarchyAnimator.animateRemoval(
- removedChild, destination = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT
- )
+ success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT,
+ )
// Ensure that the layout happens before the checks.
forceLayout()
@@ -1014,11 +1060,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalRight = removedChild.right
val originalBottom = removedChild.bottom
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.CENTER,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.CENTER,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1027,13 +1074,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val expectedX = ((originalLeft - M_LEFT) + (originalRight + M_RIGHT)) / 2
val expectedY = ((originalTop - M_TOP) + (originalBottom + M_BOTTOM)) / 2
- checkBounds(
- removedChild,
- l = expectedX,
- t = expectedY,
- r = expectedX,
- b = expectedY
- )
+ checkBounds(removedChild, l = expectedX, t = expectedY, r = expectedX, b = expectedY)
}
@Test
@@ -1044,11 +1085,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalTop = removedChild.top
val originalBottom = removedChild.bottom
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.LEFT,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.LEFT,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1059,7 +1101,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalLeft - M_LEFT,
t = originalTop,
r = originalLeft - M_LEFT,
- b = originalBottom
+ b = originalBottom,
)
}
@@ -1070,11 +1112,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalLeft = removedChild.left
val originalTop = removedChild.top
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.TOP_LEFT,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.TOP_LEFT,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1085,7 +1128,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalLeft - M_LEFT,
t = originalTop - M_TOP,
r = originalLeft - M_LEFT,
- b = originalTop - M_TOP
+ b = originalTop - M_TOP,
)
}
@@ -1097,11 +1140,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalTop = removedChild.top
val originalRight = removedChild.right
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.TOP,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.TOP,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1112,7 +1156,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalLeft,
t = originalTop - M_TOP,
r = originalRight,
- b = originalTop - M_TOP
+ b = originalTop - M_TOP,
)
}
@@ -1123,11 +1167,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalTop = removedChild.top
val originalRight = removedChild.right
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.TOP_RIGHT,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.TOP_RIGHT,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1138,7 +1183,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalRight + M_RIGHT,
t = originalTop - M_TOP,
r = originalRight + M_RIGHT,
- b = originalTop - M_TOP
+ b = originalTop - M_TOP,
)
}
@@ -1150,11 +1195,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalRight = removedChild.right
val originalBottom = removedChild.bottom
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.RIGHT,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.RIGHT,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1165,7 +1211,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalRight + M_RIGHT,
t = originalTop,
r = originalRight + M_RIGHT,
- b = originalBottom
+ b = originalBottom,
)
}
@@ -1176,11 +1222,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalRight = removedChild.right
val originalBottom = removedChild.bottom
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.BOTTOM_RIGHT,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1191,7 +1238,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalRight + M_RIGHT,
t = originalBottom + M_BOTTOM,
r = originalRight + M_RIGHT,
- b = originalBottom + M_BOTTOM
+ b = originalBottom + M_BOTTOM,
)
}
@@ -1203,11 +1250,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalRight = removedChild.right
val originalBottom = removedChild.bottom
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.BOTTOM,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.BOTTOM,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1218,7 +1266,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalLeft,
t = originalBottom + M_BOTTOM,
r = originalRight,
- b = originalBottom + M_BOTTOM
+ b = originalBottom + M_BOTTOM,
)
}
@@ -1229,11 +1277,12 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val originalLeft = removedChild.left
val originalBottom = removedChild.bottom
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild,
- destination = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT,
- includeMargins = true,
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(
+ removedChild,
+ destination = ViewHierarchyAnimator.Hotspot.BOTTOM_LEFT,
+ includeMargins = true,
+ )
forceLayout()
assertTrue(success)
@@ -1244,9 +1293,10 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
l = originalLeft - M_LEFT,
t = originalBottom + M_BOTTOM,
r = originalLeft - M_LEFT,
- b = originalBottom + M_BOTTOM
+ b = originalBottom + M_BOTTOM,
)
}
+
/* ******** end of animatesViewRemoval_includeMarginsTrue tests ******** */
@Test
@@ -1256,9 +1306,8 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val child = rootView.getChildAt(0) as ViewGroup
val firstGrandChild = child.getChildAt(0)
val secondGrandChild = child.getChildAt(1)
- val success = ViewHierarchyAnimator.animateRemoval(
- child, interpolator = Interpolators.LINEAR
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(child, interpolator = Interpolators.LINEAR)
assertTrue(success)
assertNotNull(child.getTag(R.id.tag_animator))
@@ -1288,9 +1337,8 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val removedChild = rootView.getChildAt(0)
val remainingChild = rootView.getChildAt(1)
- val success = ViewHierarchyAnimator.animateRemoval(
- removedChild, interpolator = Interpolators.LINEAR
- )
+ val success =
+ ViewHierarchyAnimator.animateRemoval(removedChild, interpolator = Interpolators.LINEAR)
// Ensure that the layout happens before the checks.
forceLayout()
@@ -1315,17 +1363,14 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
forceLayout()
val removedView = rootView.getChildAt(0)
- ViewHierarchyAnimator.animateRemoval(
- removedView,
- onAnimationEnd = onAnimationEndRunnable
- )
+ ViewHierarchyAnimator.animateRemoval(removedView, onAnimationEnd = onAnimationEndRunnable)
endAnimation(removedView)
assertEquals(true, runnableRun)
}
@Test
- fun animateRemoval_runnableDoesNotRunWhenAnimationCancelled() {
+ fun animateRemoval_runnableRunsWhenAnimationCancelled() {
var runnableRun = false
val onAnimationEndRunnable = { runnableRun = true }
@@ -1333,13 +1378,10 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
forceLayout()
val removedView = rootView.getChildAt(0)
- ViewHierarchyAnimator.animateRemoval(
- removedView,
- onAnimationEnd = onAnimationEndRunnable
- )
+ ViewHierarchyAnimator.animateRemoval(removedView, onAnimationEnd = onAnimationEndRunnable)
cancelAnimation(removedView)
- assertEquals(false, runnableRun)
+ assertEquals(true, runnableRun)
}
@Test
@@ -1351,10 +1393,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
forceLayout()
val removedView = rootView.getChildAt(0)
- ViewHierarchyAnimator.animateRemoval(
- removedView,
- onAnimationEnd = onAnimationEndRunnable
- )
+ ViewHierarchyAnimator.animateRemoval(removedView, onAnimationEnd = onAnimationEndRunnable)
advanceAnimation(removedView, 0.5f)
assertEquals(false, runnableRun)
@@ -1370,7 +1409,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
rootView.addView(secondChild)
rootView.measure(
View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY)
+ View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
)
rootView.layout(0 /* l */, 0 /* t */, 100 /* r */, 100 /* b */)
@@ -1378,7 +1417,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
// Change all bounds.
rootView.measure(
View.MeasureSpec.makeMeasureSpec(150, View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY)
+ View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
)
rootView.layout(0 /* l */, 0 /* t */, 150 /* r */, 100 /* b */)
@@ -1501,7 +1540,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
checkBounds(rootView, l = 0, t = 15, r = 70, b = 80)
// Change all bounds again.
- rootView.layout(10 /* l */, 10 /* t */, 50/* r */, 50 /* b */)
+ rootView.layout(10 /* l */, 10 /* t */, 50 /* r */, 50 /* b */)
assertNull(rootView.getTag(R.id.tag_animator))
checkBounds(rootView, l = 10, t = 10, r = 50, b = 50)
@@ -1523,7 +1562,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
ViewHierarchyAnimator.stopAnimating(rootView)
// Change all bounds again.
- rootView.layout(10 /* l */, 10 /* t */, 50/* r */, 50 /* b */)
+ rootView.layout(10 /* l */, 10 /* t */, 50 /* r */, 50 /* b */)
assertNull(rootView.getTag(R.id.tag_animator))
checkBounds(rootView, l = 10, t = 10, r = 50, b = 50)
@@ -1543,10 +1582,8 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
val secondChild = View(mContext)
rootView.addView(secondChild)
- val firstChildParams = LinearLayout.LayoutParams(
- 0 /* width */,
- LinearLayout.LayoutParams.MATCH_PARENT
- )
+ val firstChildParams =
+ LinearLayout.LayoutParams(0 /* width */, LinearLayout.LayoutParams.MATCH_PARENT)
firstChildParams.weight = 0.5f
if (includeMarginsOnFirstChild) {
firstChildParams.leftMargin = M_LEFT
@@ -1556,23 +1593,25 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
}
firstChild.layoutParams = firstChildParams
- val secondChildParams = LinearLayout.LayoutParams(
- 0 /* width */,
- LinearLayout.LayoutParams.MATCH_PARENT
- )
+ val secondChildParams =
+ LinearLayout.LayoutParams(0 /* width */, LinearLayout.LayoutParams.MATCH_PARENT)
secondChildParams.weight = 0.5f
secondChild.layoutParams = secondChildParams
firstGrandChild.layoutParams = RelativeLayout.LayoutParams(40 /* width */, 40 /* height */)
- (firstGrandChild.layoutParams as RelativeLayout.LayoutParams)
- .addRule(RelativeLayout.ALIGN_PARENT_START)
- (firstGrandChild.layoutParams as RelativeLayout.LayoutParams)
- .addRule(RelativeLayout.ALIGN_PARENT_TOP)
+ (firstGrandChild.layoutParams as RelativeLayout.LayoutParams).addRule(
+ RelativeLayout.ALIGN_PARENT_START
+ )
+ (firstGrandChild.layoutParams as RelativeLayout.LayoutParams).addRule(
+ RelativeLayout.ALIGN_PARENT_TOP
+ )
secondGrandChild.layoutParams = RelativeLayout.LayoutParams(40 /* width */, 40 /* height */)
- (secondGrandChild.layoutParams as RelativeLayout.LayoutParams)
- .addRule(RelativeLayout.ALIGN_PARENT_END)
- (secondGrandChild.layoutParams as RelativeLayout.LayoutParams)
- .addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
+ (secondGrandChild.layoutParams as RelativeLayout.LayoutParams).addRule(
+ RelativeLayout.ALIGN_PARENT_END
+ )
+ (secondGrandChild.layoutParams as RelativeLayout.LayoutParams).addRule(
+ RelativeLayout.ALIGN_PARENT_BOTTOM
+ )
forceLayout()
}
@@ -1580,7 +1619,7 @@ ViewHierarchyAnimatorTest : SysuiTestCase() {
private fun forceLayout() {
rootView.measure(
View.MeasureSpec.makeMeasureSpec(200 /* width */, View.MeasureSpec.AT_MOST),
- View.MeasureSpec.makeMeasureSpec(100 /* height */, View.MeasureSpec.AT_MOST)
+ View.MeasureSpec.makeMeasureSpec(100 /* height */, View.MeasureSpec.AT_MOST),
)
rootView.layout(0 /* l */, 0 /* t */, 200 /* r */, 100 /* b */)
}