diff options
| author | Ming-Shin Lu <lumark@google.com> | 2020-03-27 23:51:56 +0800 |
|---|---|---|
| committer | Ming-Shin Lu <lumark@google.com> | 2020-04-07 21:21:59 +0800 |
| commit | b6d7002f365d92010c1d55910d7a231c82820314 (patch) | |
| tree | df37708f90e1d56d03a023a00029b8dd6c326f90 /core/java/android/app/ActivityOptions.java | |
| parent | f0059d21c775fd94291451b1aa5272f86da99e7d (diff) | |
Add test APIs for makeCustomAnimation
For CTS to verify activity custom transition duration
with onAnimationStartedListener / onAnimationFinishedListener
in ActivityOptions
Bug: 150443017
Test: build, atest ActivityTransitionTests
Change-Id: I603ab60a65343f3f336b311064ad55b01ead4929
Diffstat (limited to 'core/java/android/app/ActivityOptions.java')
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 7fd0211215c5..9833536a510b 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -22,6 +22,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.Display.INVALID_DISPLAY; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.TestApi; @@ -369,7 +370,7 @@ public class ActivityOptions { */ public static ActivityOptions makeCustomAnimation(Context context, int enterResId, int exitResId) { - return makeCustomAnimation(context, enterResId, exitResId, null, null); + return makeCustomAnimation(context, enterResId, exitResId, null, null, null); } /** @@ -404,6 +405,38 @@ public class ActivityOptions { } /** + * Create an ActivityOptions specifying a custom animation to run when + * the activity is displayed. + * + * @param context Who is defining this. This is the application that the + * animation resources will be loaded from. + * @param enterResId A resource ID of the animation resource to use for + * the incoming activity. Use 0 for no animation. + * @param exitResId A resource ID of the animation resource to use for + * the outgoing activity. Use 0 for no animation. + * @param handler If <var>listener</var> is non-null this must be a valid + * Handler on which to dispatch the callback; otherwise it should be null. + * @param startedListener Optional OnAnimationStartedListener to find out when the + * requested animation has started running. If for some reason the animation + * is not executed, the callback will happen immediately. + * @param finishedListener Optional OnAnimationFinishedListener when the animation + * has finished running. + * @return Returns a new ActivityOptions object that you can use to + * supply these options as the options Bundle when starting an activity. + * @hide + */ + @TestApi + public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context, + int enterResId, int exitResId, @Nullable Handler handler, + @Nullable OnAnimationStartedListener startedListener, + @Nullable OnAnimationFinishedListener finishedListener) { + ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, handler, + startedListener); + opts.setOnAnimationFinishedListener(handler, finishedListener); + return opts; + } + + /** * Creates an ActivityOptions specifying a custom animation to run in place on an existing * activity. * @@ -448,6 +481,7 @@ public class ActivityOptions { * to find out when the given animation has started running. * @hide */ + @TestApi public interface OnAnimationStartedListener { void onAnimationStarted(); } @@ -474,6 +508,7 @@ public class ActivityOptions { * to find out when the given animation has drawn its last frame. * @hide */ + @TestApi public interface OnAnimationFinishedListener { void onAnimationFinished(); } @@ -1089,7 +1124,7 @@ public class ActivityOptions { } /** @hide */ - public IRemoteCallback getOnAnimationStartListener() { + public IRemoteCallback getAnimationStartedListener() { return mAnimationStartedListener; } |
