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

Commit 801dbf90 authored by Cyrus Boadway's avatar Cyrus Boadway Committed by Automerger Merge Worker
Browse files

Merge "Use the splash screen background color as the fallback background...

Merge "Use the splash screen background color as the fallback background color" into sc-dev am: 3616f29f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14881306

Change-Id: I5ad3b65fb0e74ca77e37aa9bea590f82519283a0
parents c13b47f7 3616f29f
Loading
Loading
Loading
Loading
+27 −21
Original line number Original line Diff line number Diff line
@@ -213,8 +213,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        }
        }
    };
    };


    // Pairs of window starting type and starting window background color for starting tasks
    // Will never be larger than MAX_NUM_TASKS
    // Will never be larger than MAX_NUM_TASKS
    private LinkedHashMap<Integer, Integer> mTypeForTaskId;
    private LinkedHashMap<Integer, Pair<Integer, Integer>> mTaskStartParams;


    public QuickstepTransitionManager(Context context) {
    public QuickstepTransitionManager(Context context) {
        mLauncher = Launcher.cast(Launcher.getLauncher(context));
        mLauncher = Launcher.cast(Launcher.getLauncher(context));
@@ -231,9 +232,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        mLauncher.addOnDeviceProfileChangeListener(this);
        mLauncher.addOnDeviceProfileChangeListener(this);


        if (supportsSSplashScreen()) {
        if (supportsSSplashScreen()) {
            mTypeForTaskId = new LinkedHashMap<Integer, Integer>(MAX_NUM_TASKS) {
            mTaskStartParams = new LinkedHashMap<Integer, Pair<Integer, Integer>>(MAX_NUM_TASKS) {
                @Override
                @Override
                protected boolean removeEldestEntry(Entry<Integer, Integer> entry) {
                protected boolean removeEldestEntry(Entry<Integer, Pair<Integer, Integer>> entry) {
                    return size() > MAX_NUM_TASKS;
                    return size() > MAX_NUM_TASKS;
                }
                }
            };
            };
@@ -419,15 +420,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        return bounds;
        return bounds;
    }
    }


    private int getOpeningTaskId(RemoteAnimationTargetCompat[] appTargets) {
        for (RemoteAnimationTargetCompat target : appTargets) {
            if (target.mode == MODE_OPENING) {
                return target.taskId;
            }
        }
        return -1;
    }

    public void setRemoteAnimationProvider(final RemoteAnimationProvider animationProvider,
    public void setRemoteAnimationProvider(final RemoteAnimationProvider animationProvider,
            CancellationSignal cancellationSignal) {
            CancellationSignal cancellationSignal) {
        mRemoteAnimationProvider = animationProvider;
        mRemoteAnimationProvider = animationProvider;
@@ -594,10 +586,12 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener


        final boolean hasSplashScreen;
        final boolean hasSplashScreen;
        if (supportsSSplashScreen()) {
        if (supportsSSplashScreen()) {
            int taskId = getOpeningTaskId(appTargets);
            int taskId = openingTargets.getFirstAppTargetTaskId();
            int type = mTypeForTaskId.getOrDefault(taskId, STARTING_WINDOW_TYPE_NONE);
            Pair<Integer, Integer> defaultParams = Pair.create(STARTING_WINDOW_TYPE_NONE, 0);
            mTypeForTaskId.remove(taskId);
            Pair<Integer, Integer> taskParams =
            hasSplashScreen = type == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
                    mTaskStartParams.getOrDefault(taskId, defaultParams);
            mTaskStartParams.remove(taskId);
            hasSplashScreen = taskParams.first == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
        } else {
        } else {
            hasSplashScreen = false;
            hasSplashScreen = false;
        }
        }
@@ -798,18 +792,30 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        final RectF widgetBackgroundBounds = new RectF();
        final RectF widgetBackgroundBounds = new RectF();
        final Rect appWindowCrop = new Rect();
        final Rect appWindowCrop = new Rect();
        final Matrix matrix = new Matrix();
        final Matrix matrix = new Matrix();
        RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
                wallpaperTargets, nonAppTargets, MODE_OPENING);

        RemoteAnimationTargetCompat openingTarget = openingTargets.getFirstAppTarget();
        int fallbackBackgroundColor = 0;
        if (openingTarget != null && supportsSSplashScreen()) {
            fallbackBackgroundColor = mTaskStartParams.containsKey(openingTarget.taskId)
                    ? mTaskStartParams.get(openingTarget.taskId).second : 0;
            mTaskStartParams.remove(openingTarget.taskId);
        }
        if (fallbackBackgroundColor == 0) {
            fallbackBackgroundColor =
                    FloatingWidgetView.getDefaultBackgroundColor(mLauncher, openingTarget);
        }


        final float finalWindowRadius = mDeviceProfile.isMultiWindowMode
        final float finalWindowRadius = mDeviceProfile.isMultiWindowMode
                ? 0 : getWindowCornerRadius(mLauncher.getResources());
                ? 0 : getWindowCornerRadius(mLauncher.getResources());
        final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
        final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
                v, widgetBackgroundBounds,
                v, widgetBackgroundBounds,
                new Size(windowTargetBounds.width(), windowTargetBounds.height()),
                new Size(windowTargetBounds.width(), windowTargetBounds.height()),
                finalWindowRadius, appTargetsAreTranslucent);
                finalWindowRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
        final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
        final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
                ? floatingView.getInitialCornerRadius() : 0;
                ? floatingView.getInitialCornerRadius() : 0;


        RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
                wallpaperTargets, nonAppTargets, MODE_OPENING);
        SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
        SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
        openingTargets.addReleaseCheck(surfaceApplier);
        openingTargets.addReleaseCheck(surfaceApplier);


@@ -1441,8 +1447,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        }
        }


        @Override
        @Override
        public void onTaskLaunching(int taskId, int supportedType) {
        public void onTaskLaunching(int taskId, int supportedType, int color) {
            mTransitionManager.mTypeForTaskId.put(taskId, supportedType);
            mTransitionManager.mTaskStartParams.put(taskId, Pair.create(supportedType, color));
        }
        }
    }
    }
}
}
+3 −2
Original line number Original line Diff line number Diff line
@@ -1071,7 +1071,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    }
    }


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


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


    @Override
    @Override
    protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
    protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
            long duration, boolean isTargetTranslucent) {
            long duration, boolean isTargetTranslucent,
            RemoteAnimationTargetCompat runningTaskTarget) {
        mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
        mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
        ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
        ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
        Intent intent = new Intent(mGestureState.getHomeIntent());
        Intent intent = new Intent(mGestureState.getHomeIntent());
+27 −10
Original line number Original line Diff line number Diff line
@@ -20,6 +20,9 @@ import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.Utilities.boundToRange;
import static com.android.launcher3.Utilities.boundToRange;
import static com.android.launcher3.Utilities.dpToPx;
import static com.android.launcher3.Utilities.dpToPx;
import static com.android.launcher3.Utilities.mapBoundToRange;
import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE;
import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
@@ -65,6 +68,7 @@ import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.plugins.ResourceProvider;
import com.android.systemui.plugins.ResourceProvider;
import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;


import java.util.ArrayList;
import java.util.ArrayList;


@@ -84,7 +88,8 @@ public class LauncherSwipeHandlerV2 extends


    @Override
    @Override
    protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
    protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
            long duration, boolean isTargetTranslucent) {
            long duration, boolean isTargetTranslucent,
            RemoteAnimationTargetCompat runningTaskTarget) {
        if (mActivity == null) {
        if (mActivity == null) {
            mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
            mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
                    isPresent -> mRecentsView.startHome());
                    isPresent -> mRecentsView.startHome());
@@ -108,7 +113,7 @@ public class LauncherSwipeHandlerV2 extends
        }
        }
        if (workspaceView instanceof LauncherAppWidgetHostView) {
        if (workspaceView instanceof LauncherAppWidgetHostView) {
            return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView,
            return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView,
                    isTargetTranslucent);
                    isTargetTranslucent, runningTaskTarget);
        }
        }
        return createIconHomeAnimationFactory(workspaceView);
        return createIconHomeAnimationFactory(workspaceView);
    }
    }
