diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 70304023e0..7ea188bbbf 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -868,6 +868,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext { btv.post(() -> mControllers.taskbarPopupController.showForIcon(btv)); } + public boolean isInApp() { + return mControllers.taskbarStashController.isInApp(); + } + protected void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarActivityContext:"); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index b7a50fc35e..81a5c1cb9d 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -340,6 +340,8 @@ public abstract class AbsSwipeUpHandler, return ActiveGestureErrorDetector.GestureEvent.STATE_CAPTURE_SCREENSHOT; } else if (stateFlag == STATE_HANDLER_INVALIDATED) { return ActiveGestureErrorDetector.GestureEvent.STATE_HANDLER_INVALIDATED; + } else if (stateFlag == STATE_LAUNCHER_DRAWN) { + return ActiveGestureErrorDetector.GestureEvent.STATE_LAUNCHER_DRAWN; } return null; } diff --git a/quickstep/src/com/android/quickstep/MultiStateCallback.java b/quickstep/src/com/android/quickstep/MultiStateCallback.java index 56e7fb5ea4..a68bea2cc0 100644 --- a/quickstep/src/com/android/quickstep/MultiStateCallback.java +++ b/quickstep/src/com/android/quickstep/MultiStateCallback.java @@ -116,7 +116,13 @@ public class MultiStateCallback { if (gestureEvent == null) { continue; } - ActiveGestureLog.INSTANCE.trackEvent(gestureEvent); + if (gestureEvent.mLogEvent && gestureEvent.mTrackEvent) { + ActiveGestureLog.INSTANCE.addLog(gestureEvent.name(), gestureEvent); + } else if (gestureEvent.mLogEvent) { + ActiveGestureLog.INSTANCE.addLog(gestureEvent.name()); + } else if (gestureEvent.mTrackEvent) { + ActiveGestureLog.INSTANCE.trackEvent(gestureEvent); + } } } diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 813e687f34..5a9862ce0f 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -27,9 +27,9 @@ import android.util.SparseBooleanArray; import androidx.annotation.VisibleForTesting; -import com.android.quickstep.util.GroupTask; import com.android.launcher3.util.LooperExecutor; import com.android.launcher3.util.SplitConfigurationOptions; +import com.android.quickstep.util.GroupTask; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.KeyguardManagerCompat; import com.android.wm.shell.recents.IRecentTasksListener; @@ -254,8 +254,12 @@ public class RecentTasksList { TaskLoadResult allTasks = new TaskLoadResult(requestId, loadKeysOnly, rawTasks.size()); for (GroupedRecentTaskInfo rawTask : rawTasks) { - ActivityManager.RecentTaskInfo taskInfo1 = rawTask.mTaskInfo1; - ActivityManager.RecentTaskInfo taskInfo2 = rawTask.mTaskInfo2; + if (rawTask.getType() == GroupedRecentTaskInfo.TYPE_FREEFORM) { + // TODO: add entry for freeform tasks + continue; + } + ActivityManager.RecentTaskInfo taskInfo1 = rawTask.getTaskInfo1(); + ActivityManager.RecentTaskInfo taskInfo2 = rawTask.getTaskInfo2(); Task.TaskKey task1Key = new Task.TaskKey(taskInfo1); Task task1 = loadKeysOnly ? new Task(task1Key) @@ -272,7 +276,7 @@ public class RecentTasksList { task2.setLastSnapshotData(taskInfo2); } final SplitConfigurationOptions.SplitBounds launcherSplitBounds = - convertSplitBounds(rawTask.mSplitBounds); + convertSplitBounds(rawTask.getSplitBounds()); allTasks.add(new GroupTask(task1, task2, launcherSplitBounds)); } @@ -310,8 +314,8 @@ public class RecentTasksList { mSysUiProxy.getRecentTasks(Integer.MAX_VALUE, currentUserId); writer.println(prefix + " rawTasks=["); for (GroupedRecentTaskInfo task : rawTasks) { - writer.println(prefix + " t1=" + task.mTaskInfo1.taskId - + " t2=" + (task.mTaskInfo2 != null ? task.mTaskInfo2.taskId : "-1")); + writer.println(prefix + " t1=" + task.getTaskInfo1().taskId + + " t2=" + (task.getTaskInfo2() != null ? task.getTaskInfo2().taskId : "-1")); } writer.println(prefix + " ]"); } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index c650f292f0..040c55bb9c 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -462,7 +462,8 @@ public class TouchInteractionService extends Service mOverviewComponentObserver = new OverviewComponentObserver(this, mDeviceState); mOverviewCommandHelper = new OverviewCommandHelper(this, mOverviewComponentObserver, mTaskAnimationManager); - mResetGestureInputConsumer = new ResetGestureInputConsumer(mTaskAnimationManager); + mResetGestureInputConsumer = new ResetGestureInputConsumer( + mTaskAnimationManager, mTaskbarManager::getCurrentActivityContext); mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer(); mInputConsumer.registerInputConsumer(); onSystemUiFlagsChanged(mDeviceState.getSystemUiStateFlags()); diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ResetGestureInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ResetGestureInputConsumer.java index d34b40bf0c..349f4d2f2f 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/ResetGestureInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/ResetGestureInputConsumer.java @@ -17,18 +17,25 @@ package com.android.quickstep.inputconsumers; import android.view.MotionEvent; +import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.quickstep.InputConsumer; import com.android.quickstep.TaskAnimationManager; +import java.util.function.Supplier; + /** * A NO_OP input consumer which also resets any pending gesture */ public class ResetGestureInputConsumer implements InputConsumer { private final TaskAnimationManager mTaskAnimationManager; + private final Supplier mActivityContextSupplier; - public ResetGestureInputConsumer(TaskAnimationManager taskAnimationManager) { + public ResetGestureInputConsumer( + TaskAnimationManager taskAnimationManager, + Supplier activityContextSupplier) { mTaskAnimationManager = taskAnimationManager; + mActivityContextSupplier = activityContextSupplier; } @Override @@ -40,7 +47,9 @@ public class ResetGestureInputConsumer implements InputConsumer { public void onMotionEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN && mTaskAnimationManager.isRecentsAnimationRunning()) { - mTaskAnimationManager.finishRunningRecentsAnimation(false /* toHome */); + TaskbarActivityContext tac = mActivityContextSupplier.get(); + mTaskAnimationManager.finishRunningRecentsAnimation( + /* toHome= */ tac != null && !tac.isInApp()); } } } diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java b/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java index 54f632afdb..693ef100b6 100644 --- a/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java +++ b/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java @@ -46,7 +46,19 @@ public class ActiveGestureErrorDetector { STATE_GESTURE_STARTED, STATE_GESTURE_COMPLETED, STATE_GESTURE_CANCELLED, STATE_END_TARGET_ANIMATION_FINISHED, STATE_RECENTS_SCROLLING_FINISHED, STATE_CAPTURE_SCREENSHOT, STATE_SCREENSHOT_CAPTURED, STATE_HANDLER_INVALIDATED, - STATE_RECENTS_ANIMATION_CANCELED + STATE_RECENTS_ANIMATION_CANCELED, STATE_LAUNCHER_DRAWN(true, false); + + public final boolean mLogEvent; + public final boolean mTrackEvent; + + GestureEvent() { + this(false, true); + } + + GestureEvent(boolean logEvent, boolean trackEvent) { + mLogEvent = logEvent; + mTrackEvent = trackEvent; + } } private ActiveGestureErrorDetector() {} @@ -168,6 +180,7 @@ public class ActiveGestureErrorDetector { case STATE_END_TARGET_ANIMATION_FINISHED: case STATE_CAPTURE_SCREENSHOT: case STATE_HANDLER_INVALIDATED: + case STATE_LAUNCHER_DRAWN: default: // No-Op } diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index 2539ed6d26..0bed51dac4 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -250,8 +250,7 @@ public class GroupedTaskView extends TaskView { @Override public void setOverlayEnabled(boolean overlayEnabled) { - super.setOverlayEnabled(overlayEnabled); - mSnapshotView2.setOverlayEnabled(overlayEnabled); + // Intentional no-op to prevent setting smart actions overlay on thumbnails } @Override diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index 083756ad85..08a17c49f0 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -53,7 +53,9 @@ public class OverviewActionsView extends FrameLayo HIDDEN_NON_ZERO_ROTATION, HIDDEN_NO_TASKS, HIDDEN_NO_RECENTS, - HIDDEN_SPLIT_SCREEN}) + HIDDEN_SPLIT_SCREEN, + HIDDEN_SPLIT_SELECT_ACTIVE + }) @Retention(RetentionPolicy.SOURCE) public @interface ActionsHiddenFlags { } @@ -61,6 +63,7 @@ public class OverviewActionsView extends FrameLayo public static final int HIDDEN_NO_TASKS = 1 << 1; public static final int HIDDEN_NO_RECENTS = 1 << 2; public static final int HIDDEN_SPLIT_SCREEN = 1 << 3; + public static final int HIDDEN_SPLIT_SELECT_ACTIVE = 1 << 4; @IntDef(flag = true, value = { DISABLED_SCROLLING, @@ -79,6 +82,11 @@ public class OverviewActionsView extends FrameLayo private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3; private static final int INDEX_SHARE_TARGET_ALPHA = 4; + public @interface SplitButtonDisabledFlags { } + + public static final int FLAG_IS_NOT_TABLET = 1 << 0; + public static final int FLAG_SINGLE_TASK = 1 << 1; + private MultiValueAlpha mMultiValueAlpha; private Button mSplitButton; @@ -88,6 +96,9 @@ public class OverviewActionsView extends FrameLayo @ActionsDisabledFlags protected int mDisabledFlags; + @SplitButtonDisabledFlags + private int mSplitButtonDisabledFlags; + @Nullable protected T mCallbacks; @@ -182,6 +193,20 @@ public class OverviewActionsView extends FrameLayo LayoutUtils.setViewEnabled(this, isEnabled); } + /** + * Updates the proper flags to indicate whether the "Split screen" button should be enabled. + * + * @param flag The flag to update. + * @param enable Whether to enable the disable flag: True will cause view to be disabled. + */ + public void updateSplitButtonFlags(@SplitButtonDisabledFlags int flag, boolean enable) { + if (enable) { + mSplitButtonDisabledFlags |= flag; + } else { + mSplitButtonDisabledFlags &= ~flag; + } + } + public AlphaProperty getContentAlpha() { return mMultiValueAlpha.getProperty(INDEX_CONTENT_ALPHA); } @@ -263,12 +288,17 @@ public class OverviewActionsView extends FrameLayo 0, 0, 0); } - public void setSplitButtonVisible(boolean visible) { + /** + * Shows/hides the "Split" button based on the status of mHiddenFlags. + */ + public void updateSplitButtonVisibility() { if (mSplitButton == null) { return; } - - mSplitButton.setVisibility(visible ? VISIBLE : GONE); - findViewById(R.id.action_split_space).setVisibility(visible ? VISIBLE : GONE); + boolean shouldBeVisible = mSplitButtonDisabledFlags == 0 + // and neither of these flags are active + && (mHiddenFlags & (HIDDEN_SPLIT_SCREEN | HIDDEN_SPLIT_SELECT_ACTIVE)) == 0; + mSplitButton.setVisibility(shouldBeVisible ? VISIBLE : GONE); + findViewById(R.id.action_split_space).setVisibility(shouldBeVisible ? VISIBLE : GONE); } } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index be42b73d57..ae0fa1dc97 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -52,10 +52,13 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITIO import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK; import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId; import static com.android.quickstep.views.ClearAllButton.DISMISS_ALPHA; +import static com.android.quickstep.views.OverviewActionsView.FLAG_IS_NOT_TABLET; +import static com.android.quickstep.views.OverviewActionsView.FLAG_SINGLE_TASK; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_RECENTS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_TASKS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_SPLIT_SCREEN; +import static com.android.quickstep.views.OverviewActionsView.HIDDEN_SPLIT_SELECT_ACTIVE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -3394,11 +3397,11 @@ public abstract class RecentsView 1); + mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SELECT_ACTIVE, isSplitSelectionActive()); + mActionsView.updateSplitButtonFlags(FLAG_IS_NOT_TABLET, + !mActivity.getDeviceProfile().isTablet); + mActionsView.updateSplitButtonFlags(FLAG_SINGLE_TASK, getTaskViewCount() <= 1); + mActionsView.updateSplitButtonVisibility(); } /** diff --git a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java index 4e497163b5..262dc37e75 100644 --- a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +++ b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java @@ -70,7 +70,7 @@ public class RecentTasksListTest { @Test public void loadTasksInBackground_onlyKeys_noValidTaskDescription() { - GroupedRecentTaskInfo recentTaskInfos = new GroupedRecentTaskInfo( + GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forSplitTasks( new ActivityManager.RecentTaskInfo(), new ActivityManager.RecentTaskInfo(), null); when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt())) .thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos))); @@ -90,8 +90,8 @@ public class RecentTasksListTest { task1.taskDescription = new ActivityManager.TaskDescription(taskDescription); ActivityManager.RecentTaskInfo task2 = new ActivityManager.RecentTaskInfo(); task2.taskDescription = new ActivityManager.TaskDescription(); - GroupedRecentTaskInfo recentTaskInfos = new GroupedRecentTaskInfo( - task1, task2, null); + GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forSplitTasks(task1, task2, + null); when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt())) .thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos))); diff --git a/res/layout/user_folder_icon_normalized.xml b/res/layout/user_folder_icon_normalized.xml index 87bf33df8b..4dee6e7ec3 100644 --- a/res/layout/user_folder_icon_normalized.xml +++ b/res/layout/user_folder_icon_normalized.xml @@ -34,7 +34,8 @@ android:clipChildren="false" android:orientation="horizontal" android:paddingLeft="12dp" - android:paddingRight="12dp" > + android:paddingRight="12dp" + android:alpha="0">