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

Commit 4a2efa1a authored by Michael Jurka's avatar Michael Jurka Committed by Android Git Automerger
Browse files

am 76070ed3: am d2ae85d4: Merge "Adding a thumbnail scale down animation" into jb-mr1-dev

* commit '76070ed3':
  Adding a thumbnail scale down animation
parents 240c53b7 76070ed3
Loading
Loading
Loading
Loading
+20 −21
Original line number Diff line number Diff line
@@ -97,9 +97,9 @@ public class ActivityOptions {
    /** @hide */
    public static final int ANIM_SCALE_UP = 2;
    /** @hide */
    public static final int ANIM_THUMBNAIL = 3;
    public static final int ANIM_THUMBNAIL_SCALE_UP = 3;
    /** @hide */
    public static final int ANIM_THUMBNAIL_DELAYED = 4;
    public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4;

    private String mPackageName;
    private int mAnimationType = ANIM_NONE;
@@ -262,20 +262,19 @@ public class ActivityOptions {
     */
    public static ActivityOptions makeThumbnailScaleUpAnimation(View source,
            Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) {
        return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, listener, false);
        return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, true);
    }

    /**
     * Create an ActivityOptions specifying an animation where a thumbnail
     * is scaled from a given position to the new activity window that is
     * being started. Before the animation, there is a short delay.
     * Create an ActivityOptions specifying an animation where an activity window
     * is scaled from a given position to a thumbnail at a specified location.
     *
     * @param source The View that this thumbnail is animating from.  This
     * @param source The View that this thumbnail is animating to.  This
     * defines the coordinate space for <var>startX</var> and <var>startY</var>.
     * @param thumbnail The bitmap that will be shown as the initial thumbnail
     * @param thumbnail The bitmap that will be shown as the final thumbnail
     * of the animation.
     * @param startX The x starting location of the bitmap, relative to <var>source</var>.
     * @param startY The y starting location of the bitmap, relative to <var>source</var>.
     * @param startX The x end location of the bitmap, relative to <var>source</var>.
     * @param startY The y end location of the bitmap, relative to <var>source</var>.
     * @param listener 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.
@@ -283,17 +282,17 @@ public class ActivityOptions {
     * supply these options as the options Bundle when starting an activity.
     * @hide
     */
    public static ActivityOptions makeDelayedThumbnailScaleUpAnimation(View source,
    public static ActivityOptions makeThumbnailScaleDownAnimation(View source,
            Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) {
        return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, listener, true);
        return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, false);
    }

    private static ActivityOptions makeThumbnailScaleUpAnimation(View source,
    private static ActivityOptions makeThumbnailAnimation(View source,
            Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener,
            boolean delayed) {
            boolean scaleUp) {
        ActivityOptions opts = new ActivityOptions();
        opts.mPackageName = source.getContext().getPackageName();
        opts.mAnimationType = delayed ? ANIM_THUMBNAIL_DELAYED : ANIM_THUMBNAIL;
        opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN;
        opts.mThumbnail = thumbnail;
        int[] pts = new int[2];
        source.getLocationOnScreen(pts);
@@ -320,8 +319,8 @@ public class ActivityOptions {
            mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
            mStartWidth = opts.getInt(KEY_ANIM_START_WIDTH, 0);
            mStartHeight = opts.getInt(KEY_ANIM_START_HEIGHT, 0);
        } else if (mAnimationType == ANIM_THUMBNAIL ||
                mAnimationType == ANIM_THUMBNAIL_DELAYED) {
        } else if (mAnimationType == ANIM_THUMBNAIL_SCALE_UP ||
                mAnimationType == ANIM_THUMBNAIL_SCALE_DOWN) {
            mThumbnail = (Bitmap)opts.getParcelable(KEY_ANIM_THUMBNAIL);
            mStartX = opts.getInt(KEY_ANIM_START_X, 0);
            mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
@@ -434,8 +433,8 @@ public class ActivityOptions {
                }
                mAnimationStartedListener = null;
                break;
            case ANIM_THUMBNAIL:
            case ANIM_THUMBNAIL_DELAYED:
            case ANIM_THUMBNAIL_SCALE_UP:
            case ANIM_THUMBNAIL_SCALE_DOWN:
                mAnimationType = otherOptions.mAnimationType;
                mThumbnail = otherOptions.mThumbnail;
                mStartX = otherOptions.mStartX;
@@ -479,8 +478,8 @@ public class ActivityOptions {
                b.putInt(KEY_ANIM_START_WIDTH, mStartWidth);
                b.putInt(KEY_ANIM_START_HEIGHT, mStartHeight);
                break;
            case ANIM_THUMBNAIL:
            case ANIM_THUMBNAIL_DELAYED:
            case ANIM_THUMBNAIL_SCALE_UP:
            case ANIM_THUMBNAIL_SCALE_DOWN:
                b.putInt(KEY_ANIM_TYPE, mAnimationType);
                b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
                b.putInt(KEY_ANIM_START_X, mStartX);
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ interface IWindowManager
    void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
            int startHeight);
    void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY,
            IRemoteCallback startedCallback, boolean delayed);
            IRemoteCallback startedCallback, boolean scaleUp);
    void executeAppTransition();
    void setAppStartingWindow(IBinder token, String pkg, int theme,
            in CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes,
+1 −1
Original line number Diff line number Diff line
@@ -767,7 +767,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        show(false, true);

        mThumbnailScaleUpStarted = false;
        ActivityOptions opts = ActivityOptions.makeDelayedThumbnailScaleUpAnimation(
        ActivityOptions opts = ActivityOptions.makeThumbnailScaleUpAnimation(
                holder.thumbnailViewImage, bm, 0, 0,
                new ActivityOptions.OnAnimationStartedListener() {
                    @Override public void onAnimationStarted() {
+4 −4
Original line number Diff line number Diff line
@@ -614,14 +614,14 @@ final class ActivityRecord {
                                pendingOptions.getStartY()+pendingOptions.getStartHeight()));
                    }
                    break;
                case ActivityOptions.ANIM_THUMBNAIL:
                case ActivityOptions.ANIM_THUMBNAIL_DELAYED:
                    boolean delayed = (animationType == ActivityOptions.ANIM_THUMBNAIL_DELAYED);
                case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
                case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
                    boolean scaleUp = (animationType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
                    service.mWindowManager.overridePendingAppTransitionThumb(
                            pendingOptions.getThumbnail(),
                            pendingOptions.getStartX(), pendingOptions.getStartY(),
                            pendingOptions.getOnAnimationStartListener(),
                            delayed);
                            scaleUp);
                    if (intent.getSourceBounds() == null) {
                        intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
                                pendingOptions.getStartY(),
+91 −53
Original line number Diff line number Diff line
@@ -512,7 +512,8 @@ public class WindowManagerService extends IWindowManager.Stub
    int mNextAppTransitionType = ActivityOptions.ANIM_NONE;
    String mNextAppTransitionPackage;
    Bitmap mNextAppTransitionThumbnail;
    boolean mNextAppTransitionDelayed;
    // Used for thumbnail transitions. True if we're scaling up, false if scaling down
    boolean mNextAppTransitionScaleUp;
    IRemoteCallback mNextAppTransitionCallback;
    int mNextAppTransitionEnter;
    int mNextAppTransitionExit;
@@ -3224,7 +3225,7 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    private Animation createThumbnailAnimationLocked(int transit,
            boolean enter, boolean thumb, boolean delayed) {
            boolean enter, boolean thumb, boolean scaleUp) {
        Animation a;
        final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
        final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
@@ -3234,7 +3235,6 @@ public class WindowManagerService extends IWindowManager.Stub
        // it  is the standard duration for that.  Otherwise we use the longer
        // task transition duration.
        int duration;
        int delayDuration = delayed ? 270 : 0;
        switch (transit) {
            case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
            case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
@@ -3242,7 +3242,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        com.android.internal.R.integer.config_shortAnimTime);
                break;
            default:
                duration = delayed ? 250 : 300;
                duration = 250;
                break;
        }
        // TOOD(multidisplay): For now assume all app animation is on the main screen.
@@ -3250,6 +3250,7 @@ public class WindowManagerService extends IWindowManager.Stub
        if (thumb) {
            // Animation for zooming thumbnail from its initial size to
            // filling the screen.
            if (scaleUp) {
                float scaleW = displayInfo.appWidth / thumbWidth;
                float scaleH = displayInfo.appHeight / thumbHeight;

@@ -3265,12 +3266,29 @@ public class WindowManagerService extends IWindowManager.Stub
                alpha.setDuration(duration);
                set.addAnimation(alpha);
                set.setFillBefore(true);
            if (delayDuration > 0) {
                set.setStartOffset(delayDuration);
            }
                a = set;
            } else {
                float scaleW = displayInfo.appWidth / thumbWidth;
                float scaleH = displayInfo.appHeight / thumbHeight;

                Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
                        computePivot(mNextAppTransitionStartX, 1 / scaleW),
                        computePivot(mNextAppTransitionStartY, 1 / scaleH));
                AnimationSet set = new AnimationSet(true);
                Animation alpha = new AlphaAnimation(1, 1);
                scale.setDuration(duration);
                scale.setInterpolator(
                        new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
                set.addAnimation(scale);
                alpha.setDuration(duration);
                set.addAnimation(alpha);
                set.setFillBefore(true);

                a = set;
            }
        } else if (enter) {
            // Entering app zooms out from the center of the thumbnail.
            if (scaleUp) {
                float scaleW = thumbWidth / displayInfo.appWidth;
                float scaleH = thumbHeight / displayInfo.appHeight;
                Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
@@ -3280,18 +3298,38 @@ public class WindowManagerService extends IWindowManager.Stub
                scale.setInterpolator(
                        new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
                scale.setFillBefore(true);
            if (delayDuration > 0) {
                scale.setStartOffset(delayDuration);
            }
                a = scale;
            } else {
            if (delayed) {
                a = new AlphaAnimation(1, 0);
                a.setStartOffset(0);
                a.setDuration(delayDuration - 120);
                a.setBackgroundColor(0xFF000000);
                // noop animation
                a = new AlphaAnimation(1, 1);
                a.setDuration(duration);
            }
        } else {
                a = createExitAnimationLocked(transit, duration);
            // Exiting app
            if (scaleUp) {
                // noop animation
                a = new AlphaAnimation(1, 1);
                a.setDuration(duration);
            } else {
                float scaleW = thumbWidth / displayInfo.appWidth;
                float scaleH = thumbHeight / displayInfo.appHeight;
                Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
                        computePivot(mNextAppTransitionStartX, scaleW),
                        computePivot(mNextAppTransitionStartY, scaleH));
                scale.setDuration(duration);
                scale.setInterpolator(
                        new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
                scale.setFillBefore(true);
                AnimationSet set = new AnimationSet(true);
                Animation alpha = new AlphaAnimation(1, 0);
                set.addAnimation(scale);
                alpha.setDuration(duration);
                alpha.setInterpolator(new DecelerateInterpolator(
                        THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
                set.addAnimation(alpha);
                set.setFillBefore(true);
                set.setZAdjustment(Animation.ZORDER_TOP);
                a = set;
            }
        }
        a.setFillAfter(true);
@@ -3326,14 +3364,14 @@ public class WindowManagerService extends IWindowManager.Stub
                        "applyAnimation: wtoken=" + wtoken
                        + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
                        + " transit=" + transit + " Callers " + Debug.getCallers(3));
            } else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL ||
                    mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_DELAYED) {
                boolean delayed = (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_DELAYED);
                a = createThumbnailAnimationLocked(transit, enter, false, delayed);
            } else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP ||
                    mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN) {
                boolean scaleUp = (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
                a = createThumbnailAnimationLocked(transit, enter, false, scaleUp);
                initialized = true;

                if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
                    String animName = delayed ? "ANIM_THUMBNAIL_DELAYED" : "ANIM_THUMBNAIL";
                    String animName = scaleUp ? "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
                    Slog.v(TAG, "applyAnimation: wtoken=" + wtoken
                            + " anim=" + a + " nextAppTransition=" + animName
                            + " transit=" + transit + " Callers " + Debug.getCallers(3));
@@ -4008,14 +4046,14 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX,
            int startY, IRemoteCallback startedCallback, boolean delayed) {
            int startY, IRemoteCallback startedCallback, boolean scaleUp) {
        synchronized(mWindowMap) {
            if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
                mNextAppTransitionType = delayed
                        ? ActivityOptions.ANIM_THUMBNAIL_DELAYED : ActivityOptions.ANIM_THUMBNAIL;
                mNextAppTransitionType = scaleUp
                        ? ActivityOptions.ANIM_THUMBNAIL_SCALE_UP : ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN;
                mNextAppTransitionPackage = null;
                mNextAppTransitionThumbnail = srcThumb;
                mNextAppTransitionDelayed = delayed;
                mNextAppTransitionScaleUp = scaleUp;
                mNextAppTransitionStartX = startX;
                mNextAppTransitionStartY = startY;
                scheduleAnimationCallback(mNextAppTransitionCallback);
@@ -8392,7 +8430,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    drawSurface.release();
                    topOpeningApp.mAppAnimator.thumbnailLayer = topOpeningLayer;
                    Animation anim = createThumbnailAnimationLocked(
                            transit, true, true, mNextAppTransitionDelayed);
                            transit, true, true, mNextAppTransitionScaleUp);
                    topOpeningApp.mAppAnimator.thumbnailAnimation = anim;
                    anim.restrictDuration(MAX_ANIMATION_DURATION);
                    anim.scaleCurrentDuration(mTransitionAnimationScale);
@@ -10163,15 +10201,15 @@ public class WindowManagerService extends IWindowManager.Stub
                            pw.print(" mNextAppTransitionStartHeight=");
                            pw.println(mNextAppTransitionStartHeight);
                    break;
                case ActivityOptions.ANIM_THUMBNAIL:
                case ActivityOptions.ANIM_THUMBNAIL_DELAYED:
                case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
                case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
                    pw.print("  mNextAppTransitionThumbnail=");
                            pw.print(mNextAppTransitionThumbnail);
                            pw.print(" mNextAppTransitionStartX=");
                            pw.print(mNextAppTransitionStartX);
                            pw.print(" mNextAppTransitionStartY=");
                            pw.println(mNextAppTransitionStartY);
                    pw.print("  mNextAppTransitionDelayed="); pw.println(mNextAppTransitionDelayed);
                    pw.print("  mNextAppTransitionScaleUp="); pw.println(mNextAppTransitionScaleUp);
                    break;
            }
            if (mNextAppTransitionCallback != null) {
Loading