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

Commit 6015c3fb authored by Cyrus Boadway's avatar Cyrus Boadway Committed by Android (Google) Code Review
Browse files

Merge "Improve widget-activity transition animation for translucent activities" into sc-dev

parents 01d1cb92 67047330
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -783,7 +783,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
                v, widgetBackgroundBounds,
                new Size(windowTargetBounds.width(), windowTargetBounds.height()),
                finalWindowRadius);
                finalWindowRadius, appTargetsAreTranslucent);
        final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
                ? floatingView.getInitialCornerRadius() : 0;

+4 −2
Original line number Diff line number Diff line
@@ -1047,7 +1047,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    }

    protected abstract HomeAnimationFactory createHomeAnimationFactory(
            ArrayList<IBinder> launchCookies, long duration);
            ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent);

    private final TaskStackChangeListener mActivityRestartListener = new TaskStackChangeListener() {
        @Override
@@ -1091,7 +1091,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            final ArrayList<IBinder> cookies = runningTaskTarget != null
                    ? runningTaskTarget.taskInfo.launchCookies
                    : new ArrayList<>();
            HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(cookies, duration);
            boolean isTranslucent = runningTaskTarget != null && runningTaskTarget.isTranslucent;
            HomeAnimationFactory homeAnimFactory =
                    createHomeAnimationFactory(cookies, duration, isTranslucent);
            mIsSwipingPipToHome = homeAnimFactory.supportSwipePipToHome()
                    && runningTaskTarget != null
                    && runningTaskTarget.taskInfo.pictureInPictureParams != null
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class FallbackSwipeHandler extends

    @Override
    protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
            long duration) {
            long duration, boolean isTargetTranslucent) {
        mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
        ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
        Intent intent = new Intent(mGestureState.getHomeIntent());
+5 −4
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class LauncherSwipeHandlerV2 extends

    @Override
    protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
            long duration) {
            long duration, boolean isTargetTranslucent) {
        if (mActivity == null) {
            mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
                    isPresent -> mRecentsView.startHome());
@@ -103,7 +103,8 @@ public class LauncherSwipeHandlerV2 extends
            return new LauncherHomeAnimationFactory();
        }
        if (workspaceView instanceof LauncherAppWidgetHostView) {
            return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView);
            return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView,
                    isTargetTranslucent);
        }
        return createIconHomeAnimationFactory(workspaceView);
    }
@@ -235,7 +236,7 @@ public class LauncherSwipeHandlerV2 extends
    }

    private HomeAnimationFactory createWidgetHomeAnimationFactory(
            LauncherAppWidgetHostView hostView) {
            LauncherAppWidgetHostView hostView, boolean isTargetTranslucent) {

        RectF backgroundLocation = new RectF();
        Rect crop = new Rect();
@@ -243,7 +244,7 @@ public class LauncherSwipeHandlerV2 extends
        Size windowSize = new Size(crop.width(), crop.height());
        FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity,
                hostView, backgroundLocation, windowSize,
                mTaskViewSimulator.getCurrentCornerRadius());
                mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent);

        return new LauncherHomeAnimationFactory() {

+24 −16
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
    private Runnable mEndRunnable;
    private Runnable mFastFinishRunnable;
    private Runnable mOnTargetChangeRunnable;
    private boolean mAppTargetIsTranslucent;

    public FloatingWidgetView(Context context) {
        this(context, null);
@@ -142,10 +143,12 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
    }

    private void init(DragLayer dragLayer, LauncherAppWidgetHostView originalView,
            RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius) {
            RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius,
            boolean appTargetIsTranslucent) {
        mAppWidgetView = originalView;
        mAppWidgetView.beginDeferringUpdates();
        mBackgroundPosition = widgetBackgroundPosition;
        mAppTargetIsTranslucent = appTargetIsTranslucent;
        mEndRunnable = () -> finish(dragLayer);

        mAppWidgetBackgroundView = RoundedCornerEnforcement.findBackground(mAppWidgetView);
@@ -155,11 +158,13 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,

        getRelativePosition(mAppWidgetBackgroundView, dragLayer, mBackgroundPosition);
        getRelativePosition(mAppWidgetBackgroundView, mAppWidgetView, mBackgroundOffset);
        if (!mAppTargetIsTranslucent) {
            mBackgroundView.init(mAppWidgetView, mAppWidgetBackgroundView, windowCornerRadius);
            // Layout call before GhostView creation so that the overlaid view isn't clipped
            layout(0, 0, windowSize.getWidth(), windowSize.getHeight());
            mForegroundOverlayView = GhostView.addGhost(mAppWidgetView, this);
            positionViews();
        }

        mListenerView.setListener(this::fastFinish);
        dragLayer.addView(mListenerView);
@@ -179,7 +184,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
     */
    public void update(RectF backgroundPosition, float floatingWidgetAlpha, float foregroundAlpha,
            float fallbackBackgroundAlpha, float cornerRadiusProgress) {
        if (isUninitialized()) return;
        if (isUninitialized() || mAppTargetIsTranslucent) return;
        setAlpha(floatingWidgetAlpha);
        mBackgroundView.update(cornerRadiusProgress, fallbackBackgroundAlpha);
        mAppWidgetView.setAlpha(foregroundAlpha);
@@ -203,14 +208,17 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
        backgroundParams.height = (int) mBackgroundPosition.height();
        mBackgroundView.setLayoutParams(backgroundParams);

        if (mForegroundOverlayView != null) {
            sTmpMatrix.reset();
        float foregroundScale = mBackgroundPosition.width() / mAppWidgetBackgroundView.getWidth();
            float foregroundScale =
                    mBackgroundPosition.width() / mAppWidgetBackgroundView.getWidth();
            sTmpMatrix.setTranslate(-mBackgroundOffset.left - mAppWidgetView.getLeft(),
                    -mBackgroundOffset.top - mAppWidgetView.getTop());
            sTmpMatrix.postScale(foregroundScale, foregroundScale);
            sTmpMatrix.postTranslate(mBackgroundPosition.left, mBackgroundPosition.top);
            mForegroundOverlayView.setMatrix(sTmpMatrix);
        }
    }

    private void finish(DragLayer dragLayer) {
        mAppWidgetView.setAlpha(1f);
@@ -254,7 +262,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
     */
    public static FloatingWidgetView getFloatingWidgetView(Launcher launcher,
            LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition,
            Size windowSize, float windowCornerRadius) {
            Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent) {
        final DragLayer dragLayer = launcher.getDragLayer();
        ViewGroup parent = (ViewGroup) dragLayer.getParent();
        FloatingWidgetView floatingView =
@@ -262,7 +270,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
        floatingView.recycle();

        floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize,
                windowCornerRadius);
                windowCornerRadius, appTargetsAreTranslucent);
        parent.addView(floatingView);
        return floatingView;
    }