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

Commit f6ba9499 authored by Ats Jenk's avatar Ats Jenk
Browse files

Fixes to support transient taskbar in desktop mode

Track gesture progress in desktop visibility controller. We need to
allow launcher to resume when gesture is in progress and freeform tasks
are visible.
Update overview state handling in desktop visibility controller. When
overview is enabled, launcher should be made visible, regardless of
freeform state. When exiting overview state, check freeform state to see
what should be shown and enabled.

Bug: 263264985
Test: manual, enable transient taskbar, move app to desktop, invoke transient
taskbar
Test: manual, enable transient taskarb, enable desktop mode, invoke
transient taskbar
Test: manual, disable transient taskbar, move app to desktop, swipe up
to overview
Test: manual, disable transient taskbar, enable desktop mode, swipe up
to overview

Change-Id: I63000441d9cf72769e6efb9d247ab4112c01839d
parent 39688d2d
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);
        }
    }
}