Merge "Implements the "Save App Pair" button in Overview Actions" into main
diff --git a/go/quickstep/res/layout/overview_actions_container.xml b/go/quickstep/res/layout/overview_actions_container.xml
index 48650aa..077cfae 100644
--- a/go/quickstep/res/layout/overview_actions_container.xml
+++ b/go/quickstep/res/layout/overview_actions_container.xml
@@ -120,6 +120,16 @@
android:layout_height="1dp"
android:layout_weight="1"
android:visibility="gone" />
+
+ <Button
+ android:id="@+id/action_save_app_pair"
+ style="@style/GoOverviewActionButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:drawableStart="@drawable/ic_save_app_pair"
+ android:text="@string/action_save_app_pair"
+ android:theme="@style/ThemeControlHighlightWorkspaceColor"
+ android:visibility="gone" />
</LinearLayout>
</com.android.quickstep.views.GoOverviewActionsView>
\ No newline at end of file
diff --git a/quickstep/res/layout/overview_actions_container.xml b/quickstep/res/layout/overview_actions_container.xml
index 0fda0bf..5bd5823 100644
--- a/quickstep/res/layout/overview_actions_container.xml
+++ b/quickstep/res/layout/overview_actions_container.xml
@@ -55,6 +55,15 @@
android:theme="@style/ThemeControlHighlightWorkspaceColor"
android:visibility="gone" />
+ <Button
+ android:id="@+id/action_save_app_pair"
+ style="@style/OverviewActionButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/action_save_app_pair"
+ android:theme="@style/ThemeControlHighlightWorkspaceColor"
+ android:visibility="gone" />
+
<Space
android:layout_width="0dp"
android:layout_height="1dp"
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index 14f615e..75a4fc8 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -230,6 +230,8 @@
<string name="action_screenshot">Screenshot</string>
<!-- Label for a button that enters split screen selection mode. [CHAR_LIMIT=20] -->
<string name="action_split">Split</string>
+ <!-- Label for a button that saves a new app pair. [CHAR_LIMIT=20] -->
+ <string name="action_save_app_pair">Save app pair</string>
<!-- Label for toast with instructions for split screen selection mode. [CHAR_LIMIT=50] -->
<string name="toast_split_select_app">Tap another app to use split screen</string>
<string name="toast_contextual_split_select_app">Choose another app to use split screen</string>
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 312cdc9..cc582d1 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -43,6 +43,7 @@
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.Snackbar;
import com.android.quickstep.util.RecentsOrientedState;
+import com.android.quickstep.views.GroupedTaskView;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskThumbnailView;
@@ -210,13 +211,19 @@
}
}
- private void enterSplitSelect() {
+ protected void enterSplitSelect() {
RecentsView overviewPanel = mThumbnailView.getTaskView().getRecentsView();
// Task has already been dismissed
if (overviewPanel == null) return;
overviewPanel.initiateSplitSelect(mThumbnailView.getTaskView());
}
+ protected void saveAppPair() {
+ GroupedTaskView taskView = (GroupedTaskView) mThumbnailView.getTaskView();
+ taskView.getRecentsView().getSplitSelectController().getAppPairsController()
+ .saveAppPair(taskView);
+ }
+
/**
* Called when the overlay is no longer used.
*/
@@ -329,6 +336,10 @@
public void onSplit() {
endLiveTileMode(TaskOverlay.this::enterSplitSelect);
}
+
+ public void onSaveAppPair() {
+ endLiveTileMode(TaskOverlay.this::saveAppPair);
+ }
}
}
@@ -342,5 +353,8 @@
/** User wants to start split screen with current app. */
void onSplit();
+
+ /** User wants to save an app pair with current group of apps. */
+ void onSaveAppPair();
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index 9c84df8..c1b3a16 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -311,9 +311,21 @@
@Override
public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
TaskIdAttributeContainer taskContainer) {
+ DeviceProfile deviceProfile = activity.getDeviceProfile();
final TaskView taskView = taskContainer.getTaskView();
+ final RecentsView recentsView = taskView.getRecentsView();
+ boolean isLargeTileFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask();
+ boolean isInExpectedScrollPosition =
+ recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
+ boolean shouldShowActionsButtonInstead =
+ isLargeTileFocusedTask && isInExpectedScrollPosition;
- if (!FeatureFlags.enableAppPairs() || !taskView.containsMultipleTasks()) {
+ // No "save app pair" menu item if:
+ // - app pairs feature is not enabled
+ // - the task in question is a single task
+ // - the Overview Actions Button should be visible
+ if (!FeatureFlags.enableAppPairs() || !taskView.containsMultipleTasks()
+ || shouldShowActionsButtonInstead) {
return null;
}
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
index 10ef47c..259927d 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
@@ -24,6 +24,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.CancellableTask;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SplitConfigurationOptions;
@@ -40,11 +41,11 @@
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
import com.android.wm.shell.common.split.SplitScreenConstants.PersistentSnapPosition;
-import kotlin.Unit;
-
import java.util.HashMap;
import java.util.function.Consumer;
+import kotlin.Unit;
+
/**
* TaskView that contains and shows thumbnails for not one, BUT TWO(!!) tasks
*
@@ -382,7 +383,11 @@
@Override
public void setOverlayEnabled(boolean overlayEnabled) {
- // Intentional no-op to prevent setting smart actions overlay on thumbnails
+ if (FeatureFlags.enableAppPairs()) {
+ super.setOverlayEnabled(overlayEnabled);
+ } else {
+ // Intentional no-op to prevent setting smart actions overlay on thumbnails
+ }
}
@Override
diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
index 8281ad7..7a1c49a 100644
--- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
+++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
@@ -33,6 +33,7 @@
import com.android.launcher3.Flags;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.util.MultiValueAlpha;
@@ -92,14 +93,28 @@
private static final int INDEX_SCROLL_ALPHA = 5;
private static final int NUM_ALPHAS = 6;
+ public @interface ScreenshotButtonHiddenFlags { }
+ public static final int FLAG_MULTIPLE_TASKS_HIDE_SCREENSHOT = 1 << 0;
+
public @interface SplitButtonHiddenFlags { }
- public static final int FLAG_IS_NOT_TABLET = 1 << 0;
+ public static final int FLAG_SMALL_SCREEN_HIDE_SPLIT = 1 << 0;
+ public static final int FLAG_MULTIPLE_TASKS_HIDE_SPLIT = 1 << 1;
public @interface SplitButtonDisabledFlags { }
- public static final int FLAG_SINGLE_TASK = 1 << 0;
+ public static final int FLAG_SINGLE_TASK_DISABLE_SPLIT = 1 << 0;
+
+ public @interface AppPairButtonHiddenFlags { }
+ public static final int FLAG_SINGLE_TASK_HIDE_APP_PAIR = 1 << 0;
+ public static final int FLAG_SMALL_SCREEN_HIDE_APP_PAIR = 1 << 1;
private MultiValueAlpha mMultiValueAlpha;
+
+ // The screenshot button is implemented as a Button in launcher3 and NexusLauncher, but is an
+ // ImageButton in go launcher (does not share a common class with Button). Take care when
+ // casting this.
+ private View mScreenshotButton;
private Button mSplitButton;
+ private Button mSaveAppPairButton;
@ActionsHiddenFlags
private int mHiddenFlags;
@@ -107,11 +122,14 @@
@ActionsDisabledFlags
protected int mDisabledFlags;
+ @ScreenshotButtonHiddenFlags
+ private int mScreenshotButtonHiddenFlags;
+
@SplitButtonHiddenFlags
private int mSplitButtonHiddenFlags;
- @SplitButtonDisabledFlags
- private int mSplitButtonDisabledFlags;
+ @AppPairButtonHiddenFlags
+ private int mAppPairButtonHiddenFlags;
@Nullable
protected T mCallbacks;
@@ -138,9 +156,12 @@
mMultiValueAlpha = new MultiValueAlpha(findViewById(R.id.action_buttons), NUM_ALPHAS);
mMultiValueAlpha.setUpdateVisibility(true);
- findViewById(R.id.action_screenshot).setOnClickListener(this);
+ mScreenshotButton = findViewById(R.id.action_screenshot);
+ mScreenshotButton.setOnClickListener(this);
mSplitButton = findViewById(R.id.action_split);
mSplitButton.setOnClickListener(this);
+ mSaveAppPairButton = findViewById(R.id.action_save_app_pair);
+ mSaveAppPairButton.setOnClickListener(this);
}
/**
@@ -162,6 +183,8 @@
mCallbacks.onScreenshot();
} else if (id == R.id.action_split) {
mCallbacks.onSplit();
+ } else if (id == R.id.action_save_app_pair) {
+ mCallbacks.onSaveAppPair();
}
}
@@ -204,7 +227,49 @@
}
boolean isEnabled = (mDisabledFlags & ~DISABLED_ROTATED) == 0;
LayoutUtils.setViewEnabled(this, isEnabled);
- updateSplitButtonEnabledState();
+ }
+
+ /**
+ * Updates a batch of flags to hide and show actions buttons when a grouped task (split screen)
+ * is focused.
+ * @param isGroupedTask True if the focused task is a grouped task.
+ */
+ public void updateForGroupedTask(boolean isGroupedTask) {
+ // Update flags to see if split button should be hidden.
+ updateSplitButtonHiddenFlags(FLAG_MULTIPLE_TASKS_HIDE_SPLIT, isGroupedTask);
+ // Update flags to see if screenshot button should be hidden.
+ updateScreenshotButtonHiddenFlags(FLAG_MULTIPLE_TASKS_HIDE_SCREENSHOT, isGroupedTask);
+ // Update flags to see if save app pair button should be hidden.
+ updateAppPairButtonHiddenFlags(FLAG_SINGLE_TASK_HIDE_APP_PAIR, !isGroupedTask);
+ }
+
+ /**
+ * Updates a batch of flags to hide and show actions buttons for tablet/non tablet case.
+ * @param isSmallScreen True if the current display is a small screen.
+ */
+ public void updateForSmallScreen(boolean isSmallScreen) {
+ // Update flags to see if split button should be hidden.
+ updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, isSmallScreen);
+ // Update flags to see if save app pair button should be hidden.
+ updateAppPairButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_APP_PAIR, isSmallScreen);
+ }
+
+ /**
+ * Updates the proper flags to indicate whether the "Screenshot" button should be hidden.
+ *
+ * @param flag The flag to update.
+ * @param enable Whether to enable the hidden flag: True will cause view to be hidden.
+ */
+ private void updateScreenshotButtonHiddenFlags(@ScreenshotButtonHiddenFlags int flag,
+ boolean enable) {
+ if (mScreenshotButton == null) return;
+ if (enable) {
+ mScreenshotButtonHiddenFlags |= flag;
+ } else {
+ mScreenshotButtonHiddenFlags &= ~flag;
+ }
+ int desiredVisibility = mScreenshotButtonHiddenFlags == 0 ? VISIBLE : GONE;
+ mScreenshotButton.setVisibility(desiredVisibility);
}
/**
@@ -213,16 +278,17 @@
* @param flag The flag to update.
* @param enable Whether to enable the hidden flag: True will cause view to be hidden.
*/
- public void updateSplitButtonHiddenFlags(@SplitButtonHiddenFlags int flag, boolean enable) {
+ void updateSplitButtonHiddenFlags(@SplitButtonHiddenFlags int flag,
+ boolean enable) {
+ if (mSplitButton == null) return;
if (enable) {
mSplitButtonHiddenFlags |= flag;
} else {
mSplitButtonHiddenFlags &= ~flag;
}
- if (mSplitButton == null) return;
- boolean shouldBeVisible = mSplitButtonHiddenFlags == 0;
- mSplitButton.setVisibility(shouldBeVisible ? VISIBLE : GONE);
- findViewById(R.id.action_split_space).setVisibility(shouldBeVisible ? VISIBLE : GONE);
+ int desiredVisibility = mSplitButtonHiddenFlags == 0 ? VISIBLE : GONE;
+ mSplitButton.setVisibility(desiredVisibility);
+ findViewById(R.id.action_split_space).setVisibility(desiredVisibility);
String callStack = Arrays.stream(
Log.getStackTraceString(new Exception("thread stacktrace"))
@@ -232,23 +298,30 @@
.collect(Collectors.joining("\n"));
Log.d("b/321291049", "updateSplitButtonHiddenFlags called with flag: " + flag
+ " enabled: " + enable
- + " shouldBeVisible: " + shouldBeVisible
+ + " visibility: " + desiredVisibility
+ " partial trace: \n" + callStack);
}
/**
- * Updates the proper flags to indicate whether the "Split screen" button should be disabled.
+ * Updates the proper flags to indicate whether the "Save app pair" button should be disabled.
*
* @param flag The flag to update.
- * @param enable Whether to enable the disable flag: True will cause view to be disabled.
+ * @param enable Whether to enable the hidden flag: True will cause view to be hidden.
*/
- public void updateSplitButtonDisabledFlags(@SplitButtonDisabledFlags int flag, boolean enable) {
- if (enable) {
- mSplitButtonDisabledFlags |= flag;
- } else {
- mSplitButtonDisabledFlags &= ~flag;
+ private void updateAppPairButtonHiddenFlags(
+ @AppPairButtonHiddenFlags int flag, boolean enable) {
+ if (!FeatureFlags.enableAppPairs()) {
+ return;
}
- updateSplitButtonEnabledState();
+
+ if (mSaveAppPairButton == null) return;
+ if (enable) {
+ mAppPairButtonHiddenFlags |= flag;
+ } else {
+ mAppPairButtonHiddenFlags &= ~flag;
+ }
+ int desiredVisibility = mAppPairButtonHiddenFlags == 0 ? VISIBLE : GONE;
+ mSaveAppPairButton.setVisibility(desiredVisibility);
}
public MultiProperty getContentAlpha() {
@@ -326,19 +399,7 @@
? R.drawable.ic_split_horizontal
: R.drawable.ic_split_vertical;
mSplitButton.setCompoundDrawablesRelativeWithIntrinsicBounds(splitIconRes, 0, 0, 0);
+ mSaveAppPairButton.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ R.drawable.ic_save_app_pair, 0, 0, 0);
}
-
- /**
- * Enables/disables the "Split" button based on the status of mSplitButtonDisabledFlags and
- * mDisabledFlags.
- */
- private void updateSplitButtonEnabledState() {
- if (mSplitButton == null) {
- return;
- }
- boolean isParentEnabled = (mDisabledFlags & ~DISABLED_ROTATED) == 0;
- boolean shouldBeEnabled = mSplitButtonDisabledFlags == 0 && isParentEnabled;
- mSplitButton.setEnabled(shouldBeEnabled);
- }
-
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index ea33b4d..6699147 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -62,8 +62,6 @@
import static com.android.quickstep.util.TaskGridNavHelper.DIRECTION_UP;
import static com.android.quickstep.views.ClearAllButton.DISMISS_ALPHA;
import static com.android.quickstep.views.DesktopTaskView.isDesktopModeSupported;
-import static com.android.quickstep.views.OverviewActionsView.FLAG_IS_NOT_TABLET;
-import static com.android.quickstep.views.OverviewActionsView.FLAG_SINGLE_TASK;
import static com.android.quickstep.views.OverviewActionsView.HIDDEN_ACTIONS_IN_MENU;
import static com.android.quickstep.views.OverviewActionsView.HIDDEN_DESKTOP;
import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION;
@@ -4007,18 +4005,24 @@
}
/**
- * Hides all overview actions if current page is for split apps, shows otherwise
- * If actions are showing, we only show split option if
+ * Hides all overview actions if user is halfway through split selection, shows otherwise.
+ * We only show split option if:
+ * * Focused view is a single app
* * Device is large screen
- * * There are at least 2 tasks to invoke split
*/
private void updateCurrentTaskActionsVisibility() {
boolean isCurrentSplit = getCurrentPageTaskView() instanceof GroupedTaskView;
- mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SCREEN, isCurrentSplit);
+ // Update flags to see if entire actions bar should be hidden.
+ if (!FeatureFlags.enableAppPairs()) {
+ mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SCREEN, isCurrentSplit);
+ }
mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SELECT_ACTIVE, isSplitSelectionActive());
- mActionsView.updateSplitButtonHiddenFlags(FLAG_IS_NOT_TABLET,
- !mActivity.getDeviceProfile().isTablet);
- mActionsView.updateSplitButtonDisabledFlags(FLAG_SINGLE_TASK, /*enable=*/ false);
+ // Update flags to see if actions bar should show buttons for a single task or a pair of
+ // tasks.
+ mActionsView.updateForGroupedTask(isCurrentSplit);
+ // Update flags to see if actions bar should show buttons for tablets or phones.
+ mActionsView.updateForSmallScreen(!mActivity.getDeviceProfile().isTablet);
+
if (isDesktopModeSupported()) {
boolean isCurrentDesktop = getCurrentPageTaskView() instanceof DesktopTaskView;
mActionsView.updateHiddenFlags(HIDDEN_DESKTOP, isCurrentDesktop);
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 1231cd7..07df7af 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -21,6 +21,7 @@
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.config.FeatureFlags.enableSplitContextually;
import static com.android.launcher3.testing.shared.TestProtocol.TEST_INFO_RESPONSE_FIELD;
+import static com.android.launcher3.config.FeatureFlags.enableAppPairs;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.app.Activity;
@@ -300,6 +301,11 @@
return response;
}
+ case TestProtocol.REQUEST_FLAG_ENABLE_APP_PAIRS: {
+ response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, enableAppPairs());
+ return response;
+ }
+
default:
return null;
}
diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
index bc3a136..7d195fd 100644
--- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
@@ -183,6 +183,7 @@
public static final String REQUEST_EMULATE_PRINT_DEVICE = "emulate-print-device";
public static final String REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW = "enable-grid-only-overview";
+ public static final String REQUEST_FLAG_ENABLE_APP_PAIRS = "enable-app-pairs";
public static final String REQUEST_UNSTASH_BUBBLE_BAR_IF_STASHED =
"unstash-bubble-bar-if-stashed";
diff --git a/tests/multivalentTests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/multivalentTests/tapl/com/android/launcher3/tapl/BaseOverview.java
index ad95ecf..4f20c57 100644
--- a/tests/multivalentTests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/multivalentTests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -401,8 +401,11 @@
if (isTablet && Math.abs(task.getExactCenterX() - mLauncher.getExactScreenCenterX()) >= 1) {
return false;
}
- // Overview actions aren't visible for split screen tasks.
- return !task.isTaskSplit();
+ if (!mLauncher.isAppPairsEnabled() && task.isTaskSplit()) {
+ // Overview actions aren't visible for split screen tasks.
+ return false;
+ }
+ return true;
}
/**
diff --git a/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 053b360..aa792bf 100644
--- a/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1952,6 +1952,10 @@
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
+ boolean isAppPairsEnabled() {
+ return getTestInfo(TestProtocol.REQUEST_FLAG_ENABLE_APP_PAIRS).getBoolean(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ }
public void sendPointer(long downTime, long currentTime, int action, Point point,
GestureScope gestureScope) {
sendPointer(downTime, currentTime, action, point, gestureScope,