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

Commit 3974edc4 authored by Tony Wickham's avatar Tony Wickham
Browse files

Don't draw taskbar background during gestures

In this case, the ScrimView for BackgroundAppState will handle drawing behind the whole screen, and prevents taskbar from drawing the rounded corners on top of TaskViews.

Added a hack to defer resuming last task by a frame to ensure taskbar is drawing first.

Test: Quick switch to an app, ensure it isn't covered by the taskbar's rounded corner
Bug: 196257194
Change-Id: Ibc81d80bc3bf1d908e6912b179cbcafbdcc56c0f
parent 157d3b95
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ObjectAnimator;
import android.graphics.Rect;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;


@@ -241,7 +242,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        return mContext.getDragController().isDragging();
        return mContext.getDragController().isDragging();
    }
    }


    void setTaskbarViewVisible(boolean isVisible) {
    public View getRootView() {
        return mTaskbarDragLayer;
    }

    private void setTaskbarViewVisible(boolean isVisible) {
        mIconAlphaForHome.setValue(isVisible ? 1 : 0);
        mIconAlphaForHome.setValue(isVisible ? 1 : 0);
        mLauncher.getHotseat().setIconsAlpha(isVisible ? 0f : 1f);
        mLauncher.getHotseat().setIconsAlpha(isVisible ? 0f : 1f);
    }
    }
+17 −3
Original line number Original line Diff line number Diff line
@@ -655,8 +655,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,


    private void onAnimatorPlaybackControllerCreated(AnimatorControllerWithResistance anim) {
    private void onAnimatorPlaybackControllerCreated(AnimatorControllerWithResistance anim) {
        mLauncherTransitionController = anim;
        mLauncherTransitionController = anim;
        mStateCallback.runOnceAtState(STATE_GESTURE_STARTED, () -> {
            // Wait until the gesture is started (touch slop was passed) to start in sync with
            // mWindowTransitionController. This ensures we don't hide the taskbar background when
            // long pressing to stash it, for instance.
            mLauncherTransitionController.getNormalController().dispatchOnStart();
            mLauncherTransitionController.getNormalController().dispatchOnStart();
            updateLauncherTransitionProgress();
            updateLauncherTransitionProgress();
        });
    }
    }


    public Intent getLaunchIntent() {
    public Intent getLaunchIntent() {
@@ -885,6 +890,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        // Fast-finish the attaching animation if it's still running.
        // Fast-finish the attaching animation if it's still running.
        maybeUpdateRecentsAttachedState(false);
        maybeUpdateRecentsAttachedState(false);
        final GestureEndTarget endTarget = mGestureState.getEndTarget();
        final GestureEndTarget endTarget = mGestureState.getEndTarget();
        // Wait until the given View (if supplied) draws before resuming the last task.
        View postResumeLastTask = mActivityInterface.onSettledOnEndTarget(endTarget);

        if (endTarget != NEW_TASK) {
        if (endTarget != NEW_TASK) {
            InteractionJankMonitorWrapper.cancel(
            InteractionJankMonitorWrapper.cancel(
                    InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
                    InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
@@ -893,6 +901,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            InteractionJankMonitorWrapper.cancel(
            InteractionJankMonitorWrapper.cancel(
                    InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
                    InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
        }
        }

        switch (endTarget) {
        switch (endTarget) {
            case HOME:
            case HOME:
                mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
                mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
@@ -907,7 +916,12 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
                mStateCallback.setState(STATE_START_NEW_TASK | STATE_CAPTURE_SCREENSHOT);
                mStateCallback.setState(STATE_START_NEW_TASK | STATE_CAPTURE_SCREENSHOT);
                break;
                break;
            case LAST_TASK:
            case LAST_TASK:
                if (postResumeLastTask != null) {
                    ViewUtils.postFrameDrawn(postResumeLastTask,
                            () -> mStateCallback.setState(STATE_RESUME_LAST_TASK));
                } else {
                    mStateCallback.setState(STATE_RESUME_LAST_TASK);
                    mStateCallback.setState(STATE_RESUME_LAST_TASK);
                }
                TaskViewUtils.setDividerBarShown(mRecentsAnimationTargets.nonApps, true);
                TaskViewUtils.setDividerBarShown(mRecentsAnimationTargets.nonApps, true);
                break;
                break;
        }
        }
+10 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import android.graphics.Rect;
import android.os.Build;
import android.os.Build;
import android.view.Gravity;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;


import androidx.annotation.Nullable;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.UiThread;
@@ -385,6 +386,15 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
     */
     */
    public abstract STATE_TYPE stateFromGestureEndTarget(GestureState.GestureEndTarget endTarget);
    public abstract STATE_TYPE stateFromGestureEndTarget(GestureState.GestureEndTarget endTarget);


    /**
     * Called when the animation to the target has finished, but right before updating the state.
     * @return A View that needs to draw before ending the recents animation to LAST_TASK.
     * (This is a hack to ensure Taskbar draws its background first to avoid flickering.)
     */
    public @Nullable View onSettledOnEndTarget(GestureState.GestureEndTarget endTarget) {
        return null;
    }

    public interface AnimationFactory {
    public interface AnimationFactory {


        void createActivityInterface(long transitionLength);
        void createActivityInterface(long transitionLength);
+26 −0
Original line number Original line Diff line number Diff line
@@ -25,10 +25,12 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;


import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.AnimatorSet;
import android.content.Context;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;


import androidx.annotation.Nullable;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.UiThread;
@@ -131,6 +133,18 @@ public final class LauncherActivityInterface extends
                        new ClampedDepthProperty(fromDepthRatio, toDepthRatio),
                        new ClampedDepthProperty(fromDepthRatio, toDepthRatio),
                        fromDepthRatio, toDepthRatio, LINEAR);
                        fromDepthRatio, toDepthRatio, LINEAR);


                pa.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        LauncherTaskbarUIController taskbarUIController =
                                activity.getTaskbarUIController();
                        if (taskbarUIController != null) {
                            // Launcher's ScrimView will draw the background throughout the gesture.
                            taskbarUIController.forceHideBackground(true);
                        }
                    }
                });

            }
            }
        };
        };


@@ -358,4 +372,16 @@ public final class LauncherActivityInterface extends
                return NORMAL;
                return NORMAL;
        }
        }
    }
    }

    @Override
    public View onSettledOnEndTarget(@Nullable GestureEndTarget endTarget) {
        View superRet = super.onSettledOnEndTarget(endTarget);
        LauncherTaskbarUIController taskbarUIController = getTaskbarController();
        if (taskbarUIController != null) {
            // Start drawing taskbar's background again since launcher might stop drawing.
            taskbarUIController.forceHideBackground(false);
            return taskbarUIController.getRootView();
        }
        return superRet;
    }
}
}