summaryrefslogtreecommitdiff
path: root/core/java/android/window/SplashScreenView.java
diff options
context:
space:
mode:
authorwilsonshih <wilsonshih@google.com>2022-03-14 17:48:09 +0800
committerwilsonshih <wilsonshih@google.com>2022-03-18 09:44:37 +0800
commit4748ce9e02047d3ee6962a6e9cfed6729f0ddd45 (patch)
tree257bb8bd291d5b7016c7e6ac34261be6b129d020 /core/java/android/window/SplashScreenView.java
parenta56e6c1f97f0ee8ca03a55d5e8243665c6ea1299 (diff)
Deprecating windowSplashScreenAnimationDuration attr.
In previous CL(5e0c72a2c593de712debf7294e39fb36553a2b30) we provide a way to read the animation duration from AVD and AnimationDrawable, which should be enough to deprecate this attribute since the naming could confusing developers. The attribute was used to cut off the animation if the icon is animatable, but since the animation can be stop when removing the splash screen view from window, the attribute is useless so framework won't read it anymore. The attribute was also be the return value from SplashScreenView#getIconAnimationDuration, however, since this API was designed to let developer decide when to cut off the animation if the app want to handle OnExitAnimationListener#onSplashScreenExit, developer can pre-decide the duration in the app without set this attribute. Bug: 211707095 Test: atest SplashscreenTests StartingSurfaceDrawerTests Change-Id: Ib3a0b4314bd15158c392e56c0e125a33c753e716
Diffstat (limited to 'core/java/android/window/SplashScreenView.java')
-rw-r--r--core/java/android/window/SplashScreenView.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/core/java/android/window/SplashScreenView.java b/core/java/android/window/SplashScreenView.java
index 10d7ecab4ffa..19ee1d046184 100644
--- a/core/java/android/window/SplashScreenView.java
+++ b/core/java/android/window/SplashScreenView.java
@@ -233,14 +233,6 @@ public final class SplashScreenView extends FrameLayout {
}
/**
- * Set the animation duration if icon is animatable.
- */
- public Builder setAnimationDurationMillis(long duration) {
- mIconAnimationDuration = Duration.ofMillis(duration);
- return this;
- }
-
- /**
* Set the Runnable that can receive the task which should be executed on UI thread.
* @param uiThreadInitTask
*/
@@ -294,8 +286,7 @@ public final class SplashScreenView extends FrameLayout {
} else {
view.mIconView = createSurfaceView(view);
}
- view.initIconAnimation(mIconDrawable,
- mIconAnimationDuration != null ? mIconAnimationDuration.toMillis() : 0);
+ view.initIconAnimation(mIconDrawable);
view.mIconAnimationStart = mIconAnimationStart;
view.mIconAnimationDuration = mIconAnimationDuration;
} else if (mIconSize != 0) {
@@ -463,6 +454,11 @@ public final class SplashScreenView extends FrameLayout {
/**
* Returns the duration of the icon animation if icon is animatable.
*
+ * Note the return value can be null or 0 if the
+ * {@link android.R.attr#windowSplashScreenAnimatedIcon} is not
+ * {@link android.graphics.drawable.AnimationDrawable} or
+ * {@link android.graphics.drawable.AnimatedVectorDrawable}.
+ *
* @see android.R.attr#windowSplashScreenAnimatedIcon
* @see android.R.attr#windowSplashScreenAnimationDuration
*/
@@ -497,12 +493,12 @@ public final class SplashScreenView extends FrameLayout {
mSurfaceView.setChildSurfacePackage(mSurfacePackage);
}
- void initIconAnimation(Drawable iconDrawable, long duration) {
+ void initIconAnimation(Drawable iconDrawable) {
if (!(iconDrawable instanceof IconAnimateListener)) {
return;
}
IconAnimateListener aniDrawable = (IconAnimateListener) iconDrawable;
- aniDrawable.prepareAnimate(duration, this::animationStartCallback);
+ aniDrawable.prepareAnimate(this::animationStartCallback);
aniDrawable.setAnimationJankMonitoring(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
@@ -524,7 +520,7 @@ public final class SplashScreenView extends FrameLayout {
private void animationStartCallback(long animDuration) {
mIconAnimationStart = Instant.now();
- if (animDuration > 0) {
+ if (animDuration >= 0) {
mIconAnimationDuration = Duration.ofMillis(animDuration);
}
}
@@ -695,10 +691,9 @@ public final class SplashScreenView extends FrameLayout {
public interface IconAnimateListener {
/**
* Prepare the animation if this drawable also be animatable.
- * @param duration The animation duration.
* @param startListener The callback listener used to receive the start of the animation.
*/
- void prepareAnimate(long duration, LongConsumer startListener);
+ void prepareAnimate(LongConsumer startListener);
/**
* Stop animation.