Loading packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.systemui.surfaceeffects.turbulencenoise import android.view.View import androidx.annotation.VisibleForTesting import java.util.Random /** Plays [TurbulenceNoiseView] in ease-in, main (no easing), and ease-out order. */ class TurbulenceNoiseController(private val turbulenceNoiseView: TurbulenceNoiseView) { Loading @@ -37,8 +36,6 @@ class TurbulenceNoiseController(private val turbulenceNoiseView: TurbulenceNoise } } private val random = Random() /** Current state of the animation. */ @VisibleForTesting var state: AnimationState = AnimationState.NOT_PLAYING Loading Loading @@ -95,12 +92,7 @@ class TurbulenceNoiseController(private val turbulenceNoiseView: TurbulenceNoise } state = AnimationState.EASE_IN // Add offset to avoid repetitive noise. turbulenceNoiseView.playEaseIn( offsetX = random.nextFloat(), offsetY = random.nextFloat(), this::playMainAnimation ) turbulenceNoiseView.playEaseIn(this::playMainAnimation) } private fun playMainAnimation() { Loading packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt +3 −3 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ class TurbulenceNoiseView(context: Context?, attrs: AttributeSet?) : View(contex /** Plays the turbulence noise with linear ease-in. */ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) fun playEaseIn(offsetX: Float = 0f, offsetY: Float = 0f, onAnimationEnd: Runnable? = null) { fun playEaseIn(onAnimationEnd: Runnable? = null) { if (noiseConfig == null) { return } Loading @@ -129,8 +129,8 @@ class TurbulenceNoiseView(context: Context?, attrs: AttributeSet?) : View(contex val progress = updateListener.animatedValue as Float shader.setNoiseMove( offsetX + initialX + timeInSec * config.noiseMoveSpeedX, offsetY + initialY + timeInSec * config.noiseMoveSpeedY, initialX + timeInSec * config.noiseMoveSpeedX, initialY + timeInSec * config.noiseMoveSpeedY, initialZ + timeInSec * config.noiseMoveSpeedZ ) Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaControlPanel.java +4 −4 Original line number Diff line number Diff line Loading @@ -260,7 +260,6 @@ public class MediaControlPanel { private TurbulenceNoiseController mTurbulenceNoiseController; private LoadingEffect mLoadingEffect; private final GlobalSettings mGlobalSettings; private final Random mRandom = new Random(); private TurbulenceNoiseAnimationConfig mTurbulenceNoiseAnimationConfig; private boolean mWasPlaying = false; private boolean mButtonClicked = false; Loading Loading @@ -1294,13 +1293,14 @@ public class MediaControlPanel { mMediaViewHolder.getTurbulenceNoiseView(); int width = targetView.getWidth(); int height = targetView.getHeight(); Random random = new Random(); return new TurbulenceNoiseAnimationConfig( /* gridCount= */ 2.14f, TurbulenceNoiseAnimationConfig.DEFAULT_LUMINOSITY_MULTIPLIER, /* noiseOffsetX= */ mRandom.nextFloat(), /* noiseOffsetY= */ mRandom.nextFloat(), /* noiseOffsetZ= */ mRandom.nextFloat(), /* noiseOffsetX= */ random.nextFloat(), /* noiseOffsetY= */ random.nextFloat(), /* noiseOffsetZ= */ random.nextFloat(), /* noiseMoveSpeedX= */ 0.42f, /* noiseMoveSpeedY= */ 0f, TurbulenceNoiseAnimationConfig.DEFAULT_NOISE_SPEED_Z, Loading packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseControllerTest.kt +24 −0 Original line number Diff line number Diff line Loading @@ -166,4 +166,28 @@ class TurbulenceNoiseControllerTest : SysuiTestCase() { assertThat(config.color).isEqualTo(expectedColor) } } @Test fun play_initializesShader() { val expectedNoiseOffset = floatArrayOf(0.1f, 0.2f, 0.3f) val config = TurbulenceNoiseAnimationConfig( noiseOffsetX = expectedNoiseOffset[0], noiseOffsetY = expectedNoiseOffset[1], noiseOffsetZ = expectedNoiseOffset[2] ) val turbulenceNoiseView = TurbulenceNoiseView(context, null) val turbulenceNoiseController = TurbulenceNoiseController(turbulenceNoiseView) fakeExecutor.execute { turbulenceNoiseController.play(SIMPLEX_NOISE, config) assertThat(turbulenceNoiseView.noiseConfig).isNotNull() val shader = turbulenceNoiseView.turbulenceNoiseShader!! assertThat(shader).isNotNull() assertThat(shader.noiseOffsetX).isEqualTo(expectedNoiseOffset[0]) assertThat(shader.noiseOffsetY).isEqualTo(expectedNoiseOffset[1]) assertThat(shader.noiseOffsetZ).isEqualTo(expectedNoiseOffset[2]) } } } Loading
packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseController.kt +1 −9 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.systemui.surfaceeffects.turbulencenoise import android.view.View import androidx.annotation.VisibleForTesting import java.util.Random /** Plays [TurbulenceNoiseView] in ease-in, main (no easing), and ease-out order. */ class TurbulenceNoiseController(private val turbulenceNoiseView: TurbulenceNoiseView) { Loading @@ -37,8 +36,6 @@ class TurbulenceNoiseController(private val turbulenceNoiseView: TurbulenceNoise } } private val random = Random() /** Current state of the animation. */ @VisibleForTesting var state: AnimationState = AnimationState.NOT_PLAYING Loading Loading @@ -95,12 +92,7 @@ class TurbulenceNoiseController(private val turbulenceNoiseView: TurbulenceNoise } state = AnimationState.EASE_IN // Add offset to avoid repetitive noise. turbulenceNoiseView.playEaseIn( offsetX = random.nextFloat(), offsetY = random.nextFloat(), this::playMainAnimation ) turbulenceNoiseView.playEaseIn(this::playMainAnimation) } private fun playMainAnimation() { Loading
packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseView.kt +3 −3 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ class TurbulenceNoiseView(context: Context?, attrs: AttributeSet?) : View(contex /** Plays the turbulence noise with linear ease-in. */ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) fun playEaseIn(offsetX: Float = 0f, offsetY: Float = 0f, onAnimationEnd: Runnable? = null) { fun playEaseIn(onAnimationEnd: Runnable? = null) { if (noiseConfig == null) { return } Loading @@ -129,8 +129,8 @@ class TurbulenceNoiseView(context: Context?, attrs: AttributeSet?) : View(contex val progress = updateListener.animatedValue as Float shader.setNoiseMove( offsetX + initialX + timeInSec * config.noiseMoveSpeedX, offsetY + initialY + timeInSec * config.noiseMoveSpeedY, initialX + timeInSec * config.noiseMoveSpeedX, initialY + timeInSec * config.noiseMoveSpeedY, initialZ + timeInSec * config.noiseMoveSpeedZ ) Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaControlPanel.java +4 −4 Original line number Diff line number Diff line Loading @@ -260,7 +260,6 @@ public class MediaControlPanel { private TurbulenceNoiseController mTurbulenceNoiseController; private LoadingEffect mLoadingEffect; private final GlobalSettings mGlobalSettings; private final Random mRandom = new Random(); private TurbulenceNoiseAnimationConfig mTurbulenceNoiseAnimationConfig; private boolean mWasPlaying = false; private boolean mButtonClicked = false; Loading Loading @@ -1294,13 +1293,14 @@ public class MediaControlPanel { mMediaViewHolder.getTurbulenceNoiseView(); int width = targetView.getWidth(); int height = targetView.getHeight(); Random random = new Random(); return new TurbulenceNoiseAnimationConfig( /* gridCount= */ 2.14f, TurbulenceNoiseAnimationConfig.DEFAULT_LUMINOSITY_MULTIPLIER, /* noiseOffsetX= */ mRandom.nextFloat(), /* noiseOffsetY= */ mRandom.nextFloat(), /* noiseOffsetZ= */ mRandom.nextFloat(), /* noiseOffsetX= */ random.nextFloat(), /* noiseOffsetY= */ random.nextFloat(), /* noiseOffsetZ= */ random.nextFloat(), /* noiseMoveSpeedX= */ 0.42f, /* noiseMoveSpeedY= */ 0f, TurbulenceNoiseAnimationConfig.DEFAULT_NOISE_SPEED_Z, Loading
packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/turbulencenoise/TurbulenceNoiseControllerTest.kt +24 −0 Original line number Diff line number Diff line Loading @@ -166,4 +166,28 @@ class TurbulenceNoiseControllerTest : SysuiTestCase() { assertThat(config.color).isEqualTo(expectedColor) } } @Test fun play_initializesShader() { val expectedNoiseOffset = floatArrayOf(0.1f, 0.2f, 0.3f) val config = TurbulenceNoiseAnimationConfig( noiseOffsetX = expectedNoiseOffset[0], noiseOffsetY = expectedNoiseOffset[1], noiseOffsetZ = expectedNoiseOffset[2] ) val turbulenceNoiseView = TurbulenceNoiseView(context, null) val turbulenceNoiseController = TurbulenceNoiseController(turbulenceNoiseView) fakeExecutor.execute { turbulenceNoiseController.play(SIMPLEX_NOISE, config) assertThat(turbulenceNoiseView.noiseConfig).isNotNull() val shader = turbulenceNoiseView.turbulenceNoiseShader!! assertThat(shader).isNotNull() assertThat(shader.noiseOffsetX).isEqualTo(expectedNoiseOffset[0]) assertThat(shader.noiseOffsetY).isEqualTo(expectedNoiseOffset[1]) assertThat(shader.noiseOffsetZ).isEqualTo(expectedNoiseOffset[2]) } } }