Add task menu shortcut for closing apps
Fix: 383977717 Test: OverviewMenuImageTest Flag: EXEMPT bugfix Change-Id: I24338a821e1ec9be21d22a5d1c4295dd6e28d13d
This commit is contained in:
@@ -120,7 +120,8 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
|
||||
TaskShortcutFactory.WELLBEING,
|
||||
TaskShortcutFactory.SAVE_APP_PAIR,
|
||||
TaskShortcutFactory.SCREENSHOT,
|
||||
TaskShortcutFactory.MODAL
|
||||
TaskShortcutFactory.MODAL,
|
||||
TaskShortcutFactory.CLOSE,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<SystemShortcut> 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user