diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 6df31e5670..62a11d4954 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -353,6 +353,13 @@ public class LauncherTaskbarUIController extends TaskbarUIController { .get(); } + @Override + public void onExpandPip() { + super.onExpandPip(); + mTaskbarLauncherStateController.updateStateForFlag(FLAG_RESUMED, false); + mTaskbarLauncherStateController.applyState(); + } + @Override public void dumpLogs(String prefix, PrintWriter pw) { super.dumpLogs(prefix, pw); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index c00bcb97c9..9cae53be43 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -627,7 +627,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext { /** Adds the given view to WindowManager with the provided LayoutParams (creates new window). */ public void addWindowView(View view, WindowManager.LayoutParams windowLayoutParams) { - mWindowManager.addView(view, windowLayoutParams); + if (!view.isAttachedToWindow()) { + mWindowManager.addView(view, windowLayoutParams); + } } /** Removes the given view from WindowManager. See {@link #addWindowView}. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt index 946873e7ab..81acda3d75 100644 --- a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt @@ -36,7 +36,10 @@ class VoiceInteractionWindowController(val context: TaskbarActivityContext) override fun draw(canvas: Canvas) { super.draw(canvas) - taskbarBackgroundRenderer.draw(canvas) + if (this@VoiceInteractionWindowController.context.isGestureNav + && controllers.taskbarStashController.isInAppAndNotStashed) { + taskbarBackgroundRenderer.draw(canvas) + } } } separateWindowForTaskbarBackground.recreateControllers() @@ -74,18 +77,20 @@ class VoiceInteractionWindowController(val context: TaskbarActivityContext) fadeStashedHandle.end() } - if (context.isGestureNav && controllers.taskbarStashController.isInAppAndNotStashed) { - moveTaskbarBackgroundToLowerLayer() - } + moveTaskbarBackgroundToAppropriateLayer() } /** + * Either: * Hides the TaskbarDragLayer background and creates a new window to draw just that background. + * OR + * Removes the temporary window and show the TaskbarDragLayer background again. */ - private fun moveTaskbarBackgroundToLowerLayer() { + private fun moveTaskbarBackgroundToAppropriateLayer() { val taskbarBackgroundOverride = controllers.taskbarDragLayerController .overrideBackgroundAlpha - if (isVoiceInteractionWindowVisible) { + val moveToLowerLayer = isVoiceInteractionWindowVisible + if (moveToLowerLayer) { // First add the temporary window, then hide the overlapping taskbar background. context.addWindowView(separateWindowForTaskbarBackground, separateWindowLayoutParams) ViewRootSync.synchronizeNextDraw(separateWindowForTaskbarBackground, context.dragLayer diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 4bd627a868..159b65fcd3 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -179,6 +179,21 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { actionsView.clickAndDismissScreenshot(); } + @Test + @PortraitLandscape + public void testSplitFromOverview() { + assumeTrue(!mLauncher.isTablet()); + + startTestActivity(2); + startTestActivity(3); + + mLauncher.goHome().switchToOverview().getCurrentTask() + .tapMenu() + .tapSplitMenuItem() + .getTestActivityTask(2) + .open(); + } + @Test @PortraitLandscape public void testSplitFromOverviewForTablet() { diff --git a/src/com/android/launcher3/FastScrollRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java index 94903f278e..747b755263 100644 --- a/src/com/android/launcher3/FastScrollRecyclerView.java +++ b/src/com/android/launcher3/FastScrollRecyclerView.java @@ -57,7 +57,9 @@ public abstract class FastScrollRecyclerView extends RecyclerView { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - bindFastScrollbar(); + if (mScrollbar == null || !mScrollbar.hasRecyclerView()) { + bindFastScrollbar(); + } } public void bindFastScrollbar() { diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index 11ca130179..6e6512d294 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -174,6 +174,11 @@ public class RecyclerViewFastScroller extends View { ta.recycle(); } + /** @return whether there is a RecyclerView bound to this scroller. */ + public boolean hasRecyclerView() { + return mRv != null; + } + public void setRecyclerView(FastScrollRecyclerView rv, TextView popupView) { if (mRv != null && mOnScrollListener != null) { mRv.removeOnScrollListener(mOnScrollListener); diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index 6a11336bb9..3321c63502 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -247,8 +247,12 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { return mLauncher.hasLauncherObject(mLauncher.getOverviewObjectSelector("clear_all")); } + protected boolean isActionsViewVisible() { + return true; + } + private void verifyActionsViewVisibility() { - if (!hasTasks()) { + if (!hasTasks() || !isActionsViewVisible()) { return; } try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index fca2ab75cf..9d06b6bb01 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -169,6 +169,7 @@ public final class LauncherInstrumentation { private static final String WIDGETS_RES_ID = "primary_widgets_list_view"; private static final String CONTEXT_MENU_RES_ID = "popup_container"; private static final String TASKBAR_RES_ID = "taskbar_view"; + private static final String SPLIT_PLACEHOLDER_RES_ID = "split_placeholder"; public static final int WAIT_TIME_MS = 30000; private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; private static final String ANDROID_PACKAGE = "android"; @@ -731,6 +732,7 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(WORKSPACE_RES_ID); } @@ -739,6 +741,7 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(WIDGETS_RES_ID); } @@ -748,16 +751,26 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(APPS_RES_ID); } - case OVERVIEW: + case OVERVIEW: { + waitUntilLauncherObjectGone(APPS_RES_ID); + waitUntilLauncherObjectGone(WORKSPACE_RES_ID); + waitUntilLauncherObjectGone(WIDGETS_RES_ID); + waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + + return waitForLauncherObject(OVERVIEW_RES_ID); + } case SPLIT_SCREEN_SELECT: { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitForLauncherObject(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(OVERVIEW_RES_ID); } case FALLBACK_OVERVIEW: { @@ -765,6 +778,7 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForFallbackLauncherObject(OVERVIEW_RES_ID); } @@ -773,6 +787,7 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); + waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); if (isTablet() && !isFallbackOverview()) { waitForLauncherObject(TASKBAR_RES_ID); diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index 72a39df6c3..14192d62a3 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -20,6 +20,7 @@ import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CH import android.graphics.Rect; +import androidx.annotation.NonNull; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; @@ -159,4 +160,20 @@ public final class OverviewTask { } } } + + /** Taps the task menu. */ + @NonNull + public OverviewTaskMenu tapMenu() { + try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); + LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "want to tap the task menu")) { + mLauncher.clickLauncherObject( + mLauncher.waitForObjectInContainer(mTask.getParent(), "icon")); + + try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( + "tapped the task menu")) { + return new OverviewTaskMenu(mLauncher); + } + } + } } diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java new file mode 100644 index 0000000000..8cdc8a036e --- /dev/null +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 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.launcher3.tapl; + +import androidx.annotation.NonNull; +import androidx.test.uiautomator.By; +import androidx.test.uiautomator.UiObject2; + +/** Represents the menu of an overview task. */ +public class OverviewTaskMenu { + + private final LauncherInstrumentation mLauncher; + private final UiObject2 mMenu; + + OverviewTaskMenu(LauncherInstrumentation launcher) { + mLauncher = launcher; + + mMenu = mLauncher.waitForLauncherObject("menu_option_layout"); + mLauncher.assertTrue("The overview task menus is not visible", + !mMenu.getVisibleBounds().isEmpty()); + } + + /** Taps the split menu item from the overview task menu. */ + @NonNull + public SplitScreenSelect tapSplitMenuItem() { + try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); + LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "tap split menu item")) { + mLauncher.clickLauncherObject( + mLauncher.findObjectInContainer(mMenu, By.textStartsWith("Split"))); + + try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( + "tapped split menu item")) { + return new SplitScreenSelect(mLauncher); + } + } + } +} diff --git a/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java b/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java index 3cf3ed662f..9fa74e48c2 100644 --- a/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java +++ b/tests/tapl/com/android/launcher3/tapl/SplitScreenSelect.java @@ -32,4 +32,10 @@ public class SplitScreenSelect extends Overview { protected ContainerType getContainerType() { return ContainerType.SPLIT_SCREEN_SELECT; } + + @Override + protected boolean isActionsViewVisible() { + // We don't show overview actions in split select state. + return false; + } }