From 7b8e5271340bc67bdee84583f7d3350fabfac01b Mon Sep 17 00:00:00 2001 From: Yein Jo Date: Tue, 29 Nov 2022 06:53:36 +0000 Subject: [PATCH] Move surface effects package to AnimationLib. in order to share surface effects between launcher and sysui, the package has been moved to the AnimationLib, which is visible to launcher as well. fyi the corresponding tests remain in the SystemUiLib module. technically they should be moved to AnimationLib together, but those tests are dependant on SystemUI testing frameworks (e.g. SysuiTestCase, FakeExecutor, etc.). because of this, some of the variables are marked as VisibleForTesting. Bug: 249536060 Test: MultiRippleControllerTest MultiRippleViewTest RippleAnimationTest RippleViewTest TurbulenceNoiseControllerTest TurbulenceNoiseViewTest Change-Id: I37cdc7cf9064d4d8f02afe72ad16b1cc3df95b6c --- packages/SystemUI/animation/Android.bp | 7 ++++++- .../surfaceeffects/ripple/MultiRippleController.kt | 0 .../systemui/surfaceeffects/ripple/MultiRippleView.kt | 4 +++- .../systemui/surfaceeffects/ripple/RippleAnimation.kt | 4 +++- .../surfaceeffects/ripple/RippleAnimationConfig.kt | 0 .../android/systemui/surfaceeffects/ripple/RippleShader.kt | 2 +- .../android/systemui/surfaceeffects/ripple/RippleView.kt | 0 .../systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt | 0 .../surfaceeffects/shaderutil/ShaderUtilLibrary.kt | 0 .../turbulencenoise/TurbulenceNoiseAnimationConfig.kt | 0 .../turbulencenoise/TurbulenceNoiseController.kt | 0 .../turbulencenoise/TurbulenceNoiseShader.kt | 0 .../surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt | 2 +- 13 files changed, 14 insertions(+), 5 deletions(-) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/ripple/MultiRippleController.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt (93%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt (93%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/ripple/RippleAnimationConfig.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt (99%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseAnimationConfig.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt (100%) rename packages/SystemUI/{ => animation}/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt (98%) diff --git a/packages/SystemUI/animation/Android.bp b/packages/SystemUI/animation/Android.bp index e6ac48ff5af8d..17ad55f403fb3 100644 --- a/packages/SystemUI/animation/Android.bp +++ b/packages/SystemUI/animation/Android.bp @@ -34,7 +34,12 @@ android_library { "res", ], - static_libs: ["androidx.core_core-animation-nodeps"], + static_libs: [ + "PluginCoreLib", + "androidx.core_core-animation-nodeps", + "androidx.core_core-ktx", + "androidx.annotation_annotation", + ], manifest: "AndroidManifest.xml", kotlincflags: ["-Xjvm-default=all"], diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/MultiRippleController.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/MultiRippleController.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/MultiRippleController.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/MultiRippleController.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt similarity index 93% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt index f558fee776e6a..b8dc223af56cb 100644 --- a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/MultiRippleView.kt @@ -22,6 +22,7 @@ import android.graphics.Paint import android.util.AttributeSet import android.util.Log import android.view.View +import androidx.annotation.VisibleForTesting /** * A view that allows multiple ripples to play. @@ -30,7 +31,8 @@ import android.view.View */ class MultiRippleView(context: Context?, attrs: AttributeSet?) : View(context, attrs) { - internal val ripples = ArrayList() + @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) + val ripples = ArrayList() private val listeners = ArrayList() private val ripplePaint = Paint() private var isWarningLogged = false diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt similarity index 93% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt index b2f8994ebf511..0e3d41c40c972 100644 --- a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleAnimation.kt @@ -19,11 +19,13 @@ package com.android.systemui.surfaceeffects.ripple import android.animation.Animator import android.animation.AnimatorListenerAdapter import android.animation.ValueAnimator +import androidx.annotation.VisibleForTesting import androidx.core.graphics.ColorUtils /** A single ripple animation. */ class RippleAnimation(private val config: RippleAnimationConfig) { - internal val rippleShader: RippleShader = RippleShader(config.rippleShape) + @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) + val rippleShader: RippleShader = RippleShader(config.rippleShape) private val animator: ValueAnimator = ValueAnimator.ofFloat(0f, 1f) init { diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleAnimationConfig.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleAnimationConfig.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleAnimationConfig.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleAnimationConfig.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt similarity index 99% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt index a950d34513eec..f55fb97a9a97f 100644 --- a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt @@ -32,7 +32,7 @@ import com.android.systemui.surfaceeffects.shaderutil.ShaderUtilLibrary * * Modeled after frameworks/base/graphics/java/android/graphics/drawable/RippleShader.java. */ -class RippleShader internal constructor(rippleShape: RippleShape = RippleShape.CIRCLE) : +class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) : RuntimeShader(buildShader(rippleShape)) { /** Shapes that the [RippleShader] supports. */ diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/ShaderUtilLibrary.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseAnimationConfig.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseAnimationConfig.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseAnimationConfig.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseAnimationConfig.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt similarity index 100% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseShader.kt diff --git a/packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt similarity index 98% rename from packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt rename to packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt index 8649d59245874..68712c6cd1def 100644 --- a/packages/SystemUI/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt @@ -68,7 +68,7 @@ class TurbulenceNoiseView(context: Context?, attrs: AttributeSet?) : View(contex canvas.drawPaint(paint) } - internal fun play(config: TurbulenceNoiseAnimationConfig) { + fun play(config: TurbulenceNoiseAnimationConfig) { if (isPlaying) { return // Ignore if the animation is playing. }