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

Commit 31aefc32 authored by Randy Pfohl's avatar Randy Pfohl Committed by Android (Google) Code Review
Browse files

Merge changes from topic "windowRecents" into main

* changes:
  Cleaning up unusued handlers
  Moving RecentsWindowManager away from the singleton pattern
  Limited recents in window introductory cl
  abstracting fallback views to support container instead of activity
parents 3227a4ec daf37eeb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
    public TaskbarDragLayer(@NonNull Context context, @Nullable AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
        super(context, attrs, 1 /* alphaChannelCount */);
        mBackgroundRenderer = new TaskbarBackgroundRenderer(mActivity);
        mBackgroundRenderer = new TaskbarBackgroundRenderer(mContainer);

        mTaskbarBackgroundAlpha = new MultiPropertyFactory<>(this, BG_ALPHA, INDEX_COUNT,
                (a, b) -> a * b, 1f);
@@ -108,7 +108,7 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {

    public void init(TaskbarDragLayerController.TaskbarDragLayerCallbacks callbacks) {
        mControllerCallbacks = callbacks;
        mBackgroundRenderer.updateStashedHandleWidth(mActivity, getResources());
        mBackgroundRenderer.updateStashedHandleWidth(mContainer, getResources());
        recreateControllers();
    }

@@ -269,7 +269,7 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getAction() == ACTION_UP && event.getKeyCode() == KEYCODE_BACK) {
            AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity);
            AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mContainer);
            if (topView != null && topView.canHandleBack()) {
                topView.onBackInvoked();
                // Handled by the floating view.
+7 −7
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class TaskbarOverlayDragLayer extends
    @Override
    public void recreateControllers() {
        List<TouchController> controllers = new ArrayList<>();
        controllers.add(mActivity.getDragController());
        controllers.add(mContainer.getDragController());
        controllers.addAll(mTouchControllers);
        mControllers = controllers.toArray(new TouchController[0]);
    }
@@ -87,7 +87,7 @@ public class TaskbarOverlayDragLayer extends
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getAction() == ACTION_UP && event.getKeyCode() == KEYCODE_BACK) {
            AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity);
            AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mContainer);
            if (topView != null && topView.canHandleBack()) {
                topView.onBackInvoked();
                return true;
@@ -96,7 +96,7 @@ public class TaskbarOverlayDragLayer extends
                && event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) {
            // Ignore escape if pressed in conjunction with any modifier keys. Close each
            // floating view one at a time for each key press.
            AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity);
            AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mContainer);
            if (topView != null) {
                topView.close(/* animate= */ true);
                return true;
@@ -107,7 +107,7 @@ public class TaskbarOverlayDragLayer extends

    @Override
    public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
        if (mActivity.isAnySystemDragInProgress()) {
        if (mContainer.isAnySystemDragInProgress()) {
            inoutInfo.touchableRegion.setEmpty();
            inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
        }
@@ -123,7 +123,7 @@ public class TaskbarOverlayDragLayer extends
    @Override
    public void onViewRemoved(View child) {
        super.onViewRemoved(child);
        mActivity.getOverlayController().maybeCloseWindow();
        mContainer.getOverlayController().maybeCloseWindow();
    }

    /** Adds a {@link TouchController} to this drag layer. */
@@ -147,14 +147,14 @@ public class TaskbarOverlayDragLayer extends
     * 2) Sets tappableInsets bottom inset to 0.
     */
    private WindowInsets updateInsetsDueToStashing(WindowInsets oldInsets) {
        if (!DisplayController.isTransientTaskbar(mActivity)) {
        if (!DisplayController.isTransientTaskbar(mContainer)) {
            return oldInsets;
        }
        WindowInsets.Builder updatedInsetsBuilder = new WindowInsets.Builder(oldInsets);

        Insets oldNavInsets = oldInsets.getInsets(WindowInsets.Type.navigationBars());
        Insets newNavInsets = Insets.of(oldNavInsets.left, oldNavInsets.top, oldNavInsets.right,
                mActivity.getStashedTaskbarHeight());
                mContainer.getStashedTaskbarHeight());
        updatedInsetsBuilder.setInsets(WindowInsets.Type.navigationBars(), newNavInsets);

        Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement());
+3 −3
Original line number Diff line number Diff line
@@ -200,8 +200,6 @@ import com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver;
import com.android.systemui.unfold.updates.RotationChangeProvider;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;

import kotlin.Unit;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -214,6 +212,8 @@ import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.stream.Stream;

import kotlin.Unit;

public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
        SystemShortcut.BubbleActivityStarter {
    private static final boolean TRACE_LAYOUTS =
@@ -271,7 +271,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
        RecentsView<?,?> overviewPanel = getOverviewPanel();
        SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(this);
        mSplitSelectStateController =
                new SplitSelectStateController(this, mHandler, getStateManager(),
                new SplitSelectStateController(this, getStateManager(),
                        getDepthController(), getStatsLogManager(),
                        systemUiProxy, RecentsModel.INSTANCE.get(this),
                        () -> onStateBack());
+21 −12
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK;
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs;
import static com.android.quickstep.BaseContainerInterface.AnimationFactory;
import static com.android.quickstep.GestureState.GestureEndTarget.HOME;
import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK;
import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK;
@@ -103,6 +104,7 @@ import com.android.internal.jank.Cuj;
import com.android.internal.util.LatencyTracker;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Flags;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
@@ -112,6 +114,7 @@ import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StatefulContainer;
import com.android.launcher3.taskbar.TaskbarThresholdUtils;
import com.android.launcher3.taskbar.TaskbarUIController;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -120,9 +123,9 @@ import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.VibratorWrapper;
import com.android.launcher3.util.WindowBounds;
import com.android.quickstep.BaseActivityInterface.AnimationFactory;
import com.android.quickstep.GestureState.GestureEndTarget;
import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.util.ActiveGestureErrorDetector;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.ActivityInitListener;
@@ -156,8 +159,6 @@ import com.android.wm.shell.shared.TransactionPool;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
import com.android.wm.shell.shared.startingsurface.SplashScreenExitAnimationUtils;

import kotlin.Unit;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -167,15 +168,16 @@ import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.Consumer;

import kotlin.Unit;

/**
 * Handles the navigation gestures when Launcher is the default home activity.
 */
public abstract class AbsSwipeUpHandler<
        RECENTS_CONTAINER extends Context & RecentsViewContainer,
        RECENTS_VIEW extends RecentsView<RECENTS_CONTAINER, STATE>,
        STATE extends BaseState<STATE>>
        extends SwipeUpAnimationLogic
        implements OnApplyWindowInsetsListener, RecentsAnimationCallbacks.RecentsAnimationListener {
        RECENTS_CONTAINER extends Context & RecentsViewContainer & StatefulContainer<STATE>,
        RECENTS_VIEW extends RecentsView<RECENTS_CONTAINER, STATE>, STATE extends BaseState<STATE>>
        extends SwipeUpAnimationLogic implements OnApplyWindowInsetsListener,
        RecentsAnimationCallbacks.RecentsAnimationListener {
    private static final String TAG = "AbsSwipeUpHandler";

    private static final ArrayList<String> STATE_NAMES = new ArrayList<>();
@@ -292,7 +294,7 @@ public abstract class AbsSwipeUpHandler<
    private static final int LOG_NO_OP_PAGE_INDEX = -1;

    protected final TaskAnimationManager mTaskAnimationManager;

    protected final RecentsWindowManager mRecentsWindowManager;
    // Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise
    private RunningWindowAnim[] mRunningWindowAnim;
    // Possible second animation running at the same time as mRunningWindowAnim
@@ -353,9 +355,12 @@ public abstract class AbsSwipeUpHandler<
    public AbsSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
            long touchTimeMs, boolean continuingLastGesture,
            InputConsumerController inputConsumer) {
            InputConsumerController inputConsumer, RecentsWindowManager recentsWindowManager) {
        super(context, deviceState, gestureState);
        mContainerInterface = gestureState.getContainerInterface();
        if (recentsWindowManager != null && Flags.enableFallbackOverviewInWindow()) {
            recentsWindowManager.registerInitListener(this::onActivityInit);
        }
        mActivityInitListener =
                mContainerInterface.createActivityInitListener(this::onActivityInit);
        mInputConsumerProxy =
@@ -369,6 +374,7 @@ public abstract class AbsSwipeUpHandler<
                    endLauncherTransitionController();
                }, new InputProxyHandlerFactory(mContainerInterface, mGestureState));
        mTaskAnimationManager = taskAnimationManager;
        mRecentsWindowManager = recentsWindowManager;
        mTouchTimeMs = touchTimeMs;
        mContinuingLastGesture = continuingLastGesture;

@@ -819,7 +825,7 @@ public abstract class AbsSwipeUpHandler<
            return;
        }
        initTransitionEndpoints(mContainer.getDeviceProfile());
        mAnimationFactory.createActivityInterface(mTransitionDragLength);
        mAnimationFactory.createContainerInterface(mTransitionDragLength);
    }

    /**
@@ -863,10 +869,13 @@ public abstract class AbsSwipeUpHandler<
        }
    }

    public Intent getHomeIntent() {
        return mGestureState.getHomeIntent();
    }

    public Intent getLaunchIntent() {
        return mGestureState.getOverviewIntent();
    }

    /**
     * Called when the value of {@link #mCurrentShift} changes
     */
+2 −56
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.animation.AnimatorSet;
import android.view.MotionEvent;

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

import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
@@ -62,17 +61,14 @@ import java.util.function.Consumer;
public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_TYPE>,
        ACTIVITY_TYPE extends StatefulActivity<STATE_TYPE> & RecentsViewContainer> extends
        BaseContainerInterface<STATE_TYPE, ACTIVITY_TYPE> {
    private final STATE_TYPE mBackgroundState;

    private STATE_TYPE mTargetState;

    @Nullable private Runnable mOnInitBackgroundStateUICallback = null;

    protected BaseActivityInterface(boolean rotationSupportedByActivity,
            STATE_TYPE overviewState, STATE_TYPE backgroundState) {
        super(backgroundState);
        this.rotationSupportedByActivity = rotationSupportedByActivity;
        mTargetState = overviewState;
        mBackgroundState = backgroundState;
    }

    /**
@@ -124,13 +120,6 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
        return activity != null && activity.isStarted();
    }

    @UiThread
    @Nullable
    public abstract <T extends RecentsView> T getVisibleRecentsView();

    @UiThread
    public abstract boolean switchToRecentsIfVisible(Animator.AnimatorListener animatorListener);

    public boolean deferStartingActivity(RecentsAnimationDeviceState deviceState, MotionEvent ev) {
        TaskbarUIController controller = getTaskbarController();
        boolean isEventOverBubbleBarStashHandle =
@@ -163,49 +152,6 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
        recentsView.switchToScreenshot(thumbnailDatas, runnable);
    }


    protected void runOnInitBackgroundStateUI(Runnable callback) {
        ACTIVITY_TYPE activity = getCreatedContainer();
        if (activity != null && activity.getStateManager().getState() == mBackgroundState) {
            callback.run();
            onInitBackgroundStateUI();
            return;
        }
        mOnInitBackgroundStateUICallback = callback;
    }

    private void onInitBackgroundStateUI() {
        if (mOnInitBackgroundStateUICallback != null) {
            mOnInitBackgroundStateUICallback.run();
            mOnInitBackgroundStateUICallback = null;
        }
    }

    public interface AnimationFactory {

        void createActivityInterface(long transitionLength);

        /**
         * @param attached Whether to show RecentsView alongside the app window. If false, recents
         *                 will be hidden by some property we can animate, e.g. alpha.
         * @param animate Whether to animate recents to/from its new attached state.
         * @param updateRunningTaskAlpha Whether to update the running task's attached alpha
         */
        default void setRecentsAttachedToAppWindow(
                boolean attached, boolean animate, boolean updateRunningTaskAlpha) { }

        default boolean isRecentsAttachedToAppWindow() {
            return false;
        }

        default boolean hasRecentsEverAttachedToAppWindow() {
            return false;
        }

        /** Called when the gesture ends and we know what state it is going towards */
        default void setEndTarget(GestureState.GestureEndTarget endTarget) { }
    }

    class DefaultAnimationFactory implements AnimationFactory {

        protected final ACTIVITY_TYPE mActivity;
@@ -234,7 +180,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
        }

        @Override
        public void createActivityInterface(long transitionLength) {
        public void createContainerInterface(long transitionLength) {
            PendingAnimation pa = new PendingAnimation(transitionLength * 2);
            createBackgroundToOverviewAnim(mActivity, pa);
            AnimatorPlaybackController controller = pa.createPlaybackController();
Loading