diff --git a/core/api/current.txt b/core/api/current.txt index 5df78714be989..db0d581cdc04c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -1755,7 +1755,7 @@ package android { field public static final int windowShowWallpaper = 16843410; // 0x1010292 field public static final int windowSoftInputMode = 16843307; // 0x101022b field public static final int windowSplashScreenAnimatedIcon = 16844333; // 0x101062d - field public static final int windowSplashScreenAnimationDuration = 16844334; // 0x101062e + field @Deprecated public static final int windowSplashScreenAnimationDuration = 16844334; // 0x101062e field public static final int windowSplashScreenBackground = 16844332; // 0x101062c field public static final int windowSplashScreenBehavior; field public static final int windowSplashScreenBrandingImage = 16844335; // 0x101062f diff --git a/core/java/android/window/SplashScreenView.java b/core/java/android/window/SplashScreenView.java index 10d7ecab4ffa9..19ee1d0461849 100644 --- a/core/java/android/window/SplashScreenView.java +++ b/core/java/android/window/SplashScreenView.java @@ -232,14 +232,6 @@ public final class SplashScreenView extends FrameLayout { return this; } - /** - * 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. diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 2107f651eade6..2295090b66164 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2322,7 +2322,9 @@ + be limited below 1000ms. + @deprecated Not used by framework starting from API level 33. The system estimates the + duration of the vector animation automatically. -->