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

Commit b06ff838 authored by Jordan Silva's avatar Jordan Silva
Browse files

Move DesktopTask to front of RecentsView (1/2)

This CL updates the DesktopTasks in the RecentsView to be displayed after the focused task, separated from the other tasks in the grid. The DesktopTasks will be larger, following the same size used for focused tasks.
It was necessary to do the following changes to support DesktopTask at the front of the list.
1. Sort the GroupTasks in applyLoadPlan to move DesktopTasks after all other tasks.
2. Update the target page to take into account the DesktopTasks after the running task.
3. updateGridProperties had to support DesktopTask and Focused Task to be positioned at the front of the list. This function updates view translations to support the grid with two rows and rebalacing the position after a task is dimissed.
4. Update the max and min page scroll. Updated getFirstViewIndex to check for a DesktopTaskView, and if it doesn't exist, it uses the focused task as reference.
5. TaskView.updateTaskSize was updated to prevent DesktopTaskView being resized. This change makes DesktopTaskView to have the same size of our current focused task.
6. Update several places using focused task to use isLargeTile.

Bug: 353947137
Fix: 353947516
Fix: 353947467
Fix: 353947334
Flag: com.android.launcher3.enable_large_desktop_windowing_tile
Test: OverviewDesktopTaskImageTest

Change-Id: Ic7c0d8340ca259e8644de180aa6859a3c968d66e
parent 1eebacf6
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -31,3 +31,11 @@ flag {
      purpose: PURPOSE_BUGFIX
      purpose: PURPOSE_BUGFIX
    }
    }
}
}