@@ -169,15 +174,19 @@ public class LauncherSwipeHandlerV2 extends
    }
    }


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

            RemoteAnimationTargetCompat runningTaskTarget) {
        final float floatingWidgetAlpha = isTargetTranslucent ? 0 : 1;
        RectF backgroundLocation = new RectF();
        RectF backgroundLocation = new RectF();
        Rect crop = new Rect();
        Rect crop = new Rect();
        mTaskViewSimulator.getCurrentCropRect().roundOut(crop);
        mTaskViewSimulator.getCurrentCropRect().roundOut(crop);
        Size windowSize = new Size(crop.width(), crop.height());
        Size windowSize = new Size(crop.width(), crop.height());
        int fallbackBackgroundColor =
                FloatingWidgetView.getDefaultBackgroundColor(mContext, runningTaskTarget);
        FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity,
        FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity,
                hostView, backgroundLocation, windowSize,
                hostView, backgroundLocation, windowSize,
                mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent);
                mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent,
                fallbackBackgroundColor);


        return new FloatingViewHomeAnimationFactory(floatingWidgetView) {
        return new FloatingViewHomeAnimationFactory(floatingWidgetView) {


@@ -207,12 +216,20 @@ public class LauncherSwipeHandlerV2 extends
            }
            }


            @Override
            @Override
            public void update(@Nullable AppCloseConfig config, RectF currentRect,
            public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress,
                    float progress, float radius) {
                    float radius) {
                super.update(config, currentRect, progress, radius);
                super.update(config, currentRect, progress, radius);
                floatingWidgetView.update(currentRect, 1 /* floatingWidgetAlpha */,
                final float fallbackBackgroundAlpha =
                        config != null ? config.getFgAlpha() : 1f /* foregroundAlpha */,
                        1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE);
                        0 /* fallbackBackgroundAlpha */, 1 - progress);
                final float foregroundAlpha =
                        mapBoundToRange(progress, 0.5f, 1, 0, 1, EXAGGERATED_EASE);
                floatingWidgetView.update(currentRect, floatingWidgetAlpha, foregroundAlpha,
                        fallbackBackgroundAlpha, 1 - progress);
            }

            @Override
            protected float getWindowAlpha(float progress) {
                return 1 - mapBoundToRange(progress, 0, 0.5f, 0, 1, LINEAR);
            }
            }
        };
        };
    }
    }
+11 −0
Original line number Original line Diff line number Diff line
@@ -85,6 +85,17 @@ public class RemoteAnimationTargets {
        return null;
        return null;
    }
    }


    /** Returns the first opening app target. */
    public RemoteAnimationTargetCompat getFirstAppTarget() {
        return apps.length > 0 ? apps[0] : null;
    }

    /** Returns the task id of the first opening app target, or -1 if none is found. */
    public int getFirstAppTargetTaskId() {
        RemoteAnimationTargetCompat target = getFirstAppTarget();
        return target == null ? -1 : target.taskId;
    }

    public boolean isAnimatingHome() {
    public boolean isAnimatingHome() {
        for (RemoteAnimationTargetCompat target : unfilteredApps) {
        for (RemoteAnimationTargetCompat target : unfilteredApps) {
            if (target.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
            if (target.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
Loading