Merge "Ensure null elements aren't added to TaskView shortcut list" into tm-qpr-dev am: 9307776597

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18759197

Change-Id: I19a2a12de503313067a5516ce401dbbd0fb6c894
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-06-06 21:59:54 +00:00
committed by Automerger Merge Worker
@@ -74,6 +74,15 @@ public interface TaskShortcutFactory {
return false;
}
/** @return a singleton list if the provided shortcut is non-null, null otherwise */
@Nullable
default List<SystemShortcut> createSingletonShortcutList(@Nullable SystemShortcut shortcut) {
if (shortcut != null) {
return Collections.singletonList(shortcut);
}
return null;
}
TaskShortcutFactory APP_INFO = new TaskShortcutFactory() {
@Override
public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
@@ -373,9 +382,10 @@ public interface TaskShortcutFactory {
@Override
public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
TaskIdAttributeContainer taskContainer) {
return Collections.singletonList(
SystemShortcut<BaseDraggingActivity> wellbeingShortcut =
WellbeingModel.SHORTCUT_FACTORY.getShortcut(activity,
taskContainer.getItemInfo(), taskContainer.getTaskView()));
taskContainer.getItemInfo(), taskContainer.getTaskView());
return createSingletonShortcutList(wellbeingShortcut);
}
};
@@ -383,10 +393,10 @@ public interface TaskShortcutFactory {
@Override
public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
TaskIdAttributeContainer taskContainer) {
return Collections.singletonList(
taskContainer.getThumbnailView().getTaskOverlay()
.getScreenshotShortcut(activity, taskContainer.getItemInfo(),
taskContainer.getTaskView()));
SystemShortcut screenshotShortcut = taskContainer.getThumbnailView().getTaskOverlay()
.getScreenshotShortcut(activity, taskContainer.getItemInfo(),
taskContainer.getTaskView());
return createSingletonShortcutList(screenshotShortcut);
}
};
@@ -394,10 +404,12 @@ public interface TaskShortcutFactory {
@Override
public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
TaskIdAttributeContainer taskContainer) {
SystemShortcut modalStateSystemShortcut =
taskContainer.getThumbnailView().getTaskOverlay()
.getModalStateSystemShortcut(
taskContainer.getItemInfo(), taskContainer.getTaskView());
if (ENABLE_OVERVIEW_SELECTIONS.get()) {
return Collections.singletonList(taskContainer.getThumbnailView().getTaskOverlay()
.getModalStateSystemShortcut(
taskContainer.getItemInfo(), taskContainer.getTaskView()));
return createSingletonShortcutList(modalStateSystemShortcut);
}
return null;
}