Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d72672e5 authored by Pablo Gamito's avatar Pablo Gamito Committed by Android (Google) Code Review
Browse files

Merge "Add option to override background color for animation through overridePendingTransition"

parents e139c016 8e3a0e49
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4183,6 +4183,7 @@ package android.app {
    method public void openContextMenu(android.view.View);
    method public void openOptionsMenu();
    method public void overridePendingTransition(int, int);
    method public void overridePendingTransition(int, int, int);
    method public void postponeEnterTransition();
    method public void recreate();
    method public void registerActivityLifecycleCallbacks(@NonNull android.app.Application.ActivityLifecycleCallbacks);
@@ -4486,6 +4487,7 @@ package android.app {
    method public static android.app.ActivityOptions makeBasic();
    method public static android.app.ActivityOptions makeClipRevealAnimation(android.view.View, int, int, int, int);
    method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int);
    method @NonNull public static android.app.ActivityOptions makeCustomAnimation(@NonNull android.content.Context, int, int, int);
    method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int);
    method public static android.app.ActivityOptions makeSceneTransitionAnimation(android.app.Activity, android.view.View, String);
    method @java.lang.SafeVarargs public static android.app.ActivityOptions makeSceneTransitionAnimation(android.app.Activity, android.util.Pair<android.view.View,java.lang.String>...);
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ package android.app {

  public class ActivityOptions {
    method @NonNull public static android.app.ActivityOptions fromBundle(@NonNull android.os.Bundle);
    method @NonNull public static android.app.ActivityOptions makeCustomAnimation(@NonNull android.content.Context, int, int, @Nullable android.os.Handler, @Nullable android.app.ActivityOptions.OnAnimationStartedListener, @Nullable android.app.ActivityOptions.OnAnimationFinishedListener);
    method @NonNull public static android.app.ActivityOptions makeCustomAnimation(@NonNull android.content.Context, int, int, int, @Nullable android.os.Handler, @Nullable android.app.ActivityOptions.OnAnimationStartedListener, @Nullable android.app.ActivityOptions.OnAnimationFinishedListener);
    method @NonNull @RequiresPermission(android.Manifest.permission.START_TASKS_FROM_RECENTS) public static android.app.ActivityOptions makeCustomTaskAnimation(@NonNull android.content.Context, int, int, @Nullable android.os.Handler, @Nullable android.app.ActivityOptions.OnAnimationStartedListener, @Nullable android.app.ActivityOptions.OnAnimationFinishedListener);
    method public static void setExitTransitionTimeout(long);
    method public void setLaunchActivityType(int);
+25 −2
Original line number Diff line number Diff line
@@ -6131,8 +6131,31 @@ public class Activity extends ContextThemeWrapper
     * the outgoing activity.  Use 0 for no animation.
     */
    public void overridePendingTransition(int enterAnim, int exitAnim) {
        ActivityClient.getInstance().overridePendingTransition(mToken, getPackageName(),
                enterAnim, exitAnim);
        overridePendingTransition(enterAnim, exitAnim, 0);
    }

    /**
     * Call immediately after one of the flavors of {@link #startActivity(Intent)}
     * or {@link #finish} to specify an explicit transition animation to
     * perform next.
     *
     * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN} an alternative
     * to using this with starting activities is to supply the desired animation
     * information through a {@link ActivityOptions} bundle to
     * {@link #startActivity(Intent, Bundle)} or a related function.  This allows
     * you to specify a custom animation even when starting an activity from
     * outside the context of the current top activity.
     *
     * @param enterAnim A resource ID of the animation resource to use for
     * the incoming activity.  Use 0 for no animation.
     * @param exitAnim A resource ID of the animation resource to use for
     * the outgoing activity.  Use 0 for no animation.
     * @param backgroundColor The background color to use for the background during the animation if
     * the animation requires a background. Set to 0 to not override the default color.
     */
    public void overridePendingTransition(int enterAnim, int exitAnim, int backgroundColor) {
        ActivityClient.getInstance().overridePendingTransition(mToken, getPackageName(), enterAnim,
                exitAnim, backgroundColor);
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -428,11 +428,11 @@ public class ActivityClient {
        }
    }

    void overridePendingTransition(IBinder token, String packageName,
            int enterAnim, int exitAnim) {
    void overridePendingTransition(IBinder token, String packageName, int enterAnim, int exitAnim,
            int backgroundColor) {
        try {
            getActivityClientController().overridePendingTransition(token, packageName,
                    enterAnim, exitAnim);
                    enterAnim, exitAnim, backgroundColor);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
+43 −7
Original line number Diff line number Diff line
@@ -125,6 +125,12 @@ public class ActivityOptions extends ComponentOptions {
     */
    public static final String KEY_ANIM_IN_PLACE_RES_ID = "android:activity.animInPlaceRes";

    /**
     * Custom background color for animation.
     * @hide
     */
    public static final String KEY_ANIM_BACKGROUND_COLOR = "android:activity.backgroundColor";

    /**
     * Bitmap for thumbnail animation.
     * @hide
@@ -389,6 +395,7 @@ public class ActivityOptions extends ComponentOptions {
    private int mCustomEnterResId;
    private int mCustomExitResId;
    private int mCustomInPlaceResId;
    private int mCustomBackgroundColor;
    private Bitmap mThumbnail;
    private int mStartX;
    private int mStartY;
@@ -453,7 +460,27 @@ public class ActivityOptions extends ComponentOptions {
     */
    public static ActivityOptions makeCustomAnimation(Context context,
            int enterResId, int exitResId) {
        return makeCustomAnimation(context, enterResId, exitResId, null, null, null);
        return makeCustomAnimation(context, enterResId, exitResId, 0, null, null);
    }

    /**
     * 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 backgroundColor The background color to use for the background during the animation if
     * the animation requires a background. Set to 0 to not override the default color.
     * @return Returns a new ActivityOptions object that you can use to
     * supply these options as the options Bundle when starting an activity.
     */
    public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context,
            int enterResId, int exitResId, int backgroundColor) {
        return makeCustomAnimation(context, enterResId, exitResId, backgroundColor, null, null);
    }

    /**
@@ -477,12 +504,14 @@ public class ActivityOptions extends ComponentOptions {
     */
    @UnsupportedAppUsage
    public static ActivityOptions makeCustomAnimation(Context context,
            int enterResId, int exitResId, Handler handler, OnAnimationStartedListener listener) {
            int enterResId, int exitResId, int backgroundColor, Handler handler,
            OnAnimationStartedListener listener) {
        ActivityOptions opts = new ActivityOptions();
        opts.mPackageName = context.getPackageName();
        opts.mAnimationType = ANIM_CUSTOM;
        opts.mCustomEnterResId = enterResId;
        opts.mCustomExitResId = exitResId;
        opts.mCustomBackgroundColor = backgroundColor;
        opts.setOnAnimationStartedListener(handler, listener);
        return opts;
    }
@@ -510,11 +539,11 @@ public class ActivityOptions extends ComponentOptions {
     */
    @TestApi
    public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context,
            int enterResId, int exitResId, @Nullable Handler handler,
            int enterResId, int exitResId, int backgroundColor, @Nullable Handler handler,
            @Nullable OnAnimationStartedListener startedListener,
            @Nullable OnAnimationFinishedListener finishedListener) {
        ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, handler,
                startedListener);
        ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, backgroundColor,
                handler, startedListener);
        opts.setOnAnimationFinishedListener(handler, finishedListener);
        return opts;
    }
@@ -547,8 +576,8 @@ public class ActivityOptions extends ComponentOptions {
            int enterResId, int exitResId, @Nullable Handler handler,
            @Nullable OnAnimationStartedListener startedListener,
            @Nullable OnAnimationFinishedListener finishedListener) {
        ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, handler,
                startedListener, finishedListener);
        ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, 0,
                handler, startedListener, finishedListener);
        opts.mOverrideTaskTransition = true;
        return opts;
    }
@@ -1243,6 +1272,11 @@ public class ActivityOptions extends ComponentOptions {
        return mCustomInPlaceResId;
    }

    /** @hide */
    public int getCustomBackgroundColor() {
        return mCustomBackgroundColor;
    }

    /**
     * The thumbnail is copied into a hardware bitmap when it is bundled and sent to the system, so
     * it should always be backed by a HardwareBuffer on the other end.
@@ -1775,6 +1809,7 @@ public class ActivityOptions extends ComponentOptions {
            case ANIM_CUSTOM:
                mCustomEnterResId = otherOptions.mCustomEnterResId;
                mCustomExitResId = otherOptions.mCustomExitResId;
                mCustomBackgroundColor = otherOptions.mCustomBackgroundColor;
                mThumbnail = null;
                if (mAnimationStartedListener != null) {
                    try {
@@ -1862,6 +1897,7 @@ public class ActivityOptions extends ComponentOptions {
            case ANIM_CUSTOM:
                b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId);
                b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId);
                b.putInt(KEY_ANIM_BACKGROUND_COLOR, mCustomBackgroundColor);
                b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
                        != null ? mAnimationStartedListener.asBinder() : null);
                break;
Loading