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

Commit 2e7f3bdc authored by Winson Chung's avatar Winson Chung
Browse files

Removing unnecessary delays, ensuring transition thumbnail is the size of the...

Removing unnecessary delays, ensuring transition thumbnail is the size of the header. (Bug. 16987565)

Change-Id: Ic104876c5fe16997eca00e0a2b3d8644c927120c
parent d78d4f3a
Loading
Loading
Loading
Loading
+37 −26
Original line number Diff line number Diff line
@@ -84,13 +84,13 @@ public class ActivityOptions {
     * Initial width of the animation.
     * @hide
     */
    public static final String KEY_ANIM_START_WIDTH = "android:animStartWidth";
    public static final String KEY_ANIM_WIDTH = "android:animWidth";

    /**
     * Initial height of the animation.
     * @hide
     */
    public static final String KEY_ANIM_START_HEIGHT = "android:animStartHeight";
    public static final String KEY_ANIM_HEIGHT = "android:animHeight";

    /**
     * Callback for when animation is started.
@@ -140,8 +140,8 @@ public class ActivityOptions {
    private Bitmap mThumbnail;
    private int mStartX;
    private int mStartY;
    private int mStartWidth;
    private int mStartHeight;
    private int mWidth;
    private int mHeight;
    private IRemoteCallback mAnimationStartedListener;
    private ResultReceiver mTransitionReceiver;
    private boolean mIsReturning;
@@ -238,13 +238,13 @@ public class ActivityOptions {
     * defines the coordinate space for <var>startX</var> and <var>startY</var>.
     * @param startX The x starting location of the new activity, relative to <var>source</var>.
     * @param startY The y starting location of the activity, relative to <var>source</var>.
     * @param startWidth The initial width of the new activity.
     * @param startHeight The initial height of the new activity.
     * @param width The initial width of the new activity.
     * @param height The initial height of the new activity.
     * @return Returns a new ActivityOptions object that you can use to
     * supply these options as the options Bundle when starting an activity.
     */
    public static ActivityOptions makeScaleUpAnimation(View source,
            int startX, int startY, int startWidth, int startHeight) {
            int startX, int startY, int width, int height) {
        ActivityOptions opts = new ActivityOptions();
        opts.mPackageName = source.getContext().getPackageName();
        opts.mAnimationType = ANIM_SCALE_UP;
@@ -252,8 +252,8 @@ public class ActivityOptions {
        source.getLocationOnScreen(pts);
        opts.mStartX = pts[0] + startX;
        opts.mStartY = pts[1] + startY;
        opts.mStartWidth = startWidth;
        opts.mStartHeight = startHeight;
        opts.mWidth = width;
        opts.mHeight = height;
        return opts;
    }

@@ -359,9 +359,10 @@ public class ActivityOptions {
     * @hide
     */
    public static ActivityOptions makeThumbnailAspectScaleUpAnimation(View source,
            Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) {
        return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, listener,
                true);
            Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight,
            OnAnimationStartedListener listener) {
        return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY,
                targetWidth, targetHeight, listener, true);
    }

    /**
@@ -382,13 +383,15 @@ public class ActivityOptions {
     * @hide
     */
    public static ActivityOptions makeThumbnailAspectScaleDownAnimation(View source,
            Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) {
        return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, listener,
                false);
            Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight,
            OnAnimationStartedListener listener) {
        return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY,
                targetWidth, targetHeight, listener, false);
    }

    private static ActivityOptions makeAspectScaledThumbnailAnimation(View source, Bitmap thumbnail,
            int startX, int startY, OnAnimationStartedListener listener, boolean scaleUp) {
            int startX, int startY, int targetWidth, int targetHeight,
            OnAnimationStartedListener listener, boolean scaleUp) {
        ActivityOptions opts = new ActivityOptions();
        opts.mPackageName = source.getContext().getPackageName();
        opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_ASPECT_SCALE_UP :
@@ -398,6 +401,8 @@ public class ActivityOptions {
        source.getLocationOnScreen(pts);
        opts.mStartX = pts[0] + startX;
        opts.mStartY = pts[1] + startY;
        opts.mWidth = targetWidth;
        opts.mHeight = targetHeight;
        opts.setOnAnimationStartedListener(source.getHandler(), listener);
        return opts;
    }
@@ -543,8 +548,8 @@ public class ActivityOptions {
            case ANIM_SCALE_UP:
                mStartX = opts.getInt(KEY_ANIM_START_X, 0);
                mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
                mStartWidth = opts.getInt(KEY_ANIM_START_WIDTH, 0);
                mStartHeight = opts.getInt(KEY_ANIM_START_HEIGHT, 0);
                mWidth = opts.getInt(KEY_ANIM_WIDTH, 0);
                mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0);
                break;

            case ANIM_THUMBNAIL_SCALE_UP:
@@ -554,6 +559,8 @@ public class ActivityOptions {
                mThumbnail = (Bitmap) opts.getParcelable(KEY_ANIM_THUMBNAIL);
                mStartX = opts.getInt(KEY_ANIM_START_X, 0);
                mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
                mWidth = opts.getInt(KEY_ANIM_WIDTH, 0);
                mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0);
                mAnimationStartedListener = IRemoteCallback.Stub.asInterface(
                        opts.getBinder(KEY_ANIM_START_LISTENER));
                break;
@@ -605,13 +612,13 @@ public class ActivityOptions {
    }

    /** @hide */
    public int getStartWidth() {
        return mStartWidth;
    public int getWidth() {
        return mWidth;
    }

    /** @hide */
    public int getStartHeight() {
        return mStartHeight;
    public int getHeight() {
        return mHeight;
    }

    /** @hide */
@@ -690,8 +697,8 @@ public class ActivityOptions {
            case ANIM_SCALE_UP:
                mStartX = otherOptions.mStartX;
                mStartY = otherOptions.mStartY;
                mStartWidth = otherOptions.mStartWidth;
                mStartHeight = otherOptions.mStartHeight;
                mWidth = otherOptions.mWidth;
                mHeight = otherOptions.mHeight;
                if (mAnimationStartedListener != null) {
                    try {
                        mAnimationStartedListener.sendResult(null);
@@ -707,6 +714,8 @@ public class ActivityOptions {
                mThumbnail = otherOptions.mThumbnail;
                mStartX = otherOptions.mStartX;
                mStartY = otherOptions.mStartY;
                mWidth = otherOptions.mWidth;
                mHeight = otherOptions.mHeight;
                if (mAnimationStartedListener != null) {
                    try {
                        mAnimationStartedListener.sendResult(null);
@@ -755,8 +764,8 @@ public class ActivityOptions {
            case ANIM_SCALE_UP:
                b.putInt(KEY_ANIM_START_X, mStartX);
                b.putInt(KEY_ANIM_START_Y, mStartY);
                b.putInt(KEY_ANIM_START_WIDTH, mStartWidth);
                b.putInt(KEY_ANIM_START_HEIGHT, mStartHeight);
                b.putInt(KEY_ANIM_WIDTH, mWidth);
                b.putInt(KEY_ANIM_HEIGHT, mHeight);
                break;
            case ANIM_THUMBNAIL_SCALE_UP:
            case ANIM_THUMBNAIL_SCALE_DOWN:
@@ -765,6 +774,8 @@ public class ActivityOptions {
                b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
                b.putInt(KEY_ANIM_START_X, mStartX);
                b.putInt(KEY_ANIM_START_Y, mStartY);
                b.putInt(KEY_ANIM_WIDTH, mWidth);
                b.putInt(KEY_ANIM_HEIGHT, mHeight);
                b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
                        != null ? mAnimationStartedListener.asBinder() : null);
                break;
+2 −1
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ interface IWindowManager
    void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY,
            IRemoteCallback startedCallback, boolean scaleUp);
    void overridePendingAppTransitionAspectScaledThumb(in Bitmap srcThumb, int startX,
            int startY, IRemoteCallback startedCallback, boolean scaleUp);
            int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback,
            boolean scaleUp);
    void executeAppTransition();
    void setAppStartingWindow(IBinder token, String pkg, int theme,
            in CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes,
+5 −4
Original line number Diff line number Diff line
@@ -385,9 +385,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
                toTask);
        if (toTransform != null && toTask.key != null) {
            Rect toTaskRect = toTransform.rect;

            // XXX: Reduce the memory usage the to the task bar height
            Bitmap thumbnail = Bitmap.createBitmap(toTaskRect.width(), toTaskRect.height(),
            int toHeaderWidth = (int) (mHeaderBar.getMeasuredWidth() * toTransform.scale);
            int toHeaderHeight = (int) (mHeaderBar.getMeasuredHeight() * toTransform.scale);
            Bitmap thumbnail = Bitmap.createBitmap(toHeaderWidth, toHeaderHeight,
                    Bitmap.Config.ARGB_8888);
            if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) {
                thumbnail.eraseColor(0xFFff0000);
@@ -401,7 +401,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta

            mStartAnimationTriggered = false;
            return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mStatusBarView,
                    thumbnail, toTaskRect.left, toTaskRect.top, this);
                    thumbnail, toTaskRect.left, toTaskRect.top, toTaskRect.width(),
                    toTaskRect.height(), this);
        }

        // If both the screenshot and thumbnail fails, then just fall back to the default transition
+10 −7
Original line number Diff line number Diff line
@@ -413,10 +413,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
        final SystemServicesProxy ssp =
                RecentsTaskLoader.getInstance().getSystemServicesProxy();
        ActivityOptions opts = null;
        int thumbnailWidth = transform.rect.width();
        int thumbnailHeight = transform.rect.height();
        if (task.thumbnail != null && thumbnailWidth > 0 && thumbnailHeight > 0 &&
                task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
        if (task.thumbnail != null && task.thumbnail.getWidth() > 0 &&
                task.thumbnail.getHeight() > 0) {
            Bitmap b;
            if (tv != null) {
                // Disable any focused state before we draw the header
@@ -424,7 +422,11 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                    tv.unsetFocusedTask();
                }

                b = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ARGB_8888);
                float scale = tv.getScaleX();
                int fromHeaderWidth = (int) (tv.mHeaderView.getMeasuredWidth() * scale);
                int fromHeaderHeight = (int) (tv.mHeaderView.getMeasuredHeight() * scale);
                b = Bitmap.createBitmap(fromHeaderWidth, fromHeaderHeight,
                        Bitmap.Config.ARGB_8888);
                if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) {
                    b.eraseColor(0xFFff0000);
                } else {
@@ -435,7 +437,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                }
            } else {
                // Notify the system to skip the thumbnail layer by using an ALPHA_8 bitmap
                b = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ALPHA_8);
                b = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
            }
            ActivityOptions.OnAnimationStartedListener animStartedListener = null;
            if (lockToTask) {
@@ -456,7 +458,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                };
            }
            opts = ActivityOptions.makeThumbnailAspectScaleUpAnimation(sourceView,
                    b, offsetX, offsetY, animStartedListener);
                    b, offsetX, offsetY, transform.rect.width(), transform.rect.height(),
                    animStartedListener);
        }

        final ActivityOptions launchOpts = opts;
+18 −15
Original line number Diff line number Diff line
@@ -839,8 +839,10 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,

    @Override
     public void onClick(final View v) {
        // We purposely post the handler delayed to allow for the touch feedback to draw
        final TaskView tv = this;
        final boolean delayViewClick = (v != this);
        if (delayViewClick) {
            // We purposely post the handler delayed to allow for the touch feedback to draw
            postDelayed(new Runnable() {
                @Override
                public void run() {
@@ -848,6 +850,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
                        mCb.onTaskViewAppIconClicked(tv);
                    } else if (v == mHeaderView.mDismissButton) {
                        dismissTask();
                    }
                }
            }, 125);
        } else {
            if (v == mActionButtonView) {
                // Reset the translation of the action button before we animate it out
@@ -857,8 +862,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
                    (v == mFooterView || v == mActionButtonView));
        }
    }
        }, 125);
    }

    /**** View.OnLongClickListener Implementation ****/

Loading