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

Commit 41d8ae8a authored by Jeremy Sim's avatar Jeremy Sim
Browse files

Implements the "Save App Pair" button in Overview Actions

Second attempt at enabling this feature. See ag/25143701, linked bugs, and revert history for details. This patch is tested with mokey devices and does not crash!

This patch includes:
- Ability to "save app pair" from Overview Actions.
- Internally the actions bar is not longer hidden for GroupedTasks; instead the individual buttons for "Select", "Screenshot", and "Split screen" are toggled off and "Save app pair" is toggled on.
- "Save app pair" option does not appear in icon menu when it is visible in the Actions Bar.
- Addition to go/quickstep/res/layout/overview_actions_container.xml to support addition of the new button.

Note: This patch introduces a slight regression where users are now able to long-press to select text on task 1 of a paired GroupedTaskView (previously we did not let them select text on either task for consistency.) Will follow up with a fix -- see bug for details.

Flag: ACONFIG com.android.wm.shell.enable_app_pairs TRUNKFOOD
Fixes: 315545418
Fixes: 315292030
Test: Manual, all action buttons still work and "Save app pair" appears and disappears correctly
Change-Id: I4b4ac525cfd5eb9cfcd757d0bffc7215b04f9a3d
parent 7e0703ec
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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
+9 −0
Original line number Diff line number Diff line
@@ -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"
+2 −0
Original line number Diff line number Diff line
@@ -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>
+15 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.launcher3.util.ResourceBasedOverride;
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 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
            }
        }

        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 class TaskOverlayFactory implements ResourceBasedOverride {
            public void onSplit() {
                endLiveTileMode(TaskOverlay.this::enterSplitSelect);
            }

            public void onSaveAppPair() {
                endLiveTileMode(TaskOverlay.this::saveAppPair);
            }
        }
    }

@@ -342,5 +353,8 @@ public class TaskOverlayFactory implements ResourceBasedOverride {

        /** 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();
    }
}
+14 −2
Original line number Diff line number Diff line
@@ -311,9 +311,21 @@ public interface TaskShortcutFactory {
        @Override
        public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
                TaskIdAttributeContainer taskContainer) {
            DeviceProfile deviceProfile = activity.getDeviceProfile();
            final TaskView taskView = taskContainer.getTaskView();

            if (!FeatureFlags.enableAppPairs() || !taskView.containsMultipleTasks()) {
            final RecentsView recentsView = taskView.getRecentsView();
            boolean isLargeTileFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask();
            boolean isInExpectedScrollPosition =
                    recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
            boolean shouldShowActionsButtonInstead =
                    isLargeTileFocusedTask && isInExpectedScrollPosition;

            // 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;
            }

Loading