diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index d7bb16e7a2..3045eca052 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.taskbar; +import static com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_ALL_APPS; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; @@ -301,7 +302,12 @@ public class TaskbarDragController extends DragController im protected void callOnDragStart() { super.callOnDragStart(); // Pre-drag has ended, start the global system drag. - AbstractFloatingView.closeAllOpenViews(mActivity); + if (mDisallowGlobalDrag) { + AbstractFloatingView.closeAllOpenViewsExcept(mActivity, TYPE_TASKBAR_ALL_APPS); + } else { + AbstractFloatingView.closeAllOpenViews(mActivity); + } + startSystemDrag((BubbleTextView) mDragObject.originalView); } @@ -536,10 +542,15 @@ public class TaskbarDragController extends DragController im private View findTaskbarTargetForIconView(@NonNull View iconView) { Object tag = iconView.getTag(); + TaskbarViewController taskbarViewController = mControllers.taskbarViewController; + if (tag instanceof ItemInfo) { ItemInfo item = (ItemInfo) tag; - TaskbarViewController taskbarViewController = mControllers.taskbarViewController; if (item.container == CONTAINER_ALL_APPS || item.container == CONTAINER_PREDICTION) { + if (mDisallowGlobalDrag) { + // We're dragging in taskbarAllApps, we don't have folders or shortcuts + return iconView; + } // Since all apps closes when the drag starts, target the all apps button instead. return taskbarViewController.getAllAppsButtonView(); } else if (item.container >= 0) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index fc26f5fe7f..ea5df87d35 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -119,10 +119,13 @@ import java.util.StringJoiner; mLauncherState = finalState; updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, false); applyState(); - mControllers.taskbarDragController.setDisallowGlobalDrag( - (finalState instanceof OverviewState)); - mControllers.taskbarDragController.setDisallowLongClick( - finalState == LauncherState.OVERVIEW_SPLIT_SELECT); + boolean disallowGlobalDrag = finalState instanceof OverviewState; + boolean disallowLongClick = finalState == LauncherState.OVERVIEW_SPLIT_SELECT; + mControllers.taskbarDragController.setDisallowGlobalDrag(disallowGlobalDrag); + mControllers.taskbarDragController.setDisallowLongClick(disallowLongClick); + mControllers.taskbarAllAppsController.setDisallowGlobalDrag(disallowGlobalDrag); + mControllers.taskbarAllAppsController.setDisallowLongClick(disallowLongClick); + mControllers.taskbarPopupController.setHideSplitOptions(disallowGlobalDrag); } }; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index da6dab1e10..9b27c9d026 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -75,6 +75,7 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba // Initialized in init. private TaskbarControllers mControllers; + private boolean mHideSplitOptions; public TaskbarPopupController(TaskbarActivityContext context) { mContext = context; @@ -100,6 +101,10 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba mPopupDataProvider.setDeepShortcutMap(deepShortcutMapCopy); } + public void setHideSplitOptions(boolean hideSplitOptions) { + mHideSplitOptions = hideSplitOptions; + } + private void updateNotificationDots(Predicate updatedDots) { final PackageUserKey packageUserKey = new PackageUserKey(null, null); Predicate matcher = info -> !packageUserKey.updateFromItemInfo(info) @@ -186,11 +191,16 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba // TODO(b/227800345): Add "Split bottom" option when tablet is in portrait mode. private Stream getSystemShortcuts() { // concat a Stream of split options with a Stream of APP_INFO + Stream appInfo = Stream.of(APP_INFO); + if (mHideSplitOptions) { + return appInfo; + } + return Stream.concat( Utilities.getSplitPositionOptions(mContext.getDeviceProfile()) .stream() .map(this::createSplitShortcutFactory), - Stream.of(APP_INFO) + appInfo ); } diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index 85c63183ad..4dc8d47f05 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -48,6 +48,8 @@ public final class TaskbarAllAppsController { private AppInfo[] mApps; private int mAppsModelFlags; private List mPredictedApps; + private boolean mDisallowGlobalDrag; + private boolean mDisallowLongClick; /** Initialize the controller. */ public void init(TaskbarControllers controllers, boolean allAppsVisible) { @@ -78,6 +80,14 @@ public final class TaskbarAllAppsController { } } + public void setDisallowGlobalDrag(boolean disableDragForOverviewState) { + mDisallowGlobalDrag = disableDragForOverviewState; + } + + public void setDisallowLongClick(boolean disallowLongClick) { + mDisallowLongClick = disallowLongClick; + } + /** Updates the current predictions. */ public void setPredictedApps(List predictedApps) { if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) { @@ -123,6 +133,12 @@ public final class TaskbarAllAppsController { mAppsView.getFloatingHeaderView() .findFixedRowByType(PredictionRowView.class) .setPredictedApps(mPredictedApps); + // 1 alternative that would be more work: + // Create a shared drag layer between taskbar and taskbarAllApps so that when dragging + // starts and taskbarAllApps can close, but the drag layer that the view is being dragged in + // doesn't also close + overlayContext.getDragController().setDisallowGlobalDrag(mDisallowGlobalDrag); + overlayContext.getDragController().setDisallowLongClick(mDisallowLongClick); } diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 875b72cb34..5a09e021b2 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -116,7 +116,7 @@ public class OverviewCommandHelper { */ @BinderThread public void addCommand(int type) { - if (mPendingCommands.size() > MAX_QUEUE_SIZE) { + if (mPendingCommands.size() >= MAX_QUEUE_SIZE) { return; } CommandInfo cmd = new CommandInfo(type); diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index acf597bc4c..ef7c6dca11 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -548,15 +548,13 @@ public class SystemUiProxy implements ISystemUiProxy { } } - public void startIntentAndTask(PendingIntent pendingIntent, Intent fillInIntent, - Bundle options1, int taskId, Bundle options2, - @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio, - RemoteTransition remoteTransition, InstanceId instanceId) { + public void startIntentAndTask(PendingIntent pendingIntent, Bundle options1, int taskId, + Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, + float splitRatio, RemoteTransition remoteTransition, InstanceId instanceId) { if (mSystemUiProxy != null) { try { - mSplitScreen.startIntentAndTask(pendingIntent, fillInIntent, options1, - taskId, options2, splitPosition, splitRatio, - remoteTransition, instanceId); + mSplitScreen.startIntentAndTask(pendingIntent, options1, taskId, options2, + splitPosition, splitRatio, remoteTransition, instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntentAndTask"); } @@ -593,13 +591,13 @@ public class SystemUiProxy implements ISystemUiProxy { } public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, - Intent fillInIntent, Bundle options1, int taskId, Bundle options2, + Bundle options1, int taskId, Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { if (mSystemUiProxy != null) { try { - mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, fillInIntent, - options1, taskId, options2, splitPosition, splitRatio, adapter, instanceId); + mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, options1, taskId, + options2, splitPosition, splitRatio, adapter, instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntentAndTaskWithLegacyTransition"); } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index 08f9fa699f..4a74ac663b 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -37,7 +37,6 @@ import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; -import android.text.TextUtils; import android.util.Log; import android.util.Pair; import android.view.RemoteAnimationAdapter; @@ -88,10 +87,8 @@ public class SplitSelectStateController { private ItemInfo mItemInfo; private Intent mInitialTaskIntent; private int mInitialTaskId = INVALID_TASK_ID; - private String mInitialTaskPackageName; private Intent mSecondTaskIntent; private int mSecondTaskId = INVALID_TASK_ID; - private String mSecondTaskPackageName; private boolean mRecentsAnimationRunning; @Nullable private UserHandle mUser; @@ -119,7 +116,6 @@ public class SplitSelectStateController { public void setInitialTaskSelect(Task task, @StagePosition int stagePosition, StatsLogManager.EventEnum splitEvent, ItemInfo itemInfo) { mInitialTaskId = task.key.id; - mInitialTaskPackageName = task.getTopComponent().getPackageName(); setInitialData(stagePosition, splitEvent, itemInfo); } @@ -131,7 +127,6 @@ public class SplitSelectStateController { mInitialTaskIntent = intent; mUser = itemInfo.user; mItemInfo = itemInfo; - mInitialTaskPackageName = intent.getComponent().getPackageName(); setInitialData(stagePosition, splitEvent, itemInfo); } @@ -143,7 +138,6 @@ public class SplitSelectStateController { @StagePosition int stagePosition, @NonNull ItemInfo itemInfo, StatsLogManager.EventEnum splitEvent) { mInitialTaskId = info.taskId; - mInitialTaskPackageName = info.topActivity.getPackageName(); setInitialData(stagePosition, splitEvent, itemInfo); } @@ -161,9 +155,9 @@ public class SplitSelectStateController { public void launchSplitTasks(Consumer callback) { Pair instanceIds = LogUtils.getShellShareableInstanceId(); - launchTasks(mInitialTaskId, mInitialTaskIntent, mInitialTaskPackageName, mSecondTaskId, - mSecondTaskIntent, mSecondTaskPackageName, mStagePosition, callback, - false /* freezeTaskList */, DEFAULT_SPLIT_RATIO, instanceIds.first); + launchTasks(mInitialTaskId, mInitialTaskIntent, mSecondTaskId, mSecondTaskIntent, + mStagePosition, callback, false /* freezeTaskList */, DEFAULT_SPLIT_RATIO, + instanceIds.first); mStatsLogManager.logger() .withItemInfo(mItemInfo) @@ -177,12 +171,10 @@ public class SplitSelectStateController { */ public void setSecondTask(Task task) { mSecondTaskId = task.key.id; - mSecondTaskPackageName = task.getTopComponent().getPackageName(); } public void setSecondTask(Intent intent) { mSecondTaskIntent = intent; - mSecondTaskPackageName = intent.getComponent().getPackageName(); } /** @@ -205,9 +197,8 @@ public class SplitSelectStateController { */ public void launchTasks(int taskId1, int taskId2, @StagePosition int stagePosition, Consumer callback, boolean freezeTaskList, float splitRatio) { - launchTasks(taskId1, null /* intent1 */, null /* packageName1 */, taskId2, - null /* intent2 */, null /* packageName2 */, stagePosition, callback, - freezeTaskList, splitRatio, null); + launchTasks(taskId1, null /* intent1 */, taskId2, null /* intent2 */, stagePosition, + callback, freezeTaskList, splitRatio, null); } /** @@ -220,8 +211,8 @@ public class SplitSelectStateController { * a split instance, null for cases that bring existing instaces to the * foreground (quickswitch, launching previous pairs from overview) */ - public void launchTasks(int taskId1, @Nullable Intent intent1, String packageName1, int taskId2, - @Nullable Intent intent2, String packageName2, @StagePosition int stagePosition, + public void launchTasks(int taskId1, @Nullable Intent intent1, int taskId2, + @Nullable Intent intent2, @StagePosition int stagePosition, Consumer callback, boolean freezeTaskList, float splitRatio, @Nullable InstanceId shellInstanceId) { TestLogging.recordEvent( @@ -240,10 +231,10 @@ public class SplitSelectStateController { null /* options2 */, stagePosition, splitRatio, remoteTransition, shellInstanceId); } else if (intent2 == null) { - launchIntentOrShortcut(intent1, packageName2, options1, taskId2, stagePosition, - splitRatio, remoteTransition, shellInstanceId); + launchIntentOrShortcut(intent1, options1, taskId2, stagePosition, splitRatio, + remoteTransition, shellInstanceId); } else if (intent1 == null) { - launchIntentOrShortcut(intent2, packageName1, options1, taskId1, + launchIntentOrShortcut(intent2, options1, taskId1, getOppositeStagePosition(stagePosition), splitRatio, remoteTransition, shellInstanceId); } else { @@ -261,10 +252,10 @@ public class SplitSelectStateController { taskId2, null /* options2 */, stagePosition, splitRatio, adapter, shellInstanceId); } else if (intent2 == null) { - launchIntentOrShortcutLegacy(intent1, packageName2, options1, taskId2, - stagePosition, splitRatio, adapter, shellInstanceId); + launchIntentOrShortcutLegacy(intent1, options1, taskId2, stagePosition, splitRatio, + adapter, shellInstanceId); } else if (intent1 == null) { - launchIntentOrShortcutLegacy(intent2, packageName1, options1, taskId1, + launchIntentOrShortcutLegacy(intent2, options1, taskId1, getOppositeStagePosition(stagePosition), splitRatio, adapter, shellInstanceId); } else { @@ -273,9 +264,8 @@ public class SplitSelectStateController { } } - private void launchIntentOrShortcut(Intent intent, String otherTaskPackageName, - ActivityOptions options1, int taskId, @StagePosition int stagePosition, - float splitRatio, RemoteTransition remoteTransition, + private void launchIntentOrShortcut(Intent intent, ActivityOptions options1, int taskId, + @StagePosition int stagePosition, float splitRatio, RemoteTransition remoteTransition, @Nullable InstanceId shellInstanceId) { PendingIntent pendingIntent = getPendingIntent(intent); final ShortcutInfo shortcutInfo = getShortcutInfo(intent, @@ -285,16 +275,14 @@ public class SplitSelectStateController { options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio, remoteTransition, shellInstanceId); } else { - mSystemUiProxy.startIntentAndTask(pendingIntent, - getFillInIntent(intent, otherTaskPackageName), options1.toBundle(), taskId, + mSystemUiProxy.startIntentAndTask(pendingIntent, options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio, remoteTransition, shellInstanceId); } } - private void launchIntentOrShortcutLegacy(Intent intent, String otherTaskPackageName, - ActivityOptions options1, int taskId, @StagePosition int stagePosition, - float splitRatio, RemoteAnimationAdapter adapter, + private void launchIntentOrShortcutLegacy(Intent intent, ActivityOptions options1, int taskId, + @StagePosition int stagePosition, float splitRatio, RemoteAnimationAdapter adapter, @Nullable InstanceId shellInstanceId) { PendingIntent pendingIntent = getPendingIntent(intent); final ShortcutInfo shortcutInfo = getShortcutInfo(intent, @@ -305,9 +293,8 @@ public class SplitSelectStateController { splitRatio, adapter, shellInstanceId); } else { mSystemUiProxy.startIntentAndTaskWithLegacyTransition(pendingIntent, - getFillInIntent(intent, otherTaskPackageName), options1.toBundle(), taskId, - null /* options2 */, stagePosition, splitRatio, adapter, - shellInstanceId); + options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio, + adapter, shellInstanceId); } } @@ -318,18 +305,6 @@ public class SplitSelectStateController { : PendingIntent.getActivity(mContext, 0, intent, FLAG_MUTABLE)); } - private Intent getFillInIntent(Intent intent, String otherTaskPackageName) { - if (intent == null) { - return null; - } - - Intent fillInIntent = new Intent(); - if (TextUtils.equals(intent.getComponent().getPackageName(), otherTaskPackageName)) { - fillInIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); - } - return fillInIntent; - } - public @StagePosition int getActiveSplitStagePosition() { return mStagePosition; @@ -464,10 +439,8 @@ public class SplitSelectStateController { public void resetState() { mInitialTaskId = INVALID_TASK_ID; mInitialTaskIntent = null; - mInitialTaskPackageName = null; mSecondTaskId = INVALID_TASK_ID; mSecondTaskIntent = null; - mSecondTaskPackageName = null; mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED; mRecentsAnimationRunning = false; mLaunchingTaskView = null; diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java index 2abd715fae..8c43fd108f 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java @@ -288,7 +288,7 @@ public class DesktopTaskView extends TaskView { public RunnableList launchTasks() { SystemUiProxy.INSTANCE.get(getContext()).showDesktopApps(); getRecentsView().startHome(); - return new RunnableList(); + return null; } @Nullable diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 583771e15e..c428c64622 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -726,13 +726,14 @@ public class TaskView extends FrameLayout implements Reusable { /** * Launch of the current task (both live and inactive tasks) with an animation. */ + @Nullable public RunnableList launchTasks() { RecentsView recentsView = getRecentsView(); RemoteTargetHandle[] remoteTargetHandles = recentsView.mRemoteTargetHandles; - RunnableList runnableList = new RunnableList(); if (isRunningTask() && remoteTargetHandles != null) { if (!mIsClickableAsLiveTile) { - return runnableList; + Log.e(TAG, "TaskView is not clickable as a live tile; returning to home."); + return null; } mIsClickableAsLiveTile = false; @@ -757,11 +758,16 @@ public class TaskView extends FrameLayout implements Reusable { if (targets == null) { // If the recents animation is cancelled somehow between the parent if block and // here, try to launch the task as a non live tile task. - launchTaskAnimated(); + RunnableList runnableList = launchTaskAnimated(); + if (runnableList == null) { + Log.e(TAG, "Recents animation cancelled and cannot launch task as non-live tile" + + "; returning to home"); + } mIsClickableAsLiveTile = true; return runnableList; } + RunnableList runnableList = new RunnableList(); AnimatorSet anim = new AnimatorSet(); TaskViewUtils.composeRecentsLaunchAnimator( anim, this, targets.apps, @@ -798,10 +804,10 @@ public class TaskView extends FrameLayout implements Reusable { }); anim.start(); recentsView.onTaskLaunchedInLiveTileMode(); + return runnableList; } else { return launchTaskAnimated(); } - return runnableList; } /** diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 3a580203c6..d98a7f378a 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -323,6 +323,10 @@ public final class FeatureFlags { public static final BooleanFlag SHOW_DOT_PAGINATION = getDebugFlag( "SHOW_DOT_PAGINATION", false, "Enable showing dot pagination in workspace"); + public static final BooleanFlag LARGE_SCREEN_WIDGET_PICKER = getDebugFlag( + "LARGE_SCREEN_WIDGET_PICKER", false, "Enable new widget picker that takes " + + "advantage of large screen format"); + public static final BooleanFlag ENABLE_TOAST_IMPRESSION_LOGGING = getDebugFlag( "ENABLE_TOAST_IMPRESSION_LOGGING", false, "Enable toast impression logging");