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

Commit 1ad24fe2 authored by Filip Gruszczynski's avatar Filip Gruszczynski Committed by Android (Google) Code Review
Browse files

Merge "Infrastructure for animating of maximizing pip activity."

parents a2773089 c17d8b79
Loading
Loading
Loading
Loading
+26 −18
Original line number Diff line number Diff line
@@ -1774,18 +1774,33 @@ public class Am extends BaseCommand {
            System.err.println("Error: invalid input bounds");
            return;
        }
        resizeStack(stackId, bounds, 0, false);
        resizeStack(stackId, bounds, 0);
    }

    private void runStackResizeAnimated() throws Exception {
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        final Rect bounds = getBounds();
        final Rect bounds;
        if ("null".equals(mArgs.peekNextArg())) {
            bounds = null;
        } else {
            bounds = getBounds();
            if (bounds == null) {
                System.err.println("Error: invalid input bounds");
                return;
            }
        resizeStack(stackId, bounds, 0, true);
        }
        resizeStackUnchecked(stackId, bounds, 0, true);
    }

    private void resizeStackUnchecked(int stackId, Rect bounds, int delayMs, boolean animate) {
        try {
            mAm.resizeStack(stackId, bounds, false, false, animate);
            Thread.sleep(delayMs);
        } catch (RemoteException e) {
            showError("Error: resizing stack " + e);
        } catch (InterruptedException e) {
        }
    }

    private void runStackResizeDocked() throws Exception {
@@ -1802,20 +1817,13 @@ public class Am extends BaseCommand {
        }
    }

    private void resizeStack(int stackId, Rect bounds, int delayMs, boolean animate)
    private void resizeStack(int stackId, Rect bounds, int delayMs)
            throws Exception {
        if (bounds == null) {
            showError("Error: invalid input bounds");
            return;
        }

        try {
            mAm.resizeStack(stackId, bounds, false, false, animate);
            Thread.sleep(delayMs);
        } catch (RemoteException e) {
            showError("Error: resizing stack " + e);
        } catch (InterruptedException e) {
        }
        resizeStackUnchecked(stackId, bounds, delayMs, false);
    }

    private void runStackPositionTask() throws Exception {
@@ -1924,7 +1932,7 @@ public class Am extends BaseCommand {
            maxChange = Math.min(stepSize, currentPoint - minPoint);
            currentPoint -= maxChange;
            setBoundsSide(bounds, side, currentPoint);
            resizeStack(DOCKED_STACK_ID, bounds, delayMs, false);
            resizeStack(DOCKED_STACK_ID, bounds, delayMs);
        }

        System.out.println("Growing docked stack side=" + side);
@@ -1932,7 +1940,7 @@ public class Am extends BaseCommand {
            maxChange = Math.min(stepSize, maxPoint - currentPoint);
            currentPoint += maxChange;
            setBoundsSide(bounds, side, currentPoint);
            resizeStack(DOCKED_STACK_ID, bounds, delayMs, false);
            resizeStack(DOCKED_STACK_ID, bounds, delayMs);
        }

        System.out.println("Back to Original size side=" + side);
@@ -1940,7 +1948,7 @@ public class Am extends BaseCommand {
            maxChange = Math.min(stepSize, currentPoint - startPoint);
            currentPoint -= maxChange;
            setBoundsSide(bounds, side, currentPoint);
            resizeStack(DOCKED_STACK_ID, bounds, delayMs, false);
            resizeStack(DOCKED_STACK_ID, bounds, delayMs);
        }
    }

+10 −0
Original line number Diff line number Diff line
@@ -234,6 +234,16 @@ public abstract class ShellCommand {
        }
    }

    public String peekNextArg() {
        if (mCurArgData != null) {
            return mCurArgData;
        } else if (mArgPos < mArgs.length) {
            return mArgs[mArgPos];
        } else {
            return null;
        }
    }

    /**
     * Return the next argument on the command line, whatever it is; if there are
     * no arguments left, throws an IllegalArgumentException to report this to the user.
+20 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Rect;
import android.util.ArrayMap;
@@ -50,13 +51,15 @@ public class BoundsAnimationController {
        private final Rect mFrom;
        private final Rect mTo;
        private final Rect mTmpRect;
        private final boolean mMoveToFullScreen;

        BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to) {
        BoundsAnimator(AnimateBoundsUser target, Rect from, Rect to, boolean moveToFullScreen) {
            super();
            mTarget = target;
            mFrom = from;
            mTo = to;
            mTmpRect = new Rect();
            mMoveToFullScreen = moveToFullScreen;
            addUpdateListener(this);
            addListener(this);
        }
@@ -88,6 +91,9 @@ public class BoundsAnimationController {
        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
            if (mMoveToFullScreen) {
                mTarget.moveToFullscreen();
            }
        }

        @Override
@@ -125,14 +131,25 @@ public class BoundsAnimationController {
         * necessary cleanup.
         */
        void finishBoundsAnimation();

        void moveToFullscreen();

        void getFullScreenBounds(Rect bounds);
    }

    void animateBounds(final AnimateBoundsUser target, Rect from, Rect to) {
        boolean moveToFullscreen = false;
        if (to == null) {
            to = new Rect();
            target.getFullScreenBounds(to);
            moveToFullscreen = true;
        }

    void animateBounds(AnimateBoundsUser target, Rect from, Rect to) {
        final BoundsAnimator existing = mRunningAnimations.get(target);
        if (existing != null) {
            existing.cancel();
        }
        BoundsAnimator animator = new BoundsAnimator(target, from, to);
        BoundsAnimator animator = new BoundsAnimator(target, from, to, moveToFullscreen);
        mRunningAnimations.put(target, animator);
        animator.setFloatValues(0f, 1f);
        animator.setDuration(DEFAULT_APP_TRANSITION_DURATION);
+14 −0
Original line number Diff line number Diff line
@@ -927,4 +927,18 @@ public class TaskStack implements DimLayer.DimLayerUser,
            }
        }
    }

    @Override
    public void moveToFullscreen() {
        try {
            mService.mActivityManager.moveTasksToFullscreenStack(mStackId, true);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void getFullScreenBounds(Rect bounds) {
        getDisplayContent().getContentRect(bounds);
    }
}