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

Commit 83a8dad3 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Fixes to support transient taskbar in desktop mode" into tm-qpr-dev

parents f43527d5 f6ba9499
Loading
Loading
Loading
Loading
+67 −24
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public class DesktopVisibilityController {

    private boolean mFreeformTasksVisible;
    private boolean mInOverviewState;
    private boolean mGestureInProgress;

    public DesktopVisibilityController(Launcher launcher) {
        mLauncher = launcher;
@@ -57,9 +58,24 @@ public class DesktopVisibilityController {
     * Sets whether freeform windows are visible and updates launcher visibility based on that.
     */
    public void setFreeformTasksVisible(boolean freeformTasksVisible) {
        if (!isDesktopModeSupported()) {
            return;
        }
        if (freeformTasksVisible != mFreeformTasksVisible) {
            mFreeformTasksVisible = freeformTasksVisible;
            updateLauncherVisibility();
            if (mFreeformTasksVisible) {
                setLauncherViewsVisibility(View.INVISIBLE);
                if (!mInOverviewState) {
                    // When freeform is visible & we're not in overview, we want launcher to appear
                    // paused, this ensures that taskbar displays.
                    markLauncherPaused();
                }
            } else {
                setLauncherViewsVisibility(View.VISIBLE);
                // If freeform isn't visible ensure that launcher appears resumed to behave
                // normally.
                markLauncherResumed();
            }
        }
    }

@@ -67,40 +83,67 @@ public class DesktopVisibilityController {
     * Sets whether the overview is visible and updates launcher visibility based on that.
     */
    public void setOverviewStateEnabled(boolean overviewStateEnabled) {
        if (!isDesktopModeSupported()) {
            return;
        }
        if (overviewStateEnabled != mInOverviewState) {
            mInOverviewState = overviewStateEnabled;
            updateLauncherVisibility();
            if (mInOverviewState) {
                setLauncherViewsVisibility(View.VISIBLE);
                markLauncherResumed();
            } else if (mFreeformTasksVisible) {
                setLauncherViewsVisibility(View.INVISIBLE);
                markLauncherPaused();
            }
        }
    }

    /**
     * Updates launcher visibility and state to look like it is paused or resumed depending on
     * whether freeform windows are showing in desktop mode.
     * Whether recents gesture is currently in progress.
     */
    private void updateLauncherVisibility() {
        StatefulActivity<LauncherState> activity =
                QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity();
        View workspaceView = mLauncher.getWorkspace();
        if (activity == null || workspaceView == null || !isDesktopModeSupported()) {
    public boolean isGestureInProgress() {
        return mGestureInProgress;
    }

    /**
     * Sets whether recents gesture is in progress.
     */
    public void setGestureInProgress(boolean gestureInProgress) {
        if (!isDesktopModeSupported()) {
            return;
        }
        if (gestureInProgress != mGestureInProgress) {
            mGestureInProgress = gestureInProgress;
        }
    }

        if (mFreeformTasksVisible) {
            workspaceView.setVisibility(View.INVISIBLE);
            if (!mInOverviewState) {
                // When freeform is visible & we're not in overview, we want launcher to appear
                // paused, this ensures that taskbar displays.
    private void setLauncherViewsVisibility(int visibility) {
        View workspaceView = mLauncher.getWorkspace();
        if (workspaceView != null) {
            workspaceView.setVisibility(visibility);
        }
        View dragLayer = mLauncher.getDragLayer();
        if (dragLayer != null) {
            dragLayer.setVisibility(visibility);
        }
    }

    private void markLauncherPaused() {
        StatefulActivity<LauncherState> activity =
                QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity();
        if (activity != null) {
            activity.setPaused();
        }
        } else {
            workspaceView.setVisibility(View.VISIBLE);
            // If freeform isn't visible ensure that launcher appears resumed to behave normally.
    }

    private void markLauncherResumed() {
        StatefulActivity<LauncherState> activity =
                QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity();
        // Check activity state before calling setResumed(). Launcher may have been actually
        // paused (eg fullscreen task moved to front).
        // In this case we should not mark the activity as resumed.
            if (activity.isResumed()) {
        if (activity != null && activity.isResumed()) {
            activity.setResumed();
        }
    }
}
}
+2 −1
Original line number Diff line number Diff line
@@ -668,7 +668,8 @@ public class QuickstepLauncher extends Launcher {
    public void setResumed() {
        if (DesktopTaskView.DESKTOP_IS_PROTO2_ENABLED) {
            DesktopVisibilityController controller = mDesktopVisibilityController;
            if (controller != null && controller.areFreeformTasksVisible()) {
            if (controller != null && controller.areFreeformTasksVisible()
                    && !controller.isGestureInProgress()) {
                // Return early to skip setting activity to appear as resumed
                // TODO(b/255649902): shouldn't be needed when we have a separate launcher state
                //  for desktop that we can use to control other parts of launcher
+24 −0
Original line number Diff line number Diff line
@@ -36,12 +36,15 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.popup.QuickstepSystemShortcut;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.PendingSplitSelectInfo;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.RotationTouchHelper;
import com.android.quickstep.util.SplitSelectStateController;
import com.android.systemui.shared.recents.model.Task;

/**
 * {@link RecentsView} used in Launcher activity
@@ -205,4 +208,25 @@ public class LauncherRecentsView extends RecentsView<QuickstepLauncher, Launcher
    protected boolean canLaunchFullscreenTask() {
        return !mActivity.isInState(OVERVIEW_SPLIT_SELECT);
    }

    @Override
    public void onGestureAnimationStart(Task[] runningTasks,
            RotationTouchHelper rotationTouchHelper) {
        super.onGestureAnimationStart(runningTasks, rotationTouchHelper);
        DesktopVisibilityController desktopVisibilityController =
                mActivity.getDesktopVisibilityController();
        if (desktopVisibilityController != null) {
            desktopVisibilityController.setGestureInProgress(true);
        }
    }

    @Override
    public void onGestureAnimationEnd() {
        super.onGestureAnimationEnd();
        DesktopVisibilityController desktopVisibilityController =
                mActivity.getDesktopVisibilityController();
        if (desktopVisibilityController != null) {
            desktopVisibilityController.setGestureInProgress(false);
        }
    }
}