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

Commit 836602e3 authored by Tony Wickham's avatar Tony Wickham
Browse files

Quickly fade in QSB when swiping up when SWIPE_HOME = false

Now that the "hook" gesture is supported for old quickstep to switch
apps, we need to fade out the QSB so it doesn't overlap the TaskView we
are switching to.

Bug: 111926330
Change-Id: Ie04c7909f6b96d12c810b438db89eedf8ea5bdeb
parent c920b598
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import android.os.RemoteException;
import com.android.launcher3.Launcher;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.config.FeatureFlags;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
@@ -72,4 +73,13 @@ public class BackgroundAppState extends OverviewState {
        float scale = (float) appWidth / sTempRect.width();
        return new float[] { scale, 0f };
    }

    @Override
    public int getVisibleElements(Launcher launcher) {
        if (FeatureFlags.SWIPE_HOME.get()) {
            return super.getVisibleElements(launcher);
        }
        // Hide shelf content (e.g. QSB) because we fade it in when swiping up.
        return ALL_APPS_HEADER_EXTRA;
    }
}
+27 −9
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_DAMPING_RATIO;
import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_STIFFNESS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.LINEAR;

import android.animation.Animator;
@@ -38,13 +39,20 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.SpringObjectAnimator;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
@@ -61,10 +69,6 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import java.util.function.BiPredicate;
import java.util.function.Consumer;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

/**
 * {@link ActivityControlHelper} for the in-launcher recents.
 */
@@ -211,7 +215,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
                        : mShelfState == ShelfAnimState.PEEK
                                ? shelfPeekingProgress
                                : shelfOverviewProgress;
                mShelfAnim = createShelfAnim(activity, toProgress);
                mShelfAnim = createShelfProgressAnim(activity, toProgress);
                mShelfAnim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
@@ -229,10 +233,10 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
            LauncherState fromState, long transitionLength,
            Consumer<AnimatorPlaybackController> callback) {
        LauncherState endState = OVERVIEW;
        if (wasVisible && fromState != BACKGROUND_APP) {
            // If a translucent app was launched fom launcher, animate launcher states.
        DeviceProfile dp = activity.getDeviceProfile();
        long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
        if (wasVisible && fromState != BACKGROUND_APP) {
            // If a translucent app was launched fom launcher, animate launcher states.
            callback.accept(activity.getStateManager()
                    .createAnimationToNewWorkspace(fromState, endState, accuracy));
            return;
@@ -245,10 +249,11 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
        if (!activity.getDeviceProfile().isVerticalBarLayout()
                && !FeatureFlags.SWIPE_HOME.get()) {
            // Don't animate the shelf when SWIPE_HOME is true, because we update it atomically.
            Animator shiftAnim = createShelfAnim(activity,
            Animator shiftAnim = createShelfProgressAnim(activity,
                    fromState.getVerticalProgress(activity),
                    endState.getVerticalProgress(activity));
            anim.play(shiftAnim);
            anim.play(createShelfAlphaAnim(activity, endState, accuracy));
        }
        playScaleDownAnim(anim, activity, endState);

@@ -265,7 +270,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
        callback.accept(controller);
    }

    private Animator createShelfAnim(Launcher activity, float ... progressValues) {
    private Animator createShelfProgressAnim(Launcher activity, float ... progressValues) {
        Animator shiftAnim = new SpringObjectAnimator<>(activity.getAllAppsController(),
                "allAppsSpringFromACH", activity.getAllAppsController().getShiftRange(),
                SPRING_DAMPING_RATIO, SPRING_STIFFNESS, progressValues);
@@ -273,6 +278,19 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
        return shiftAnim;
    }

    /**
     * Very quickly fade the alpha of shelf content.
     */
    private Animator createShelfAlphaAnim(Launcher activity, LauncherState toState, long accuracy) {
        AllAppsTransitionController allAppsController = activity.getAllAppsController();
        AnimatorSetBuilder animBuilder = new AnimatorSetBuilder();
        animBuilder.setInterpolator(AnimatorSetBuilder.ANIM_ALL_APPS_FADE, DEACCEL_3);
        LauncherStateManager.AnimationConfig config = new LauncherStateManager.AnimationConfig();
        config.duration = accuracy;
        allAppsController.setAlphas(toState.getVisibleElements(activity), config, animBuilder);
        return animBuilder.build();
    }

    /**
     * Scale down recents from the center task being full screen to being in overview.
     */
+4 −1
Original line number Diff line number Diff line
@@ -188,9 +188,12 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil

    private void setAlphas(LauncherState toState, AnimationConfig config,
            AnimatorSetBuilder builder) {
        setAlphas(toState.getVisibleElements(mLauncher), config, builder);
    }

    public void setAlphas(int visibleElements, AnimationConfig config, AnimatorSetBuilder builder) {
        PropertySetter setter = config == null ? NO_ANIM_PROPERTY_SETTER
                : config.getPropertySetter(builder);
        int visibleElements = toState.getVisibleElements(mLauncher);
        boolean hasHeaderExtra = (visibleElements & ALL_APPS_HEADER_EXTRA) != 0;
        boolean hasContent = (visibleElements & ALL_APPS_CONTENT) != 0;