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

Commit ead5259f authored by Sergey Pinkevich's avatar Sergey Pinkevich
Browse files

Show split screen action for each task

Remove previous condition:
1. `taskView.containsMultipleTasks()` - there is already a check to filter out "Split screen" item: https://googleplex-android.googlesource.com/platform/packages/apps/Launcher3/+/refs/heads/main/quickstep/src/com/android/quickstep/TaskOverlayFactory.java#68

Edit previous condition:
2. `notEnoughTasksToSplit` - condition saying if there is less than 2 recent tasks. We still should give the possibility to split the screen if Taskbar is not presented

Bug: 305958994
Flag: NONE
Test: manual - took a photo (https://screenshot.googleplex.com/7doU5z9AjxxETUo)

Change-Id: I3fdfea987c426d557a91b0a25af368069e8af3f8
parent 0ddc9843
Loading
Loading
Loading
Loading
+31 −31
Original line number Diff line number Diff line
@@ -218,7 +218,8 @@ public interface TaskShortcutFactory {
                        new AppTransitionAnimationSpecsFuture(mHandler) {
                            @Override
                            public List<AppTransitionAnimationSpecCompat> composeSpecs() {
                        return Collections.singletonList(new AppTransitionAnimationSpecCompat(
                                return Collections.singletonList(
                                        new AppTransitionAnimationSpecCompat(
                                                taskId, thumbnail, taskBounds));
                            }
                        };
@@ -264,13 +265,12 @@ public interface TaskShortcutFactory {

    /**
     * Does NOT add split options in the following scenarios:
     * * The taskView to add split options is already showing split screen tasks
     * * There aren't at least 2 tasks in overview to show split options for
     * * Split isn't supported by the task itself (non resizable activity)
     * * We aren't currently in multi-window
     * * The taskView to show split options for is the focused task AND we haven't started
     * scrolling in overview (if we haven't scrolled, there's a split overview action button so
     * we don't need this menu option)
     * * 1. Taskbar is not present AND aren't at least 2 tasks in overview to show split options for
     * * 2. Split isn't supported by the task itself (non resizable activity)
     * * 3. We aren't currently in multi-window
     * * 4. The taskView to show split options for is the focused task AND we haven't started
     * * scrolling in overview (if we haven't scrolled, there's a split overview action button so
     * * we don't need this menu option)
     */
    TaskShortcutFactory SPLIT_SELECT = new TaskShortcutFactory() {
        @Override
@@ -284,18 +284,16 @@ public interface TaskShortcutFactory {
            final PagedOrientationHandler orientationHandler =
                    recentsView.getPagedOrientationHandler();

            boolean notEnoughTasksToSplit = recentsView.getTaskViewCount() < 2;
            boolean isFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask();
            boolean isTaskInExpectedScrollPosition =
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
            boolean notEnoughTasksToSplit =
                    !deviceProfile.isTaskbarPresent && recentsView.getTaskViewCount() < 2;
            boolean isTaskSplitNotSupported = !task.isDockable ||
                    (intentFlags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
            boolean hideForExistingMultiWindow = activity.getDeviceProfile().isMultiWindowMode;
            boolean isFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask();
            boolean isTaskInExpectedScrollPosition =
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));

            if (taskView.containsMultipleTasks()
                    || notEnoughTasksToSplit
                    || isTaskSplitNotSupported
                    || hideForExistingMultiWindow
            if (notEnoughTasksToSplit || isTaskSplitNotSupported || hideForExistingMultiWindow
                    || (isFocusedTask && isTaskInExpectedScrollPosition)) {
                return null;
            }
@@ -389,7 +387,8 @@ public interface TaskShortcutFactory {
        @Override
        public void onClick(View view) {
            if (mTaskView.launchTaskAnimated() != null) {
                SystemUiProxy.INSTANCE.get(mTarget).startScreenPinning(mTaskView.getTask().key.id);
                SystemUiProxy.INSTANCE.get(mTarget).startScreenPinning(
                        mTaskView.getTask().key.id);
            }
            dismissTaskMenuView(mTarget);
            mTarget.getStatsLogManager().logger().withItemInfo(mTaskView.getItemInfo())
@@ -425,7 +424,8 @@ public interface TaskShortcutFactory {
        @Override
        public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
                TaskIdAttributeContainer taskContainer) {
            SystemShortcut screenshotShortcut = taskContainer.getThumbnailView().getTaskOverlay()
            SystemShortcut screenshotShortcut =
                    taskContainer.getThumbnailView().getTaskOverlay()
                            .getScreenshotShortcut(activity, taskContainer.getItemInfo(),
                                    taskContainer.getTaskView());
            return createSingletonShortcutList(screenshotShortcut);
+28 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;

import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.tapl.TaskbarAppIcon;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.rule.TestStabilityRule;
@@ -139,6 +142,31 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
                        .hasMenuItem("Save app pair"));
    }

    @Test
    public void testSplitSingleTaskFromTaskbar() {
        // Currently only tablets have Taskbar in Overview, so test is only active on tablets
        assumeTrue(mLauncher.isTablet());

        if (!mLauncher.getRecentTasks().isEmpty()) {
            // Clear all recent tasks
            mLauncher.goHome().switchToOverview().dismissAllTasks();
        }

        startAppFast(getAppPackageName());

        Overview overview = mLauncher.goHome().switchToOverview();
        if (mLauncher.isGridOnlyOverviewEnabled()) {
            overview.getCurrentTask().tapMenu().tapSplitMenuItem();
        } else {
            overview.getOverviewActions().clickSplit();
        }

        Taskbar taskbar = overview.getTaskbar();
        String firstAppName = taskbar.getIconNames().get(0);
        TaskbarAppIcon firstApp = taskbar.getAppIcon(firstAppName);
        firstApp.launchIntoSplitScreen();
    }

    private void createAndLaunchASplitPair() {
        startTestActivity(2);
        startTestActivity(3);
+19 −0
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package com.android.launcher3.tapl;

import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID;

import android.graphics.Rect;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.Direction;
@@ -322,6 +325,22 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
                mLauncher.getOverviewObjectSelector("clear_all"));
    }

    /**
     * Returns the taskbar if it's a tablet, or {@code null} otherwise.
     */
    @Nullable
    public Taskbar getTaskbar() {
        if (!mLauncher.isTablet()) {
            return null;
        }
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to get the taskbar")) {
            mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);

            return new Taskbar(mLauncher);
        }
    }

    protected boolean isActionsViewVisible() {
        if (!hasTasks() || isClearAllVisible()) {
            return false;