diff --git a/quickstep/res/drawable/ic_close_option.xml b/quickstep/res/drawable/ic_close_option.xml new file mode 100644 index 0000000000..5681cb58e7 --- /dev/null +++ b/quickstep/res/drawable/ic_close_option.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml index d2a7029bda..8e70a2b835 100644 --- a/quickstep/res/values/strings.xml +++ b/quickstep/res/values/strings.xml @@ -30,6 +30,8 @@ Desktop Move to external display + + Close Desktop diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index 0772159890..a594e49445 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -120,7 +120,8 @@ public class TaskOverlayFactory implements ResourceBasedOverride { TaskShortcutFactory.WELLBEING, TaskShortcutFactory.SAVE_APP_PAIR, TaskShortcutFactory.SCREENSHOT, - TaskShortcutFactory.MODAL + TaskShortcutFactory.MODAL, + TaskShortcutFactory.CLOSE, }; /** diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java index ee1d8a6292..2dbd5e98a1 100644 --- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java @@ -21,6 +21,7 @@ import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; import static android.view.Surface.ROTATION_0; import static com.android.launcher3.Flags.enableRefactorTaskThumbnail; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_CLOSE_APP_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT; @@ -297,6 +298,29 @@ public interface TaskShortcutFactory { } } + class CloseSystemShortcut extends SystemShortcut { + private final TaskContainer mTaskContainer; + + public CloseSystemShortcut(int iconResId, int textResId, RecentsViewContainer container, + TaskContainer taskContainer) { + super(iconResId, textResId, container, taskContainer.getTaskView().getFirstItemInfo(), + taskContainer.getTaskView()); + mTaskContainer = taskContainer; + } + + @Override + public void onClick(View view) { + TaskView taskView = mTaskContainer.getTaskView(); + RecentsView recentsView = taskView.getRecentsView(); + if (recentsView != null) { + dismissTaskMenuView(); + recentsView.dismissTask(taskView, true, true); + mTarget.getStatsLogManager().logger().withItemInfo(mTaskContainer.getItemInfo()) + .log(LAUNCHER_SYSTEM_SHORTCUT_CLOSE_APP_TAP); + } + } + } + /** * Does NOT add split options in the following scenarios: * * 1. Taskbar is not present AND aren't at least 2 tasks in overview to show split options for @@ -517,4 +541,24 @@ public interface TaskShortcutFactory { return createSingletonShortcutList(modalStateSystemShortcut); } }; + + TaskShortcutFactory CLOSE = new TaskShortcutFactory() { + @Override + public List getShortcuts(RecentsViewContainer container, + TaskContainer taskContainer) { + return Collections.singletonList(new CloseSystemShortcut( + R.drawable.ic_close_option, + R.string.recent_task_option_close, container, taskContainer)); + } + + @Override + public boolean showForGroupedTask() { + return true; + } + + @Override + public boolean showForDesktopTask() { + return true; + } + }; } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 9807b0de74..ce0efb6418 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -36,7 +36,6 @@ import android.view.View import android.view.ViewGroup import android.view.ViewStub import android.view.accessibility.AccessibilityNodeInfo -import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction import android.widget.FrameLayout import android.widget.Toast import androidx.annotation.IntDef @@ -669,13 +668,6 @@ constructor( val shouldPopulateAccessibilityMenu = modalness == 0f && recentsView?.isSplitSelectionActive == false if (shouldPopulateAccessibilityMenu) { - addAction( - AccessibilityAction( - R.id.action_close, - context.getText(R.string.accessibility_close), - ) - ) - taskContainers.forEach { TraceHelper.allowIpcs("TV.a11yInfo") { TaskOverlayFactory.getEnabledShortcuts(this@TaskView, it).forEach { shortcut @@ -706,11 +698,6 @@ constructor( override fun performAccessibilityAction(action: Int, arguments: Bundle?): Boolean { // TODO(b/343708271): Add support for multiple tasks per action. - if (action == R.id.action_close) { - recentsView?.dismissTask(this, true /*animateTaskView*/, true /*removeTask*/) - return true - } - taskContainers.forEach { if (it.digitalWellBeingToast?.handleAccessibilityAction(action) == true) { return true diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 6eb02aba5a..2d3046667c 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -225,9 +225,12 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "User tapped on desktop icon on a task menu.") LAUNCHER_SYSTEM_SHORTCUT_DESKTOP_TAP(1706), - @UiEvent(doc = "Use tapped on external display icon on a task menu,") + @UiEvent(doc = "User tapped on external display icon on a task menu,") LAUNCHER_SYSTEM_SHORTCUT_EXTERNAL_DISPLAY_TAP(1957), + @UiEvent(doc = "User tapped on close app on a task menu,") + LAUNCHER_SYSTEM_SHORTCUT_CLOSE_APP_TAP(2081), + @UiEvent(doc = "User tapped on pause app system shortcut.") LAUNCHER_SYSTEM_SHORTCUT_PAUSE_TAP(521),