flag {
    name: "enable_large_desktop_windowing_tile"
    namespace: "launcher_overview"
    description: "Makes the desktop tiles larger and moves them to the front of the list in Overview."
    bug: "353947137"
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -181,7 +181,7 @@ public abstract class TaskViewTouchController<CONTAINER extends Context & Recent
                        // - The task is snapped
                        // - The task is snapped
                        mAllowGoingDown = i == mRecentsView.getCurrentPage()
                        mAllowGoingDown = i == mRecentsView.getCurrentPage()
                                && DisplayController.getNavigationMode(mContainer).hasGestures
                                && DisplayController.getNavigationMode(mContainer).hasGestures
                                && (!mRecentsView.showAsGrid() || mTaskBeingDragged.isFocusedTask())
                                && (!mRecentsView.showAsGrid() || mTaskBeingDragged.isLargeTile())
                                && mRecentsView.isTaskInExpectedScrollPosition(i);
                                && mRecentsView.isTaskInExpectedScrollPosition(i);


                        directionsToDetectScroll = mAllowGoingDown ? DIRECTION_BOTH : upDirection;
                        directionsToDetectScroll = mAllowGoingDown ? DIRECTION_BOTH : upDirection;
@@ -310,7 +310,7 @@ public abstract class TaskViewTouchController<CONTAINER extends Context & Recent
                // Set mOverrideVelocity to control task dismiss velocity in onDragEnd
                // Set mOverrideVelocity to control task dismiss velocity in onDragEnd
                int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity;
                int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity;
                if (mRecentsView.showAsGrid()) {
                if (mRecentsView.showAsGrid()) {
                    if (mTaskBeingDragged.isFocusedTask()) {
                    if (mTaskBeingDragged.isLargeTile()) {
                        velocityDimenId =
                        velocityDimenId =
                                R.dimen.default_task_dismiss_drag_velocity_grid_focus_task;
                                R.dimen.default_task_dismiss_drag_velocity_grid_focus_task;
                    } else {
                    } else {
+4 −4
Original line number Original line Diff line number Diff line
@@ -315,12 +315,12 @@ public interface TaskShortcutFactory {
            boolean isTaskSplitNotSupported = !task.isDockable ||
            boolean isTaskSplitNotSupported = !task.isDockable ||
                    (intentFlags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
                    (intentFlags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
            boolean hideForExistingMultiWindow = container.getDeviceProfile().isMultiWindowMode;
            boolean hideForExistingMultiWindow = container.getDeviceProfile().isMultiWindowMode;
            boolean isFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask();
            boolean isLargeTile = deviceProfile.isTablet && taskView.isLargeTile();
            boolean isTaskInExpectedScrollPosition =
            boolean isTaskInExpectedScrollPosition =
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));


            if (notEnoughTasksToSplit || isTaskSplitNotSupported || hideForExistingMultiWindow
            if (notEnoughTasksToSplit || isTaskSplitNotSupported || hideForExistingMultiWindow
                    || (isFocusedTask && isTaskInExpectedScrollPosition)) {
                    || (isLargeTile && isTaskInExpectedScrollPosition)) {
                return null;
                return null;
            }
            }


@@ -340,11 +340,11 @@ public interface TaskShortcutFactory {
            DeviceProfile deviceProfile = container.getDeviceProfile();
            DeviceProfile deviceProfile = container.getDeviceProfile();
            final TaskView taskView = taskContainer.getTaskView();
            final TaskView taskView = taskContainer.getTaskView();
            final RecentsView recentsView = taskView.getRecentsView();
            final RecentsView recentsView = taskView.getRecentsView();
            boolean isLargeTileFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask();
            boolean isLargeTile = deviceProfile.isTablet && taskView.isLargeTile();
            boolean isInExpectedScrollPosition =
            boolean isInExpectedScrollPosition =
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
            boolean shouldShowActionsButtonInstead =
            boolean shouldShowActionsButtonInstead =
                    isLargeTileFocusedTask && isInExpectedScrollPosition;
                    isLargeTile && isInExpectedScrollPosition;


            // No "save app pair" menu item if:
            // No "save app pair" menu item if:
            // - we are in 3p launcher
            // - we are in 3p launcher
+71 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.quickstep.util

import com.android.launcher3.Flags.enableLargeDesktopWindowingTile
import com.android.quickstep.views.DesktopTaskView
import com.android.quickstep.views.TaskView
import com.android.quickstep.views.TaskViewType

/**
 * Helper class for [com.android.quickstep.views.RecentsView]. This util class contains refactored
 * and extracted functions from RecentsView to facilitate the implementation of unit tests.
 */
class RecentsViewUtils {

    /**
     * Sort task groups to move desktop tasks to the end of the list.
     *
     * @param tasks List of group tasks to be sorted.
     * @return Sorted list of GroupTasks to be used in the RecentsView.
     */
    fun sortDesktopTasksToFront(tasks: List<GroupTask>): List<GroupTask> {
        val (desktopTasks, otherTasks) = tasks.partition { it.taskViewType == TaskViewType.DESKTOP }
        return otherTasks + desktopTasks
    }

    fun getFocusedTaskIndex(taskGroups: List<GroupTask>): Int {
        // The focused task index is placed after the desktop tasks views.
        return if (enableLargeDesktopWindowingTile()) {
            taskGroups.count { it.taskViewType == TaskViewType.DESKTOP }
        } else {
            0
        }
    }

    /**
     * Counts [numChildren] that are [DesktopTaskView] instances.
     *
     * @param numChildren Quantity of children to transverse
     * @param getTaskViewAt Function that provides a TaskView given an index
     */
    fun getDesktopTaskViewCount(numChildren: Int, getTaskViewAt: (Int) -> TaskView?): Int =
        (0 until numChildren).count { getTaskViewAt(it) is DesktopTaskView }

    /**
     * Returns the first TaskView that should be displayed as a large tile.
     *
     * @param numChildren Quantity of children to transverse
     * @param getTaskViewAt Function that provides a TaskView given an index
     */
    fun getFirstLargeTaskView(numChildren: Int, getTaskViewAt: (Int) -> TaskView?): TaskView? {
        return (0 until numChildren).firstNotNullOfOrNull { index ->
            val taskView = getTaskViewAt(index)
            if (taskView?.isLargeTile == true) taskView else null
        }
    }
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -191,7 +191,7 @@ public final class DigitalWellBeingToast {
    private @SplitBannerConfig int getSplitBannerConfig() {
    private @SplitBannerConfig int getSplitBannerConfig() {
        if (mSplitBounds == null
        if (mSplitBounds == null
                || !mContainer.getDeviceProfile().isTablet
                || !mContainer.getDeviceProfile().isTablet
                || mTaskView.isFocusedTask()) {
                || mTaskView.isLargeTile()) {
            return SPLIT_BANNER_FULLSCREEN;
            return SPLIT_BANNER_FULLSCREEN;
        }
        }


Loading